ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilGitInformation Class Reference

Class ilGitInformation. More...

+ Inheritance diagram for ilGitInformation:
+ Collaboration diagram for ilGitInformation:

Public Member Functions

 getInformationAsHtml ()
 

Static Private Member Functions

static detect ()
 

Static Private Attributes

static array $revision_information = null
 

Detailed Description

Class ilGitInformation.

Author
Michael Jansen mjans.nosp@m.en@d.nosp@m.ataba.nosp@m.y.de

Definition at line 25 of file class.ilGitInformation.php.

Member Function Documentation

◆ detect()

static ilGitInformation::detect ( )
staticprivate

Definition at line 32 of file class.ilGitInformation.php.

References $DIC, $lng, ilShellUtil\execQuoted(), ilUtil\isWindows(), and null.

32  : void
33  {
34  global $DIC;
35 
36  $lng = $DIC->language();
37 
38  if (null !== self::$revision_information) {
39  return;
40  }
41 
42  $info = array();
43 
44  if (!ilUtil::isWindows()) {
45  $origin = ilShellUtil::execQuoted('git config --get remote.origin.url');
46  $branch = ilShellUtil::execQuoted('git rev-parse --abbrev-ref HEAD');
47  $version_mini_hash = ilShellUtil::execQuoted('git rev-parse --short HEAD');
48  $version_number = ilShellUtil::execQuoted('git rev-list --count HEAD');
49  $line = ilShellUtil::execQuoted('git log -1');
50 
51  if (!empty($origin[0])) {
52  $origin = $origin[0];
53  }
54 
55  if (!empty($branch[0])) {
56  $branch = $branch[0];
57  }
58 
59  if (!empty($version_number[0])) {
60  $version_number = $version_number[0];
61  }
62 
63  if (!empty($version_mini_hash[0])) {
64  $version_mini_hash = $version_mini_hash[0];
65  }
66 
67  if ($line && array_filter($line)) {
68  $line = implode(' | ', array_filter($line));
69  }
70  } else {
71  $origin = trim(exec('git config --get remote.origin.url'));
72  $branch = trim(exec('git rev-parse --abbrev-ref HEAD'));
73  $version_mini_hash = trim(exec('git rev-parse --short HEAD'));
74  $version_number = exec('git rev-list --count HEAD');
75  $line = trim(exec('git log -1'));
76  }
77 
78  if ($origin) {
79  $info[] = $origin;
80  }
81 
82  if ($branch) {
83  $info[] = $branch;
84  }
85 
86  if ($version_number) {
87  $info[] = sprintf($lng->txt('git_revision'), $version_number);
88  }
89 
90  if ($version_mini_hash) {
91  $info[] = sprintf($lng->txt('git_hash_short'), $version_mini_hash);
92  }
93 
94  if ($line) {
95  $info[] = sprintf($lng->txt('git_last_commit'), $line);
96  }
97 
98  self::$revision_information = $info;
99  }
static isWindows()
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
global $DIC
Definition: shib_login.php:22
static execQuoted(string $cmd, ?string $args=null)
global $lng
Definition: privfeed.php:31
+ Here is the call graph for this function:

◆ getInformationAsHtml()

ilGitInformation::getInformationAsHtml ( )

Implements ilVersionControlInformation.

Definition at line 101 of file class.ilGitInformation.php.

101  : string
102  {
103  self::detect();
104 
105  return implode("<br />", self::$revision_information);
106  }

Field Documentation

◆ $revision_information

array ilGitInformation::$revision_information = null
staticprivate

Definition at line 30 of file class.ilGitInformation.php.


The documentation for this class was generated from the following file: