Skip to content

Instantly share code, notes, and snippets.

@Kubuxu
Last active March 7, 2019 21:11
Show Gist options
  • Save Kubuxu/3fc5639db27f4b072b33a84b51048ff8 to your computer and use it in GitHub Desktop.
Save Kubuxu/3fc5639db27f4b072b33a84b51048ff8 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
BADGOMODREGEX='\+replace.*=>\s+[/.]'
exec < /dev/tty
if git ls-files go.mod >/dev/null && [[ $(git diff --cached go.mod | grep -E -c "$BADGOMODREGEX") -ne 0 ]]; then
git diff --cached go.mod | grep -E "$BADGOMODREGEX"
read -p "There are local replace directives in go.mod. Are you sure you want to continue (y/n): " yn
if echo "$yn" | grep "^[Yy]$" > /dev/null; then
exit 0; #THE USER WANTS TO CONTINUE
else
exit 1; # THE USER DONT WANT TO CONTINUE SO ROLLBACK
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment