robwierzbowski / grunt-build-control

Version control your built code.
MIT License
380 stars 36 forks source link

Improve fetching logic and error handling #5

Closed robwierzbowski closed 10 years ago

robwierzbowski commented 11 years ago

If you have an existing remote branch and a non-bare tree (as you always will) the fetch fails.

Fetching remote branch test-branch.
fatal: Refusing to fetch into current branch refs/heads/test-branch of non-bare repository
fatal: The remote end hung up unexpectedly

Need to fetch remote refs without a checkout somehow.

seejee commented 11 years ago

This wasn't a problem with the pulls. The remote branch existing and pulling from it worked even when there were local changes in the git dir.

robwierzbowski commented 11 years ago

I only tested once, so I might not have grokked the issue fully. I'll take a closer look.

Can we pull without checking out, i.e., pull a specific remote branch into a specific local branch that is not HEAD? If we use pulls we might have to deal with non-ff merges too.

Might go out tonight, might work on this some more. Definitely going to try and finish it up tomorrow.

On Saturday, October 5, 2013, Chris Geihsler wrote:

This wasn't a problem with the pulls. The remote branch existing and pulling from it worked even when there were local changes in the git dir.

— Reply to this email directly or view it on GitHubhttps://github.com/robwierzbowski/grunt-version-build/issues/5#issuecomment-25760364 .

Rob Wierzbowski @robwierzbowski http://twitter.com/#!/robwierzbowski http://github.com/robwierzbowski http://robwierzbowski.com

robwierzbowski commented 11 years ago

Ok, so the problem is you can't fetch to a current branch if the working directory isn't clean. So when we safeCheckout (or normal checkout) the branch and then try to fetch, or if the branch is already checked out due to an earlier operation, the command fails.

We could fix this by creating a hidden / random branch to checkout before fetching, but that seems really workaround-ey.

robwierzbowski commented 11 years ago

OK, that fixes it using some plumbing flags. Pivoting the issue to making the fetching and fetch error catching smarter as listed in the TODO.

We could run gitFetch before safeCheckout to reduce the times --update-head-ok is needed, unless it's current position makes checking local/remote branch statuses easier.

robwierzbowski commented 10 years ago

Generally done with the big revision.