From 5e3a3412ba128473114202732e4a9537d1b93ee4 Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Tue, 6 May 2014 21:28:22 +0200 Subject: [PATCH] API: Expose git branch in siteinfo 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 --- includes/api/ApiQuerySiteinfo.php | 2 ++ includes/specials/SpecialVersion.php | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/includes/api/ApiQuerySiteinfo.php b/includes/api/ApiQuerySiteinfo.php index b0e9bd227e..636d798c2e 100644 --- a/includes/api/ApiQuerySiteinfo.php +++ b/includes/api/ApiQuerySiteinfo.php @@ -180,6 +180,8 @@ class ApiQuerySiteinfo extends ApiQueryBase { $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 ) { diff --git a/includes/specials/SpecialVersion.php b/includes/specials/SpecialVersion.php index e61d17a886..41847dc8ad 100644 --- a/includes/specials/SpecialVersion.php +++ b/includes/specials/SpecialVersion.php @@ -1113,6 +1113,15 @@ class SpecialVersion extends SpecialPage { 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 -- 2.20.1