*/
$wgUpgradeKey = false;
+/**
+ * Fully specified path to git binary
+ */
+$wgGitBin = '/usr/bin/git';
+
/**
* Map GIT repository URLs to viewer URLs to provide links in Special:Version
*
return $sha1;
}
+ /**
+ * Return the commit date of HEAD entry of the git code repository
+ *
+ * @since 1.22
+ * @return int|bool Commit date (UNIX timestamp) or false
+ */
+ public function getHeadCommitDate() {
+ global $wgGitBin;
+
+ if ( !is_file( $wgGitBin ) || !is_executable( $wgGitBin ) ) {
+ return false;
+ }
+
+ $environment = array( "GIT_DIR" => $this->basedir );
+ $cmd = wfEscapeShellArg( $wgGitBin ) . " show -s --format=format:%ct HEAD";
+ $retc = false;
+ $commitDate = wfShellExec( $cmd, $retc, $environment );
+
+ if ( $retc !== 0 ) {
+ return false;
+ } else {
+ return (int)$commitDate;
+ }
+
+ }
+
/**
* Return the name of the current branch, or HEAD if not found
* @return string The branch name, HEAD, or false
'config-mod-security' => "'''Warning:''' Your web server has [http://modsecurity.org/ mod_security] enabled. If misconfigured, it can cause problems for MediaWiki or other software that allows users to post arbitrary content.
Refer to [http://modsecurity.org/documentation/ mod_security documentation] or contact your host's support if you encounter random errors.",
'config-diff3-bad' => 'GNU diff3 not found.',
+ 'config-git' => 'Found the Git version control software: <code>$1</code>.',
+ 'config-git-bad' => 'Git version control software not found.',
'config-imagemagick' => 'Found ImageMagick: <code>$1</code>.
Image thumbnailing will be enabled if you enable uploads.',
'config-gd' => 'Found GD graphics library built-in.
'config-xcache' => 'Message indicates if this program is available',
'config-apc' => 'Message indicates if this program is available',
'config-wincache' => 'Message indicates if this program is available',
+ 'config-git' => 'Message if Git version control software is available.
+Parameter:
+* $1 is the <code>Git</code> executable file name.',
+ 'config-git-bad' => 'Message if Git version control software is not found.',
'config-imagemagick' => '$1 is ImageMagick\'s <code>convert</code> executable file name.
Add dir="ltr" to the <nowiki><code></nowiki> for right-to-left languages.',
'envCheckModSecurity',
'envCheckDiff3',
'envCheckGraphics',
+ 'envCheckGit',
'envCheckServer',
'envCheckPath',
'envCheckExtension',
'wgDBtype',
'wgDiff3',
'wgImageMagickConvertCommand',
+ 'wgGitBin',
'IP',
'wgServer',
'wgScriptPath',
*/
protected function envCheckGraphics() {
$names = array( wfIsWindows() ? 'convert.exe' : 'convert' );
- $convert = self::locateExecutableInDefaultPaths( $names, array( '$1 -version', 'ImageMagick' ) );
+ $versionInfo = array( '$1 -version', 'ImageMagick' );
+ $convert = self::locateExecutableInDefaultPaths( $names, $versionInfo );
$this->setVar( 'wgImageMagickConvertCommand', '' );
if ( $convert ) {
return true;
}
+ /**
+ * Search for git.
+ *
+ * @since 1.22
+ * @return bool
+ */
+ protected function envCheckGit() {
+ $names = array( wfIsWindows() ? 'git.exe' : 'git' );
+ $versionInfo = array( '$1 --version', 'git version' );
+
+ $git = self::locateExecutableInDefaultPaths( $names, $versionInfo );
+
+ if ( $git ) {
+ $this->setVar( 'wgGitBin', $git );
+ $this->showMessage( 'config-git', $git );
+ } else {
+ $this->setVar( 'wgGitBin', false );
+ $this->showMessage( 'config-git-bad' );
+ }
+ return true;
+ }
+
/**
* Environment check for the server hostname.
*/
}
/**
- * @return bool|string wgVersion + HEAD sha1 stripped to the first 7 chars. False on failure
+ * @since 1.22 Returns the HEAD date in addition to the sha1 and link
+ * @return bool|string wgVersion + HEAD sha1 stripped to the first 7 chars with link and date, or false on failure
*/
private static function getVersionLinkedGit() {
- global $IP;
+ global $IP, $wgLang;
$gitInfo = new GitInfo( $IP );
$headSHA1 = $gitInfo->getHeadSHA1();
}
$shortSHA1 = '(' . substr( $headSHA1, 0, 7 ) . ')';
- $viewerUrl = $gitInfo->getHeadViewUrl();
- if ( $viewerUrl !== false ) {
- $shortSHA1 = "[$viewerUrl $shortSHA1]";
+
+ $gitHeadUrl = $gitInfo->getHeadViewUrl();
+ if ( $gitHeadUrl !== false ) {
+ $shortSHA1 = "[$gitHeadUrl $shortSHA1]";
+ }
+
+ $gitHeadCommitDate = $gitInfo->getHeadCommitDate();
+ if ( $gitHeadCommitDate ) {
+ $shortSHA1 .= "<br/>" . $wgLang->timeanddate( $gitHeadCommitDate, true );
}
+
return self::getwgVersionLinked() . " $shortSHA1";
}
* @return string
*/
function getCreditsForExtension( array $extension ) {
+ global $wgLang;
+
$name = isset( $extension['name'] ) ? $extension['name'] : '[no name]';
$vcsText = false;
if ( $gitViewerUrl !== false ) {
$vcsText = "[$gitViewerUrl $vcsText]";
}
+ $gitHeadCommitDate = $gitInfo->getHeadCommitDate();
+ if ( $gitHeadCommitDate ) {
+ $vcsText .= "<br/>" . $wgLang->timeanddate( $gitHeadCommitDate, true );
+ }
} else {
$svnInfo = self::getSvnInfo( dirname( $extension['path'] ) );
# Make subversion text/link.