Merge pull request #1973 from phl0/moreDebug
Make sure git can be executed before using its results
这个提交包含在:
当前提交
a7a0b9610f
共有 1 个文件被更改,包括 16 次插入 和 13 次删除
|
|
@ -159,23 +159,26 @@
|
|||
</div>
|
||||
</div>
|
||||
<?php if (file_exists('.git')) { ?>
|
||||
<div class="card">
|
||||
<?php
|
||||
$commitHash = trim(exec('git log --pretty="%H" -n1 HEAD'));
|
||||
$commitDate = trim(exec('git log --pretty="%ci" -n1 HEAD'));
|
||||
$line = trim(exec('git log -n 1 --pretty=%D HEAD'));
|
||||
$pieces = explode(', ', $line);
|
||||
$remote = substr($pieces[1], 0, strpos($pieces[1], '/'));
|
||||
$branch = substr($pieces[1], strpos($pieces[1], '/')+1);
|
||||
$url = trim(exec('git remote get-url '.$remote));
|
||||
$owner = '';
|
||||
if (strpos($url, 'https://github.com') !== false) {
|
||||
$owner = preg_replace('/https:\/\/github\.com\/(\w+)\/Cloudlog\.git/', '$1', $url);
|
||||
} else if (strpos($url, 'git@github.com') !== false) {
|
||||
$owner = preg_replace('/git@github\.com:(\w+)\/Cloudlog\.git/', '$1', $url);
|
||||
// only proceed here if git can actually be executed
|
||||
if ($commitHash != "") {
|
||||
$commitDate = trim(exec('git log --pretty="%ci" -n1 HEAD'));
|
||||
$line = trim(exec('git log -n 1 --pretty=%D HEAD'));
|
||||
$pieces = explode(', ', $line);
|
||||
$remote = substr($pieces[1], 0, strpos($pieces[1], '/'));
|
||||
$branch = substr($pieces[1], strpos($pieces[1], '/')+1);
|
||||
$url = trim(exec('git remote get-url '.$remote));
|
||||
$owner = '';
|
||||
if (strpos($url, 'https://github.com') !== false) {
|
||||
$owner = preg_replace('/https:\/\/github\.com\/(\w+)\/Cloudlog\.git/', '$1', $url);
|
||||
} else if (strpos($url, 'git@github.com') !== false) {
|
||||
$owner = preg_replace('/git@github\.com:(\w+)\/Cloudlog\.git/', '$1', $url);
|
||||
}
|
||||
$tag = trim(exec('git describe --tags '.$commitHash));
|
||||
}
|
||||
$tag = trim(exec('git describe --tags '.$commitHash));
|
||||
?>
|
||||
<div class="card">
|
||||
<div class="card-header">Git Information</div>
|
||||
<div class="card-body">
|
||||
<table width="100%">
|
||||
|
|
|
|||
正在加载…
在新工单中引用