소스 검색

Git local distant

stany.ferer 3 달 전
부모
커밋
6b6c7e384f
1개의 변경된 파일5개의 추가작업 그리고 5개의 파일을 삭제
  1. 5 5
      core/class/git.class.php

+ 5 - 5
core/class/git.class.php

@@ -39,15 +39,15 @@ class git
     public static function getCommitHash($_target = NULL)
     {
         if ($_target == NULL) {
-            $target = "HEAD";
+            // Commit local HEAD
+            $cmd = 'git log --pretty="%H" -n1 HEAD';
         } else {
-            $target = "origin/" . $_target;
+            // On met à jour les refs distantes avant de lire origin/$_target
+            exec('git fetch --all --prune');
+            $cmd = 'git log --pretty="%H" -n1 origin/' . $_target;
         }
-
-        exec('git fetch --all --prune');
         $output = [];
         $retval = 0;
-        $cmd = 'git log --pretty="%H" -n1 ' . $target;
         $result = exec($cmd, $output, $retval);
         return substr(trim($result), 0, 10);
     }