ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilGitInformation.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2015 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once 'Services/Administration/interfaces/interface.ilVersionControlInformation.php';
5 
11 {
15  private static $revision_information = null;
16 
20  private static function detect()
21  {
22  global $DIC;
23 
24  $lng = $DIC->language();
25 
26  if (null !== self::$revision_information) {
27  return self::$revision_information;
28  }
29 
30  $info = array();
31 
32  if (!ilUtil::isWindows()) {
33  $version_mini_hash = ilUtil::execQuoted('git rev-parse --short HEAD');
34  $version_number = ilUtil::execQuoted('git rev-list --count HEAD');
35  $line = ilUtil::execQuoted('git log -1');
36 
37  if ($version_number[0]) {
38  $version_number = $version_number[0];
39  }
40 
41  if ($version_mini_hash[0]) {
42  $version_mini_hash = $version_mini_hash[0];
43  }
44 
45  if ($line && array_filter($line)) {
46  $line = implode(' | ', array_filter($line));
47  }
48  } else {
49  $version_mini_hash = trim(exec('git rev-parse --short HEAD'));
50  $version_number = exec('git rev-list --count HEAD');
51  $line = trim(exec('git log -1'));
52  }
53 
54  if ($version_number) {
55  $info[] = sprintf($lng->txt('git_revision'), $version_number);
56  }
57 
58  if ($version_mini_hash) {
59  $info[] = sprintf($lng->txt('git_hash_short'), $version_mini_hash);
60  }
61 
62  if ($line) {
63  $info[] = sprintf($lng->txt('git_last_commit'), $line);
64  }
65 
66  self::$revision_information = $info;
67  }
68 
72  public function getInformationAsHtml()
73  {
74  self::detect();
75 
76  return implode("<br />", self::$revision_information);
77  }
78 }
Class ilGitInformation.
global $DIC
Definition: saml.php:7
static isWindows()
check wether the current client system is a windows system
Class ilVersionControlInformation.
$lng
static execQuoted($cmd, $args=null)
exec command and fix spaces on windows
$info
Definition: index.php:5