mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 10:24:14 +00:00
Handle remote repos better
This commit is contained in:
@@ -170,9 +170,7 @@ class Debug extends CI_Controller
|
||||
$a_versions=[];
|
||||
try {
|
||||
$st=exec('git fetch');
|
||||
$line = trim(exec('git log -n 1 --pretty=%D HEAD')); // Get local branch-descriptor
|
||||
$pieces = explode(', ', $line);
|
||||
$versions['branch'] = substr($pieces[1], strpos($pieces[1], '/') + 1);
|
||||
$versions['branch'] = trim(exec('git rev-parse --abbrev-ref HEAD')); // Get ONLY Name of the Branch we're on
|
||||
$versions['latest_commit_hash']=substr(trim(exec('git log --pretty="%H" -n1 HEAD..origin'.'/'.$versions['branch'])),0,8); // fetch latest commit-hash from repo
|
||||
} catch (Exception $e) {
|
||||
$versions['latest_commit_hash']='';
|
||||
|
||||
@@ -208,7 +208,7 @@
|
||||
<?php
|
||||
//Below is a failsafe where git commands fail
|
||||
try {
|
||||
$commitHash = trim(exec('git log --pretty="%H" -n1 HEAD'));
|
||||
$commitHash = trim(exec('git log --pretty="%H" -n1 HEAD')); // Get last LOCAL commit of HEAD
|
||||
$branch = '';
|
||||
$remote = '';
|
||||
$owner = '';
|
||||
@@ -226,7 +226,7 @@
|
||||
}
|
||||
if (isset($pieces[1])) {
|
||||
$remote = substr($pieces[1], 0, strpos($pieces[1], '/'));
|
||||
$branch = substr($pieces[1], strpos($pieces[1], '/') + 1);
|
||||
$branch = trim(exec('git rev-parse --abbrev-ref HEAD')); // Get ONLY Name of the Branch we're on
|
||||
$url = trim(exec('git remote get-url ' . $remote));
|
||||
if (strpos($url, 'https://github.com') !== false) {
|
||||
$owner = preg_replace('/https:\/\/github\.com\/(\w+)\/Wavelog\.git/', '$1', $url);
|
||||
@@ -473,4 +473,4 @@
|
||||
<?php } else { ?>
|
||||
var local_branch = 'n/a';
|
||||
<?php } ?>
|
||||
</script>
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user