repo-report.php 2.11 KB
Newer Older
1 2
<?php

3 4 5 6 7 8 9 10
/**
 * 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
 */
11 12 13
function repo($path, $branch) {
  $escPath = escapeshellarg($path);
  $escBranch = escapeshellarg($branch);
14 15 16 17 18 19
  $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,
    );
20 21
  }
  else {
22 23
    return array();
  }
24 25 26
}

$DM_SOURCEDIR = getenv('DM_SOURCEDIR');
27
$DM_VERSION = getenv('DM_VERSION');
28
$data = array(
29
  'version' => $DM_VERSION,
30 31 32 33
  'timestamp' => array(
    'pretty' => date('r'),
    'epoch' => time(),
  ),
34 35 36 37 38 39 40
  'tar' => array(),
  'git' => array(
    'civicrm-backdrop@1.x' => repo("$DM_SOURCEDIR/backdrop", getenv('DM_REF_BACKDROP')),
    'civicrm-core' => repo("$DM_SOURCEDIR", getenv('DM_REF_CORE')),
    'civicrm-drupal@6.x' => repo("$DM_SOURCEDIR/drupal", getenv('DM_REF_DRUPAL6')),
    'civicrm-drupal@7.x' => repo("$DM_SOURCEDIR/drupal", getenv('DM_REF_DRUPAL')),
    //'civicrm-drupal@8.x' => repo("$DM_SOURCEDIR/drupal", getenv('DM_REF_DRUPAL8')),
41
    'civicrm-joomla' => repo("$DM_SOURCEDIR/joomla", getenv('DM_REF_JOOMLA')),
42 43 44
    'civicrm-packages' => repo("$DM_SOURCEDIR/packages", getenv('DM_REF_PACKAGES')),
    'civicrm-wordpress' => repo("$DM_SOURCEDIR/WordPress", getenv('DM_REF_WORDPRESS')),
  ),
45
);
46 47 48 49 50 51 52 53 54 55 56 57 58 59

if (getenv('BPACK')) {
  $data['tar']['Backdrop'] = "civicrm-$DM_VERSION-backdrop-unstable.tar.gz";
}
if (getenv('J5PACK')) {
  $data['tar']['Joomla'] = "civicrm-$DM_VERSION-joomla.zip";
}
if (getenv('D56PACK')) {
  $data['tar']['Drupal6'] = "civicrm-$DM_VERSION-drupal6.tar.gz";
}
if (getenv('D5PACK')) {
  $data['tar']['Drupal'] = "civicrm-$DM_VERSION-drupal.tar.gz";
}
if (getenv('WPPACK')) {
60
  $data['tar']['WordPress'] = "civicrm-$DM_VERSION-wordpress.zip";
61 62 63 64 65
}
if (getenv('L10NPACK')) {
  $data['tar']['L10n'] = "civicrm-$DM_VERSION-l10n.tar.gz";
}

66
ksort($data);
67 68
ksort($data['tar']);
ksort($data['git']);
69
$data['rev'] = $DM_VERSION . '-' . md5(json_encode($data));
70
echo json_encode($data);