-
Notifications
You must be signed in to change notification settings - Fork 902
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(assert_clean_master): Output error messages to stderr, not stdout (…
- Loading branch information
1 parent
0eaad8c
commit e4a4216
Showing
1 changed file
with
28 additions
and
25 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,11 +6,14 @@ cd "$(dirname "$0")" || exit; | |
# (a local branch that tracks decks 'master' branch) | ||
CURRENTBRANCH=$(git symbolic-ref --short HEAD) | ||
TRACKING=$(git rev-parse --abbrev-ref --symbolic-full-name "@{u}") | ||
function error() { | ||
echo "$*" >&2 | ||
} | ||
|
||
if [ $? -ne 0 ] ; then | ||
echo "You must be on 'master' (a branch tracking the upstream Deck 'master' branch)." | ||
echo | ||
echo "The current branch '$CURRENTBRANCH' is not tracking any remote." | ||
error "You must be on 'master' (a branch tracking the upstream Deck 'master' branch)." | ||
error | ||
error "The current branch '$CURRENTBRANCH' is not tracking any remote." | ||
exit 1 | ||
fi | ||
|
||
|
@@ -21,28 +24,28 @@ DECK_HTTPS="https://github.com/spinnaker/deck.git" | |
DECK_GIT="[email protected]:spinnaker/deck.git" | ||
|
||
if [ "x${REMOTE_URL}" != "x${DECK_HTTPS}" ] && [ "x${REMOTE_URL}" != "x${DECK_GIT}" ] ; then | ||
echo "You must be on 'master' (a branch tracking the upstream Deck 'master' branch)." | ||
echo | ||
echo "The current branch '${CURRENTBRANCH}' is tracking '${TRACKING}'." | ||
echo "However, the remote '${REMOTE}' has a URL of '${REMOTE_URL}'." | ||
echo "The tracked remote should be either '${DECK_HTTPS}' or '${DECK_GIT}'." | ||
error "You must be on 'master' (a branch tracking the upstream Deck 'master' branch)." | ||
error | ||
error "The current branch '${CURRENTBRANCH}' is tracking '${TRACKING}'." | ||
error "However, the remote '${REMOTE}' has a URL of '${REMOTE_URL}'." | ||
error "The tracked remote should be either '${DECK_HTTPS}' or '${DECK_GIT}'." | ||
exit 2 | ||
fi | ||
|
||
if [ "x${BRANCH}" != "xmaster" ] ; then | ||
echo "You must be on 'master' (a branch tracking the upstream Deck 'master' branch)." | ||
echo | ||
echo "The current branch '${CURRENTBRANCH}' is tracking '${TRACKING}'." | ||
error "You must be on 'master' (a branch tracking the upstream Deck 'master' branch)." | ||
error | ||
error "The current branch '${CURRENTBRANCH}' is tracking '${TRACKING}'." | ||
exit 3 | ||
fi | ||
|
||
# Assert that the local branch is "clean" so we don't publish any uncommitted code | ||
DIRTY_COMMITS=$(git status --porcelain); | ||
if [ "x${DIRTY_COMMITS}" != "x" ] ; then | ||
echo "Your working copy is not clean (you have uncommited changes)." | ||
echo | ||
echo "Please stash these changes before publishing using 'git stash'."; | ||
echo | ||
error "Your working copy is not clean (you have uncommited changes)." | ||
error | ||
error "Please stash these changes before publishing using 'git stash'."; | ||
error | ||
git status --porcelain | ||
exit 4; | ||
fi | ||
|
@@ -52,21 +55,21 @@ git fetch "$REMOTE" | |
|
||
STATUS=$(git status -sb --porcelain) | ||
if [[ ${STATUS} =~ [Bb]ehind ]] ; then | ||
echo "Your local branch is behind the upstream branch '${TRACKING}'." | ||
echo | ||
echo "The upstream branch has additional commits that would not be included in the published package." | ||
echo "Run 'git pull' to update your local branch." | ||
echo | ||
error "Your local branch is behind the upstream branch '${TRACKING}'." | ||
error | ||
error "The upstream branch has additional commits that would not be included in the published package." | ||
error "Run 'git pull' to update your local branch." | ||
error | ||
git status -sb | ||
exit 5 | ||
fi | ||
|
||
if [[ ${STATUS} =~ [Aa]head ]] ; then | ||
echo "Your local branch is ahead of the upstream branch '${TRACKING}'." | ||
echo | ||
echo "Your local branch has additional commits that are not reflected in the upstream branch." | ||
echo "Add your commits to the upstream branch by creating a pull request." | ||
echo | ||
error "Your local branch is ahead of the upstream branch '${TRACKING}'." | ||
error | ||
error "Your local branch has additional commits that are not reflected in the upstream branch." | ||
error "Add your commits to the upstream branch by creating a pull request." | ||
error | ||
git status -sb | ||
exit 6 | ||
fi |