Use mislav's 'travis-ci' gist to show build status for current branch

This commit is contained in:
Nathan Broadbent
2012-01-31 17:26:03 +08:00
parent 7fd415bbf4
commit 4cf8671a1c

View File

@@ -121,23 +121,27 @@ fi
# #
# Creates and excludes .travis_status~ # Creates and excludes .travis_status~
# Use with SCM breeze repo index. # Use with SCM breeze repo index.
# Requires 'travis-ci' script from https://gist.github.com/1708408
# Add the following line to your crontab: (updates every 2 minutes) # Add the following line to your crontab: (updates every 2 minutes)
# */2 * * * * /bin/bash -c '. $HOME/.bashrc && git_index --rebuild && git_index --batch-cmd update_travis_ci_status' # */2 * * * * /bin/bash -c '. $HOME/.bashrc && git_index --rebuild && git_index --batch-cmd update_travis_ci_status'
# #
update_travis_ci_status() { update_travis_ci_status() {
if [ -e ".travis.yml" ]; then if [ -e ".travis.yml" ]; then
if type ruby > /dev/null 2>&1 && type travis > /dev/null 2>&1; then if type ruby > /dev/null 2>&1 && type travis-ci > /dev/null 2>&1; then
# Only use slug from origin # Use repo from origin remote
local repo=$(ruby -e "puts %x[git remote -v].scan(/origin.*(?:\:|\/)([^\:\/]+\/[^\:\/]+)\.git/m).flatten.uniq") local branches=$(git branch -a | sed "s/ *remotes\/origin\///;tm;d;:m;/^HEAD/d;")
local travis_output=$(travis repositories --slugs="$repo")
local stat_file=".travis_status~" local stat_file=".travis_status~"
echo -n > "$stat_file"
for branch in $branches; do
local travis_output=$(travis-ci "$branch" 2>&1)
case "$travis_output" in case "$travis_output" in
*Passing*) echo "Passing" > "$stat_file";; *built\ OK*) echo "$branch passed" >> "$stat_file";;
*Failing*) echo "Failing" > "$stat_file";; *failed*) echo "$branch failed" >> "$stat_file";;
*Running*) echo "Running" > "$stat_file";; *in\ progress*) echo "$branch running" >> "$stat_file";;
esac esac
done
git_ignore ".travis_status~" ".git/info/exclude" git_ignore "$stat_file" ".git/info/exclude"
fi fi
fi fi
} }