Removed update_travis_ci_status function (moved to ndbroadbent/dotfiles repo)
This commit is contained in:
@@ -127,73 +127,3 @@ git_branch_delete_all() {
|
|||||||
git branch -D -r origin/$1
|
git branch -D -r origin/$1
|
||||||
git push origin :$1
|
git push origin :$1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Updates cached Travis CI status if repo contains .travis.yml
|
|
||||||
#
|
|
||||||
# Creates and excludes .travis_status~
|
|
||||||
# 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)
|
|
||||||
# */2 * * * * /bin/bash -c '. $HOME/.bashrc && git_index --rebuild && git_index --batch-cmd update_travis_ci_status'
|
|
||||||
#
|
|
||||||
update_travis_ci_status() {
|
|
||||||
if [ -e ".travis.yml" ]; then
|
|
||||||
# Ensure hub gem is installed
|
|
||||||
if ! gem list hub | grep -q "^hub "; then
|
|
||||||
echo "Installing 'hub' for current gemset"
|
|
||||||
gem install hub
|
|
||||||
fi
|
|
||||||
|
|
||||||
if type ruby > /dev/null 2>&1 && type travis-ci > /dev/null 2>&1; then
|
|
||||||
local stat_file=".travis_status~"
|
|
||||||
local tmp_stat_file="$stat_file"".tmp"
|
|
||||||
|
|
||||||
# Ignore stat files from git repo
|
|
||||||
git_ignore "$stat_file" ".git/info/exclude"
|
|
||||||
git_ignore "$tmp_stat_file" ".git/info/exclude"
|
|
||||||
|
|
||||||
# Either update all branches, or only current branch
|
|
||||||
if [ "$UPDATE_ALL_BRANCHES" = "true" ]; then
|
|
||||||
local all_branches=$(\git branch -a)
|
|
||||||
# All branches on origin remote that have local copies
|
|
||||||
local branches=$(comm -12 <(echo "$all_branches" | \
|
|
||||||
sed "s/ *remotes\/origin\///;tm;d;:m;/^HEAD/d;" | sort) \
|
|
||||||
<(echo "$all_branches" | \
|
|
||||||
sed "/ *remotes\//d;s/^[\* ]*//" | sort))
|
|
||||||
# Create a new, blank temp file
|
|
||||||
echo -n > "$tmp_stat_file"
|
|
||||||
else
|
|
||||||
# Only current branch
|
|
||||||
local branches="$(\git branch 2> /dev/null | sed "s/^\* \([^ ]*\)/\1/;tm;d;:m")"
|
|
||||||
# Copy current file to temp file
|
|
||||||
touch "$stat_file"
|
|
||||||
cp -f "$stat_file" "$tmp_stat_file"
|
|
||||||
fi
|
|
||||||
|
|
||||||
for branch in $branches; do
|
|
||||||
local travis_output=$(travis-ci "$branch" 2>&1)
|
|
||||||
local status=""
|
|
||||||
case "$travis_output" in
|
|
||||||
*built\ OK*) status="passed";;
|
|
||||||
*failed*) status="failed";;
|
|
||||||
*in\ progress*) status="running";;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# If branch has a build status
|
|
||||||
if [ -n "$status" ]; then
|
|
||||||
if grep -q "^$branch" "$tmp_stat_file"; then
|
|
||||||
# Replace branch's build status
|
|
||||||
sed -e "s/^$branch .*/$branch $status/" -i "$tmp_stat_file"
|
|
||||||
else
|
|
||||||
# Append new line for branch
|
|
||||||
echo "$branch $status" >> "$tmp_stat_file"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# Replace current stat file with finished update
|
|
||||||
mv -f "$tmp_stat_file" "$stat_file"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user