From bf03f7bde354779cacacc2695c836a25fd468c0a Mon Sep 17 00:00:00 2001 From: Max Semenik Date: Mon, 16 Oct 2017 20:29:58 -0700 Subject: [PATCH] Convert GitInfo to the new shell framework Change-Id: I2fdebe8748708412c59a9de4028cc2e280c8d0c8 --- includes/GitInfo.php | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/includes/GitInfo.php b/includes/GitInfo.php index 3c600ed984..8095fd7308 100644 --- a/includes/GitInfo.php +++ b/includes/GitInfo.php @@ -23,6 +23,8 @@ * @file */ +use MediaWiki\Shell\Shell; + class GitInfo { /** @@ -221,13 +223,19 @@ class GitInfo { is_executable( $wgGitBin ) && $this->getHead() !== false ) { - $environment = [ "GIT_DIR" => $this->basedir ]; - $cmd = wfEscapeShellArg( $wgGitBin ) . - " show -s --format=format:%ct HEAD"; - $retc = false; - $commitDate = wfShellExec( $cmd, $retc, $environment ); - if ( $retc === 0 ) { - $date = (int)$commitDate; + $cmd = [ + $wgGitBin, + 'show', + '-s', + '--format=format:%ct', + 'HEAD', + ]; + $result = Shell::command( $cmd ) + ->environment( [ 'GIT_DIR' => $this->basedir ] ) + ->execute(); + + if ( $result->getExitCode() === 0 ) { + $date = (int)$result->getStdout(); } } $this->cache['headCommitDate'] = $date; -- 2.20.1