Skip to content

Instantly share code, notes, and snippets.

@zeroem

zeroem/gist:6822534

Last active Apr 27, 2017
Embed
What would you like to do?
#!/bin/bash
COMMITS=$(git log --oneline | cut -d " " -f 1)
for COMMIT in $COMMITS
do
git checkout $COMMIT
./path/to/script.sh
if [ $? -eq 0 ]
then
echo $COMMIT passed
else
echo $COMMIT failed
fi
done
git checkout master
@ploeh

This comment has been minimized.

Copy link

@ploeh ploeh commented Oct 4, 2013

Thanks! This is really great.

Please excuse my ignorance about bash scripting, but assuming that my test run is another .sh file, how do I run that and check the pass condition?

@zeroem

This comment has been minimized.

Copy link
Owner Author

@zeroem zeroem commented Oct 4, 2013

./path/to/script can be an absolute path or relative to the current working directory (pwd). $? holds the exit code of the last executed command. So assuming your script exits with a non-zero exit code on failure, the rest will just work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment