Last active
February 6, 2016 23:14
-
-
Save clux/247d74d956d384a49209 to your computer and use it in GitHub Desktop.
mass edit .travis.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
dir="$1" | |
cd "$dir" | |
file=".travis.yml" | |
# ensure we have an empty staging area before we start committing | |
cache=$(git diff --cached) | |
if [[ -n "${cache// }" ]]; then | |
echo "non-empty cache" | |
elif [[ -f "$file" ]]; then | |
emailnotifies="{email: {on_success: 'change',on_failure: 'always'}}" | |
json=$(js-yaml "$file" | json -e this.notifications="$emailnotifies") | |
echo "$json" | js-yaml | head -n-1 > "$file" | |
git commit "$file" -m "automated change of .travis.yml to enable email notifications - https://gist.github.com/clux/247d74d956d384a49209" | |
git push | |
else | |
echo "no $file in current directory" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Requires the two npm packages
js-yaml
andjson
installed globally. Thehead -n-1
quirk is to get rid of an extra newline output byjs-yaml
.Usage: in a directory of repositories run:
This current example updates the
notifications:
part of the.travis.yml
file to enable partial email notifications, and this information is duplicated in many-many repositories.Example commit