forked from phpmyadmin/phpmyadmin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdisplay_git_revision.lib.php
87 lines (81 loc) · 2.9 KB
/
display_git_revision.lib.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Displays form for password change
*
* @package PhpMyAdmin
*/
use PhpMyAdmin\Core;
use PhpMyAdmin\Response;
/**
* Prints details about the current Git commit revision
*
* @return void
*/
function PMA_printGitRevision()
{
if (! $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT')) {
$response = Response::getInstance();
$response->setRequestStatus(false);
return;
}
// load revision data from repo
$GLOBALS['PMA_Config']->checkGitRevision();
// if using a remote commit fast-forwarded, link to GitHub
$commit_hash = substr(
$GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_COMMITHASH'),
0,
7
);
$commit_hash = '<strong title="'
. htmlspecialchars($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_MESSAGE'))
. '">' . $commit_hash . '</strong>';
if ($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_ISREMOTECOMMIT')) {
$commit_hash = '<a href="'
. Core::linkURL(
'https://github.com/phpmyadmin/phpmyadmin/commit/'
. $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_COMMITHASH')
)
. '" rel="noopener noreferrer" target="_blank">' . $commit_hash . '</a>';
}
$branch = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_BRANCH');
if ($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_ISREMOTEBRANCH')) {
$branch = '<a href="'
. Core::linkURL(
'https://github.com/phpmyadmin/phpmyadmin/tree/'
. $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_BRANCH')
)
. '" rel="noopener noreferrer" target="_blank">' . $branch . '</a>';
}
if ($branch !== false) {
$branch = sprintf(__('%1$s from %2$s branch'), $commit_hash, $branch);
} else {
$branch = $commit_hash . ' (' . __('no branch') . ')';
}
$committer = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_COMMITTER');
$author = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_AUTHOR');
PMA_printListItem(
__('Git revision:') . ' '
. $branch . ',<br /> '
. sprintf(
__('committed on %1$s by %2$s'),
PhpMyAdmin\Util::localisedDate(strtotime($committer['date'])),
'<a href="' . Core::linkURL(
'mailto:' . htmlspecialchars($committer['email'])
) . '">'
. htmlspecialchars($committer['name']) . '</a>'
)
. ($author != $committer
? ', <br />'
. sprintf(
__('authored on %1$s by %2$s'),
PhpMyAdmin\Util::localisedDate(strtotime($author['date'])),
'<a href="' . Core::linkURL(
'mailto:' . htmlspecialchars($author['email'])
) . '">'
. htmlspecialchars($author['name']) . '</a>'
)
: ''),
'li_pma_version_git', null, null, null
);
}