'; $END_CONTRIBUTORS = ''; $inHeader = true; $inFooter = false; $header = []; $contributors = []; $footer = []; if ( !file_exists( $CREDITS ) ) { exit( 'No CREDITS file found. Are you running this script in the right directory?' ); } $lines = explode( "\n", file_get_contents( $CREDITS ) ); foreach ( $lines as $line ) { if ( $inHeader ) { $header[] = $line; $inHeader = $line !== $START_CONTRIBUTORS; } elseif ( $inFooter ) { $footer[] = $line; } elseif ( $line == $END_CONTRIBUTORS ) { $inFooter = true; $footer[] = $line; } else { $name = substr( $line, 2 ); $contributors[$name] = true; } } unset( $lines ); $lines = explode( "\n", shell_exec( 'git log --format="%aN"' ) ); foreach ( $lines as $line ) { if ( empty( $line ) ) { continue; } if ( substr( $line, 0, 5 ) === '[BOT]' ) { continue; } $contributors[$line] = true; } $contributors = array_keys( $contributors ); $collator = Collator::create( 'root' ); $collator->setAttribute( Collator::NUMERIC_COLLATION, Collator::ON ); $collator->sort( $contributors ); array_walk( $contributors, function ( &$v, $k ) { $v = "* {$v}"; } ); file_put_contents( $CREDITS, implode( "\n", array_merge( $header, $contributors, $footer ) ) );