LogoKolab Groupware OBS > Projects
Log In

View File 0010-No-version-information-can-be-obtained-using-git-use.patch of Package phabricator (Project Infrastructure)

From 951d1328fd88417d3276427b71f24d7f5e1195d1 Mon Sep 17 00:00:00 2001
From: "Jeroen van Meeuwen (Kolab Systems)" <vanmeeuwen@kolabsys.com>
Date: Thu, 1 Dec 2016 13:15:06 +0100
Subject: [PATCH 10/15] No version information can be obtained using git -- use
 rpm.

---
 .../PhabricatorConfigVersionController.php         | 36 +++++++++++++---------
 1 file changed, 22 insertions(+), 14 deletions(-)

diff --git a/src/applications/config/controller/PhabricatorConfigVersionController.php b/src/applications/config/controller/PhabricatorConfigVersionController.php
index 15877dd..110de95 100644
--- a/src/applications/config/controller/PhabricatorConfigVersionController.php
+++ b/src/applications/config/controller/PhabricatorConfigVersionController.php
@@ -62,6 +62,14 @@ final class PhabricatorConfigVersionController
       'phutil',
     );
 
+    $pkg_specs = array(
+      'phabricator' => 'phabricator',
+      'arcanist' => 'arcanist',
+      'phutil' => 'libphutil',
+      'sprint' => 'phabricator-extension-sprint',
+      'security' => 'phabricator-extension-security',
+    );
+
     $all_libraries = PhutilBootloader::getInstance()->getAllLibraries();
     // This puts the core libraries at the top:
     $other_libraries = array_diff($all_libraries, $specs);
@@ -69,22 +77,22 @@ final class PhabricatorConfigVersionController
 
     $futures = array();
     foreach ($specs as $lib) {
-      $root = dirname(phutil_get_library_root($lib));
-      $futures[$lib] =
-        id(new ExecFuture('git log --format=%s -n 1 --', '%H %ct'))
-        ->setCWD($root);
+      if (array_key_exists($lib, $pkg_specs)) {
+        $lib = $pkg_specs[$lib];
+      }
+
+      $results[$lib] =
+        id(new ExecFuture("rpm --query --queryformat=%%{VERSION} $lib"));
     }
 
-    $results = array();
-    foreach ($futures as $key => $future) {
-      list($err, $stdout) = $future->resolve();
-      if (!$err) {
-        list($hash, $epoch) = explode(' ', $stdout);
-        $version = pht('%s (%s)', $hash, phabricator_date($epoch, $viewer));
-      } else {
-        $version = pht('Unknown');
-      }
-      $results[$key] = $version;
+    foreach ($results as $key => $future) {
+        list($ret, $version) = $future->resolve();
+
+        if ($ret > 0) {
+            $results[$key] = 'Unknown';
+        } else {
+            $results[$key] = $version;
+        }
     }
 
     return $results;
-- 
2.9.3