Index: trunk/extensions/Translate/scripts/sync-group.php |
— | — | @@ -12,6 +12,7 @@ |
13 | 13 | |
14 | 14 | /// @cond |
15 | 15 | |
| 16 | +$options = array( 'git' ); |
16 | 17 | $optionsWithArgs = array( 'group', 'groupprefix', 'lang', 'start', 'end' ); |
17 | 18 | require( dirname( __FILE__ ) . '/cli.inc' ); |
18 | 19 | |
— | — | @@ -24,6 +25,8 @@ |
25 | 26 | --group Comma separated list of group IDs (cannot use groupprefix) |
26 | 27 | --groupprefix Prefix of group IDs to be exported message groups (cannot use |
27 | 28 | group) |
| 29 | + --git Use git to retrieve last modified date of i18n files. Will use |
| 30 | + subversion by default and fallback on filesystem timestamp. |
28 | 31 | --lang Comma separated list of language codes or * |
29 | 32 | --norc Do not add entries to recent changes table |
30 | 33 | --help This help message |
— | — | @@ -124,7 +127,13 @@ |
125 | 128 | $cs->nocolor = true; |
126 | 129 | } |
127 | 130 | |
128 | | - $ts = $cs->getTimestampsFromSvn( $file ); |
| 131 | + # Guess last modified date of the file from either git, svn or filesystem |
| 132 | + $ts = false; |
| 133 | + if( isset( $options['git'] ) ) { |
| 134 | + $ts = $cs->getTimestampsFromGit( $file ); |
| 135 | + } else { |
| 136 | + $ts = $cs->getTimestampsFromSvn( $file ); |
| 137 | + } |
129 | 138 | if ( !$ts ) { |
130 | 139 | $ts = $cs->getTimestampsFromFs( $file ); |
131 | 140 | } |
— | — | @@ -182,6 +191,23 @@ |
183 | 192 | } |
184 | 193 | |
185 | 194 | /** |
| 195 | + * Fetch last changed timestamp for a versioned file for conflict resolution. |
| 196 | + * @param $file \string Filename with full path. |
| 197 | + * @return \string Timestamp or false. |
| 198 | + */ |
| 199 | + public function getTimestampsFromGit( $file ) { |
| 200 | + $file = escapeshellarg( $file ); |
| 201 | + $retval = 0; |
| 202 | + $output = wfShellExec( "git log -n 1 --format=%cd $file", $retval ); |
| 203 | + |
| 204 | + if ( $retval ) { |
| 205 | + return false; |
| 206 | + } |
| 207 | + |
| 208 | + return strtotime( $output ); |
| 209 | + } |
| 210 | + |
| 211 | + /** |
186 | 212 | * Fetch last changed timestamp for any file for conflict resolution. |
187 | 213 | * @param $file \string Filename with full path. |
188 | 214 | * @return \string Timestamp or false. |