Display branch info on unpushed branches correctly
这个提交包含在:
父节点
cdf56086bb
当前提交
ad3529fbf8
共有 1 个文件被更改,包括 12 次插入 和 8 次删除
|
|
@ -161,19 +161,23 @@
|
|||
<?php if (file_exists('.git')) { ?>
|
||||
<?php
|
||||
$commitHash = trim(exec('git log --pretty="%H" -n1 HEAD'));
|
||||
$branch = '';
|
||||
$remote = '';
|
||||
$owner = '';
|
||||
// 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);
|
||||
if (isset($pieces[1])) {
|
||||
$remote = substr($pieces[1], 0, strpos($pieces[1], '/'));
|
||||
$branch = substr($pieces[1], strpos($pieces[1], '/')+1);
|
||||
$url = trim(exec('git remote get-url '.$remote));
|
||||
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));
|
||||
}
|
||||
|
|
|
|||
正在加载…
在新工单中引用