Skip to content

Commit

Permalink
ensuring correct git branch before "pulling"
Browse files Browse the repository at this point in the history
Rather than performing a git pull, (which merges the desired branch into the current one, even if they aren't the same), this ensures the repo is on the correct branch before merging.
Fixes bevry#7
  • Loading branch information
nfriedly committed May 20, 2015
1 parent 320a4c4 commit d6f5de9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/lib/safeps.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,14 @@ safeps =
safefs.ensurePath opts.cwd, (err,exists) ->
return complete(err) if err
if exists
safeps.spawn ['git', 'pull', opts.remote, opts.branch], opts, (err,result...) ->
# this ensures the repo is on the correct branch before performing a merge or fast-forward
commands = []
commands.push ['git', 'fetch', opts.remote]
commands.push ['git', 'checkout', opts.branch]
commands.push ['git', 'merge', "#{opts.remote}/#{opts.branch}"]

# Perform commands
safeps.spawnMultiple commands, opts, (err,result...) ->
return next(err, 'pull', result)
else
safeps.initGitRepo opts, (err,result) ->
Expand Down

0 comments on commit d6f5de9

Please sign in to comment.