Skip to content

Commit

Permalink
Resolves #166: Speed up GitTest commit-msg checks. (#168)
Browse files Browse the repository at this point in the history
  • Loading branch information
grasmash authored Jun 16, 2016
1 parent ccd115b commit ae261c4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
1 change: 1 addition & 0 deletions template/build/core/phing/tasks/validate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<if>
<istrue value="${filteredFileList}"/>
<then>
<!--@todo Pass an entire fileset to PHPCS rather than looping over a list. -->
<foreach list="${filteredFileList}" target="validate:phpcs:file" param="file"/>
</then>
</if>
Expand Down
2 changes: 1 addition & 1 deletion template/scripts/blt/update-scaffold
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ done

# Restore execute permissions.
chmod 755 blt.sh
chmod 755 scripts/git-hooks/pre-commit
chmod -R 755 scripts/git-hooks/pre-commit

echo "Changes have been pulled down. Please review and commit desired changes."
8 changes: 3 additions & 5 deletions template/tests/phpunit/Bolt/GitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,11 @@ protected function assertCommitMessageValidity($is_valid, $commit_message, $mess
chdir($this->projectDirectory);

// "2>&1" redirects standard error output to standard output.
$command = "git commit --amend -m '$commit_message' 2>&1";
$command = "mkdir -p {$this->projectDirectory}/tmp && echo '$commit_message' > {$this->projectDirectory}/tmp/blt_commit_msg && {$this->projectDirectory}/.git/hooks/commit-msg {$this->projectDirectory}/tmp/blt_commit_msg 2>&1";
print "Executing \"$command\" \n";

$output = shell_exec($command);
$invalid_commit_text = 'Invalid commit message';
$output_contains_invalid_commit_text = (bool) strstr($output, $invalid_commit_text);
$this->assertNotSame($is_valid, $output_contains_invalid_commit_text, $message);
exec($command, $output, $return);
$this->assertNotSame($is_valid, (bool) $return, $message);
}

}

0 comments on commit ae261c4

Please sign in to comment.