ILIAS  release_7 Revision v7.30-3-g800a261c036
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
4require_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) {
28 }
29
30 $info = array();
31
32 if (!ilUtil::isWindows()) {
33 $origin = ilUtil::execQuoted('git config --get remote.origin.url');
34 $branch = ilUtil::execQuoted('git rev-parse --abbrev-ref HEAD');
35 $version_mini_hash = ilUtil::execQuoted('git rev-parse --short HEAD');
36 $version_number = ilUtil::execQuoted('git rev-list --count HEAD');
37 $line = ilUtil::execQuoted('git log -1');
38
39 if ($origin[0]) {
40 $origin = $origin[0];
41 }
42
43 if ($branch[0]) {
44 $branch = $branch[0];
45 }
46
47 if ($version_number[0]) {
48 $version_number = $version_number[0];
49 }
50
51 if ($version_mini_hash[0]) {
52 $version_mini_hash = $version_mini_hash[0];
53 }
54
55 if ($line && array_filter($line)) {
56 $line = implode(' | ', array_filter($line));
57 }
58 } else {
59 $origin = trim(exec('git config --get remote.origin.url'));
60 $branch = trim(exec('git rev-parse --abbrev-ref HEAD'));
61 $version_mini_hash = trim(exec('git rev-parse --short HEAD'));
62 $version_number = exec('git rev-list --count HEAD');
63 $line = trim(exec('git log -1'));
64 }
65
66 if ($origin) {
67 $info[] = $origin;
68 }
69
70 if ($branch) {
71 $info[] = $branch;
72 }
73
74 if ($version_number) {
75 $info[] = sprintf($lng->txt('git_revision'), $version_number);
76 }
77
78 if ($version_mini_hash) {
79 $info[] = sprintf($lng->txt('git_hash_short'), $version_mini_hash);
80 }
81
82 if ($line) {
83 $info[] = sprintf($lng->txt('git_last_commit'), $line);
84 }
85
86 self::$revision_information = $info;
87 }
88
92 public function getInformationAsHtml()
93 {
95
96 return implode("<br />", self::$revision_information);
97 }
98}
An exception for terminatinating execution or to throw for unit testing.
Class ilGitInformation.
static execQuoted($cmd, $args=null)
exec command and fix spaces on windows
static isWindows()
check wether the current client system is a windows system
global $DIC
Definition: goto.php:24
$lng