|
|
@@ -41,15 +41,23 @@ class git
|
|
|
if ($_target == NULL) {
|
|
|
// Commit local HEAD
|
|
|
$cmd = 'git log --pretty="%H" -n1 HEAD';
|
|
|
+ $output = [];
|
|
|
+ $retval = 0;
|
|
|
+ $result = exec($cmd, $output, $retval);
|
|
|
+ return substr(trim($result), 0, 10);
|
|
|
} else {
|
|
|
- // On met à jour les refs distantes avant de lire origin/$_target
|
|
|
- exec('git fetch --all --prune');
|
|
|
- $cmd = 'git log --pretty="%H" -n1 origin/' . $_target;
|
|
|
+ // Hash du commit distant en temps réel
|
|
|
+ $cmd = 'git ls-remote origin "refs/heads/' . $_target . '"';
|
|
|
+ $output = [];
|
|
|
+ $retval = 0;
|
|
|
+ $result = exec($cmd, $output, $retval);
|
|
|
+ // $result ou $output[0] = "<hash>\trefs/heads/branch"
|
|
|
+ $hash = '';
|
|
|
+ if (!empty($output) && strpos($output[0], '\t') !== false) {
|
|
|
+ $hash = explode("\t", $output[0])[0];
|
|
|
+ }
|
|
|
+ return substr(trim($hash), 0, 10);
|
|
|
}
|
|
|
- $output = [];
|
|
|
- $retval = 0;
|
|
|
- $result = exec($cmd, $output, $retval);
|
|
|
- return substr(trim($result), 0, 10);
|
|
|
}
|
|
|
|
|
|
/**
|