Skip to content

Commit

Permalink
Merge branch 'non-tracking-local'
Browse files Browse the repository at this point in the history
Closes #65

* non-tracking-local:
  Rearrange fresh_update to have guards and error messages together
  Local files should not be updated if on an untracked branch
  • Loading branch information
jasoncodes committed May 4, 2013
2 parents 96c979f + 7f044ab commit f4747ae
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
16 changes: 12 additions & 4 deletions bin/fresh
Original file line number Diff line number Diff line change
Expand Up @@ -543,13 +543,21 @@ usage: fresh update <filter>
(
set -e
[[ -e "$FRESH_LOCAL/.git" ]] || exit 0
if [[ -z "$(cd $FRESH_LOCAL && git status --porcelain)" ]]; then
_update_repo "$FRESH_LOCAL" "local files"
else
_note "Not updating $FRESH_LOCAL because it has uncommitted changes."

if ! (cd $FRESH_LOCAL && git rev-parse @{u} &> /dev/null); then
_note "Not updating $FRESH_LOCAL because the current branch is non-tracking."
if [[ "$1" == "--local" ]]; then
exit 1
fi
else
if [[ -n "$(cd $FRESH_LOCAL && git status --porcelain)" ]]; then
_note "Not updating $FRESH_LOCAL because it has uncommitted changes."
if [[ "$1" == "--local" ]]; then
exit 1
fi
else
_update_repo "$FRESH_LOCAL" "local files"
fi
fi
)
[[ $? == 0 ]] || exit 1
Expand Down
6 changes: 6 additions & 0 deletions test/fresh_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,8 @@ it_updates_local_repo_with_no_args() {

assertFileMatches $SANDBOX_PATH/git.log <<EOF
cd $FRESH_LOCAL
git rev-parse @{u}
cd $FRESH_LOCAL
git status --porcelain
cd $FRESH_LOCAL
git pull --rebase
Expand All @@ -973,6 +975,8 @@ it_only_updates_local_repo_with_local_arg() {

assertFileMatches $SANDBOX_PATH/git.log <<EOF
cd $FRESH_LOCAL
git rev-parse @{u}
cd $FRESH_LOCAL
git status --porcelain
cd $FRESH_LOCAL
git pull --rebase
Expand Down Expand Up @@ -1001,6 +1005,8 @@ it_does_not_update_local_dirty_local() {

assertFileMatches $SANDBOX_PATH/git.log <<EOF
cd $FRESH_LOCAL
git rev-parse @{u}
cd $FRESH_LOCAL
git status --porcelain
EOF
assertFileMatches $SANDBOX_PATH/out.log <<EOF
Expand Down

0 comments on commit f4747ae

Please sign in to comment.