Added Travis CI status caching task, for status in shell prompts
This commit is contained in:
@@ -259,7 +259,7 @@ function _git_index_batch_cmd() {
|
||||
echo -e "== Running command for $_bld_col$(_git_index_count)$_txt_col repos...\n"
|
||||
unset IFS
|
||||
for base_path in $(sed -e "s/--.*//" "$GIT_REPO_DIR/.git_index" | grep . | sort); do
|
||||
cd "$base_path"
|
||||
if [ -z "$NOCD" ]; then cd "$base_path"; fi
|
||||
$@
|
||||
done
|
||||
else
|
||||
|
||||
@@ -114,4 +114,30 @@ git_swap_remotes() {
|
||||
# (use git fetch tab completion)
|
||||
if [ "$shell" = "bash" ]; then
|
||||
complete -o default -o nospace -F _git_fetch git_swap_remotes
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# Updates cached Travis CI status if repo contains .travis.yml
|
||||
#
|
||||
# Creates and excludes TRAVIS_CI_STATUS
|
||||
# Use with SCM breeze repo index.
|
||||
# Add the following line to your crontab: (updates every 2 minutes)
|
||||
# */2 * * * * /bin/bash -c '. /home/YOUR_USERNAME/.bashrc && git_index --rebuild && NOCD=true git_index --batch-cmd git_update_travis_status'
|
||||
#
|
||||
git_update_travis_status() {
|
||||
if [ -e "$base_path/.travis.yml" ]; then
|
||||
if type ruby > /dev/null 2>&1 && type travis > /dev/null 2>&1; then
|
||||
# Only use slug from origin
|
||||
local repo=$(ruby -e "puts %x[cd $base_path && git remote -v].scan(/origin.*(?:\:|\/)([^\:\/]+\/[^\:\/]+)\.git/m).flatten.uniq")
|
||||
local travis_output=$(travis repositories --slugs="$repo")
|
||||
local status=""
|
||||
case "$travis_output" in
|
||||
*Passing*) status="Passing";;
|
||||
*Failing*) status="Failing";;
|
||||
*Running*) status="Running";;
|
||||
esac
|
||||
echo "$status" > "$base_path/TRAVIS_CI_STATUS"
|
||||
git_ignore "TRAVIS_CI_STATUS" "$base_path/.git/info/exclude"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user