CRM-19417 - distmaker - Rename report file. Tweak edge-case for missing repos.
authorTim Otten <totten@civicrm.org>
Wed, 28 Sep 2016 19:21:08 +0000 (15:21 -0400)
committerTim Otten <totten@civicrm.org>
Thu, 4 May 2017 06:09:12 +0000 (01:09 -0500)
distmaker/dists/repo-report.sh
distmaker/utils/repo-report.php

index 4a14e41f72edebf355bf7ab35675bc36444530a6..411ede8e3327f7f8ebcb4b40c357e767fe743392 100755 (executable)
@@ -12,7 +12,7 @@ fi
 . "$P/common.sh"
 
 SRC=$DM_SOURCEDIR
-REPORT="$DM_TARGETDIR/civicrm-$DM_VERSION-repos.json"
+REPORT="$DM_TARGETDIR/civicrm-$DM_VERSION.json"
 
 env \
   DM_VERSION="$DM_VERSION" \
@@ -32,5 +32,5 @@ env \
   SKPACK="$SKPACK" \
   J5PACK="$J5PACK" \
   WP5PACK="$WP5PACK" \
-  php "$DM_SOURCEDIR/distmaker/utils/repo-report.php" > "$REPORT"
-
+  php "$DM_SOURCEDIR/distmaker/utils/repo-report.php" \
+  > "$REPORT"
index 91b6cf93b4ac5b7aca9c0446be809c0b9956eddf..8551f4cd8ebf93295f0b6bf324412a08c103e31b 100644 (file)
@@ -1,12 +1,25 @@
 <?php
 
+/**
+ * Make a small report about the git content in a given folder+branch.
+ * @param string $path
+ * @param string $branch
+ * @return array
+ *   - branch: string
+ *   - commit: string
+ */
 function repo($path, $branch) {
   $escPath = escapeshellarg($path);
   $escBranch = escapeshellarg($branch);
-  return array(
-    'branch' => $branch,
-    'commit' => `cd $escPath ; git show $escBranch | head -n1 | cut -f2 -d\ `,
-  );
+  $commit = file_exists($path) ? trim(`cd $escPath ; git show $escBranch | head -n1 | cut -f2 -d\ `) : NULL;
+  if (!empty($commit)) {
+    return array(
+      'branch' => $branch,
+      'commit' => $commit,
+    );
+  } else {
+    return array();
+  }
 }
 
 $DM_SOURCEDIR = getenv('DM_SOURCEDIR');
@@ -51,5 +64,5 @@ if (getenv('L10NPACK')) {
 ksort($data);
 ksort($data['tar']);
 ksort($data['git']);
-$data['rev'] = md5(json_encode($data));
+$data['rev'] = $DM_VERSION . '-' . md5(json_encode($data));
 echo json_encode($data);