(bug 35649) Special:Version now shows hashes of extensions checked out from git
authorAlexandre Emsenhuber <ialex.wiki@gmail.com>
Thu, 5 Apr 2012 15:13:14 +0000 (17:13 +0200)
committerAlexandre Emsenhuber <ialex.wiki@gmail.com>
Thu, 5 Apr 2012 15:13:42 +0000 (17:13 +0200)
Change-Id: I0d9540dbc103ba678dd2fb5e11c656e238e31f18

RELEASE-NOTES-1.20
includes/specials/SpecialVersion.php

index 75e3cfb..7dd6b88 100644 (file)
@@ -32,6 +32,7 @@ production.
 * (bug 22870) Separate interface message when creating a page.
 * (bug 17615) nosummary option should be reassigned on preview/captcha.
 * (bug 34355) add a variable and parser function for the namespace number.
+* (bug 35649) Special:Version now shows hashes of extensions checked out from git.
 
 === Bug fixes in 1.20 ===
 * (bug 30245) Use the correct way to construct a log page title.
index 9181de0..76d60c7 100644 (file)
@@ -415,15 +415,22 @@ class SpecialVersion extends SpecialPage {
        function getCreditsForExtension( array $extension ) {
                $name = isset( $extension['name'] ) ? $extension['name'] : '[no name]';
 
+               $vcsText = false;
+
                if ( isset( $extension['path'] ) ) {
-                       $svnInfo = self::getSvnInfo( dirname($extension['path']) );
-                       $directoryRev = isset( $svnInfo['directory-rev'] ) ? $svnInfo['directory-rev'] : null;
-                       $checkoutRev = isset( $svnInfo['checkout-rev'] ) ? $svnInfo['checkout-rev'] : null;
-                       $viewvcUrl = isset( $svnInfo['viewvc-url'] ) ? $svnInfo['viewvc-url'] : null;
-               } else {
-                       $directoryRev = null;
-                       $checkoutRev = null;
-                       $viewvcUrl = null;
+                       $gitInfo = new GitInfo( dirname( $extension['path'] ) );
+                       $gitHeadSHA1 = $gitInfo->getHeadSHA1();
+                       if ( $gitHeadSHA1 !== false ) {
+                               $vcsText = substr( $gitHeadSHA1, 0, 7 );
+                       } else {
+                               $svnInfo = self::getSvnInfo( dirname( $extension['path'] ) );
+                               # Make subversion text/link.
+                               if ( $svnInfo !== false ) {
+                                       $directoryRev = isset( $svnInfo['directory-rev'] ) ? $svnInfo['directory-rev'] : null;
+                                       $vcsText = wfMsg( 'version-svn-revision', $directoryRev, $svnInfo['checkout-rev'] );
+                                       $vcsText = isset( $svnInfo['viewvc-url'] ) ? '[' . $svnInfo['viewvc-url'] . " $vcsText]" : $vcsText;
+                               }
+                       }
                }
 
                # Make main link (or just the name if there is no URL).
@@ -441,14 +448,6 @@ class SpecialVersion extends SpecialPage {
                        $versionText = '';
                }
 
-               # Make subversion text/link.
-               if ( $checkoutRev ) {
-                       $svnText = wfMsg( 'version-svn-revision', $directoryRev, $checkoutRev );
-                       $svnText = isset( $viewvcUrl ) ? "[$viewvcUrl $svnText]" : $svnText;
-               } else {
-                       $svnText = false;
-               }
-
                # Make description text.
                $description = isset ( $extension['description'] ) ? $extension['description'] : '';
 
@@ -466,10 +465,10 @@ class SpecialVersion extends SpecialPage {
                        }
                }
 
-               if ( $svnText !== false ) {
+               if ( $vcsText !== false ) {
                        $extNameVer = "<tr>
                                <td><em>$mainLink $versionText</em></td>
-                               <td><em>$svnText</em></td>";
+                               <td><em>$vcsText</em></td>";
                } else {
                        $extNameVer = "<tr>
                                <td colspan=\"2\"><em>$mainLink $versionText</em></td>";