Last active
June 18, 2019 17:20
-
-
Save shannonwells/14ab069f8e94837f7f32a2eb745c2716 to your computer and use it in GitHub Desktop.
Go repo helpers
This file contains 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 | |
# This is specifically for the go-filecoin repo but a subset of this can apply to any go project with git | |
# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ | |
set -Euo pipefail | |
echo "Updating your repo." | |
echo "☕️ Take a break - this might take a few minutes." | |
git stash | |
git co master -q | |
git pull origin master --ff-only -q | |
git fetch --prune -q | |
cat proofs/rust-fil-proofs/parameters.json | jq -r 'keys[]' | sed 's/^/\/tmp\/filecoin\-proof\-parameters\//' | xargs stat | |
if [ $? ] ; then | |
FILECOIN_USE_PRECOMPILED_RUST_PROOFS=true go run ./build/*.go deps | |
fi | |
go run ./build/*.go install | |
echo "🍩 Done." | |
This file contains 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 | |
# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ | |
set -Euo | |
GO_NAMES='\.(go)$' | |
GO_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -E $GO_NAMES) | |
# a visually obvious failure b/c this can take some time. | |
function exit_err() { echo "❌ 💔" ; exit 1; } | |
if [[ ! -z $GO_FILES ]] | |
then | |
go run ./build/*.go lint || exit_err | |
echo $GO_FILES | xargs gofmt -s -w || exit_err | |
echo $GO_FILES | xargs git add | |
else | |
echo "nothing to do 😑" | |
exit 0 | |
fi | |
echo "✅ 😇" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment