https://www.mediawiki.org/wiki/Special:Code/MediaWiki/113722
Revision: 113722
Author: hashar
Date: 2012-03-13 14:33:44 +0000 (Tue, 13 Mar 2012)
Log Message:
-----------
let sync-group find file timestamp using git!
Modified Paths:
--------------
trunk/extensions/Translate/scripts/sync-group.php
Modified: trunk/extensions/Translate/scripts/sync-group.php
===================================================================
--- trunk/extensions/Translate/scripts/sync-group.php 2012-03-13 13:50:09 UTC
(rev 113721)
+++ trunk/extensions/Translate/scripts/sync-group.php 2012-03-13 14:33:44 UTC
(rev 113722)
@@ -12,6 +12,7 @@
/// @cond
+$options = array( 'git' );
$optionsWithArgs = array( 'group', 'groupprefix', 'lang', 'start', 'end' );
require( dirname( __FILE__ ) . '/cli.inc' );
@@ -24,6 +25,8 @@
--group Comma separated list of group IDs (cannot use groupprefix)
--groupprefix Prefix of group IDs to be exported message groups (cannot use
group)
+ --git Use git to retrieve last modified date of i18n files. Will use
+ subversion by default and fallback on filesystem timestamp.
--lang Comma separated list of language codes or *
--norc Do not add entries to recent changes table
--help This help message
@@ -124,7 +127,13 @@
$cs->nocolor = true;
}
- $ts = $cs->getTimestampsFromSvn( $file );
+ # Guess last modified date of the file from either git, svn or
filesystem
+ $ts = false;
+ if( isset( $options['git'] ) ) {
+ $ts = $cs->getTimestampsFromGit( $file );
+ } else {
+ $ts = $cs->getTimestampsFromSvn( $file );
+ }
if ( !$ts ) {
$ts = $cs->getTimestampsFromFs( $file );
}
@@ -182,6 +191,23 @@
}
/**
+ * Fetch last changed timestamp for a versioned file for conflict
resolution.
+ * @param $file \string Filename with full path.
+ * @return \string Timestamp or false.
+ */
+ public function getTimestampsFromGit( $file ) {
+ $file = escapeshellarg( $file );
+ $retval = 0;
+ $output = wfShellExec( "git log -n 1 --format=%cd $file",
$retval );
+
+ if ( $retval ) {
+ return false;
+ }
+
+ return strtotime( $output );
+ }
+
+ /**
* Fetch last changed timestamp for any file for conflict resolution.
* @param $file \string Filename with full path.
* @return \string Timestamp or false.
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs