MediaWiki REL1_30
updateCredits.php
Go to the documentation of this file.
1<?php
25if ( PHP_SAPI != 'cli' ) {
26 die( "This script can only be run from the command line.\n" );
27}
28
29$CREDITS = 'CREDITS';
30$START_CONTRIBUTORS = '<!-- BEGIN CONTRIBUTOR LIST -->';
31$END_CONTRIBUTORS = '<!-- END CONTRIBUTOR LIST -->';
32
33$inHeader = true;
34$inFooter = false;
38
39if ( !file_exists( $CREDITS ) ) {
40 exit( 'No CREDITS file found. Are you running this script in the right directory?' );
41}
42
43$lines = explode( "\n", file_get_contents( $CREDITS ) );
44foreach ( $lines as $line ) {
45 if ( $inHeader ) {
46 $header[] = $line;
48 } elseif ( $inFooter ) {
49 $footer[] = $line;
50 } elseif ( $line == $END_CONTRIBUTORS ) {
51 $inFooter = true;
52 $footer[] = $line;
53 } else {
54 $name = substr( $line, 2 );
55 $contributors[$name] = true;
56 }
57}
58unset( $lines );
59
60$lines = explode( "\n", shell_exec( 'git log --format="%aN"' ) );
61foreach ( $lines as $line ) {
62 if ( empty( $line ) ) {
63 continue;
64 }
65 if ( substr( $line, 0, 5 ) === '[BOT]' ) {
66 continue;
67 }
68 $contributors[$line] = true;
69}
70
71$contributors = array_keys( $contributors );
72$collator = Collator::create( 'root' );
73$collator->setAttribute( Collator::NUMERIC_COLLATION, Collator::ON );
75array_walk( $contributors, function ( &$v, $k ) {
76 $v = "* {$v}";
77} );
78
79file_put_contents( $CREDITS,
80 implode( "\n", array_merge( $header, $contributors, $footer ) ) );
$line
Definition cdb.php:58
Allows to change the fields on the form that will be generated $name
Definition hooks.txt:302
if(!file_exists( $CREDITS)) $lines
$header
$collator
$END_CONTRIBUTORS
if(PHP_SAPI !='cli') $CREDITS
Update the CREDITS list by merging in the list of git commit authors.
$contributors
$inHeader
$inFooter
$footer
$START_CONTRIBUTORS