For browser testing, I need a reliable way to determine the branch in use
on a target wiki. One could parse the generator name forged when
querying the siteinfo, but that yields:
MediaWiki 1.24alpha instead of master
MediaWiki 1.24wmf2 instead of wmf/1.24wmf2
I am not really willing to reverse engineer the version to figure out
the branch, instead just expose it over the API.
Bug: 62509
Change-Id: If3db8f480ce0d590522741d40fb8e43b753efb41
$git = SpecialVersion::getGitHeadSha1( $GLOBALS['IP'] );
if ( $git ) {
$data['git-hash'] = $git;
+ $data['git-branch'] =
+ SpecialVersion::getGitCurrentBranch( $GLOBALS['IP'] );
} else {
$svn = SpecialVersion::getSvnRevision( $GLOBALS['IP'] );
if ( $svn ) {
return $repo->getHeadSHA1();
}
+ /**
+ * @param string $dir Directory of the git checkout
+ * @return bool|string Branch currently checked out
+ */
+ public static function getGitCurrentBranch( $dir ) {
+ $repo = new GitInfo( $dir );
+ return $repo->getCurrentBranch();
+ }
+
/**
* Get the list of entry points and their URLs
* @return string Wikitext