CRM-19417 - distmaker - Change report to JSON
authorTim Otten <totten@civicrm.org>
Wed, 28 Sep 2016 02:16:53 +0000 (22:16 -0400)
committerTim Otten <totten@civicrm.org>
Thu, 4 May 2017 06:08:59 +0000 (01:08 -0500)
distmaker/dists/common.sh
distmaker/dists/repo-report.sh
distmaker/utils/repo-report.php [new file with mode: 0644]

index 9f2047ffb8e9031b325a9ee9db7b9c5d491ddb69..26aeb13d6c65f1c171eb8f9af759f529c5846252 100644 (file)
@@ -239,22 +239,3 @@ function dm_git_checkout() {
     git checkout "$2"
   popd
 }
-
-function dm_key_value() {
-  echo -e "$1\n$2" | php -r '$lines = explode("\n", rtrim(file_get_contents("php://stdin"), "\r\n"), 2); fputcsv(STDOUT, $lines);'
-}
-
-## usage: dm_repo_report <name> <path> <treeish>
-function dm_repo_report() {
-  local COMMIT
-  if [ -d "$2" ]; then
-    pushd "$2" >> /dev/null
-      COMMIT=$(git show "$3" | head -n1 | cut -f2 -d\  )
-    popd >> /dev/null
-  fi
-  [ -z "$COMMIT" ] && COMMIT=NONE
-
-  #echo -e "$1\n$3\n$COMMIT" | php -r '$lines = explode("\n", rtrim(file_get_contents("php://stdin"), "\r\n")); fputcsv(STDOUT, $lines);'
-  dm_key_value "${1}.branch" $3
-  dm_key_value "${1}.commit" $COMMIT
-}
index 2bbb705f5d74fbcd1dfa16c0338dc786559264f3..1b61f66ba1e5660f5faa832c8a5a7a998136f679 100755 (executable)
@@ -12,14 +12,17 @@ fi
 . "$P/common.sh"
 
 SRC=$DM_SOURCEDIR
-REPORT="$DM_TARGETDIR/civicrm-$DM_VERSION-repos.txt"
+REPORT="$DM_TARGETDIR/civicrm-$DM_VERSION-repos.json"
+
+env \
+  DM_VERSION="$DM_VERSION" \
+  DM_SOURCEDIR="$DM_SOURCEDIR" \
+  DM_REF_CORE="$DM_REF_CORE" \
+  DM_REF_BACKDROP="$DM_REF_BACKDROP" \
+  DM_REF_DRUPAL6="$DM_REF_DRUPAL6" \
+  DM_REF_DRUPAL="$DM_REF_DRUPAL" \
+  DM_REF_JOOMLA="$DM_REF_JOOMLA" \
+  DM_REF_WORDPRESS="$DM_REF_WORDPRESS" \
+  DM_REF_PACKAGES="$DM_REF_PACKAGES" \
+  php "$DM_SOURCEDIR/distmaker/utils/repo-report.php" > "$REPORT"
 
-dm_key_value version "$DM_VERSION" > $REPORT
-dm_repo_report "civicrm-core"          "$DM_SOURCEDIR"                 "$DM_REF_CORE"          >> $REPORT
-dm_repo_report "civicrm-backdrop@1.x"  "$DM_SOURCEDIR/backdrop"        "$DM_REF_BACKDROP"      >> $REPORT
-dm_repo_report "civicrm-drupal@6.x"    "$DM_SOURCEDIR/drupal"          "$DM_REF_DRUPAL6"       >> $REPORT
-dm_repo_report "civicrm-drupal@7.x"    "$DM_SOURCEDIR/drupal"          "$DM_REF_DRUPAL"        >> $REPORT
-#dm_repo_report "civicrm-drupal@8.x"   "$DM_SOURCEDIR/drupal"          "$DM_REF_DRUPAL8"       >> $REPORT
-dm_repo_report "civicrm-joomla"        "$DM_SOURCEDIR/joomla"          "$DM_REF_JOOMLA"        >> $REPORT
-dm_repo_report "civicrm-wordpress"     "$DM_SOURCEDIR/WordPress"       "$DM_REF_WORDPRESS"     >> $REPORT
-dm_repo_report "civicrm-packages"      "$DM_SOURCEDIR/packages"        "$DM_REF_PACKAGES"      >> $REPORT
diff --git a/distmaker/utils/repo-report.php b/distmaker/utils/repo-report.php
new file mode 100644 (file)
index 0000000..79fe891
--- /dev/null
@@ -0,0 +1,24 @@
+<?php
+
+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\ `,
+  );
+}
+
+$DM_SOURCEDIR = getenv('DM_SOURCEDIR');
+$data = array(
+  'version' => getenv('DM_VERSION'),
+  'timestamp' => array(
+    'pretty' => date('r'),
+    'epoch' => time(),
+  ),
+  'civicrm-core' => repo("$DM_SOURCEDIR", getenv('DM_REF_CORE')),
+  'civicrm-packages' => repo("$DM_SOURCEDIR/packages", getenv('DM_REF_PACKAGES')),
+);
+ksort($data);
+$data['sig'] = md5(json_encode($data));
+echo json_encode($data);