-
Notifications
You must be signed in to change notification settings - Fork 534
Add a Force flag to Fetch and Clone, mimicking the command-line client #497
Conversation
@mcuadros this is currently lacking tests but you get the basic idea. WDYT? |
Codecov Report
@@ Coverage Diff @@
## master #497 +/- ##
==========================================
- Coverage 78.08% 77.36% -0.72%
==========================================
Files 129 127 -2
Lines 9693 9403 -290
==========================================
- Hits 7569 7275 -294
- Misses 1298 1329 +31
+ Partials 826 799 -27
Continue to review full report at Codecov.
|
Looks good! |
I'm having a little trouble with the tests, actually. Consider: func (s *RemoteSuite) TestFetchNoForce(c *C) {
r := newRemote(memory.NewStorage(), &config.RemoteConfig{
URL: s.GetBasicLocalRepositoryURL(),
})
// Can be fast-forwarded
r.s.SetReference(plumbing.NewReferenceFromStrings(
"refs/heads/master", "918c48b83bd081e863dbe1b80f8998f058cd8294",
))
s.testFetch(c, r, &FetchOptions{
RefSpecs: []config.RefSpec{
config.RefSpec("+refs/heads/master:refs/remotes/origin/master"),
},
}, []*plumbing.Reference{
plumbing.NewReferenceFromStrings("refs/heads/master", "f7b877701fbf855b44c0a9e86f3fdce2c298b07f"),
plumbing.NewReferenceFromStrings("refs/remotes/origin/master", "f7b877701fbf855b44c0a9e86f3fdce2c298b07f"),
})
} I get the error:
I want to set up the local ref "master" such that the fetch has to update it. I can then set the ref to commits that are (or are not) ancestors and exercise the behaviour that way, but I've not managed to get it working just yet. I'll look into it again on Thursday, but in the meantime, any tips appreciated! |
You were lucky? Can you elaborate a little more, I don't understand the goal. |
@lupine any update? If not I will try to take a look to it, since we want to release the v4, and this should be included. |
Sorry @mcuadros, the tests and the safe locking behaviour both prevented me from finishing this, and in the end we went for a "wrap the SSH client" approach over at GitLab. There's also the question of respecting "+" in refspecs. If you can finish this off, I'd be super-grateful! |
Over the go-git SSH client?
|
That's right :/ we're doing https://gitlab.com/gitlab-org/gitlab-shell/blob/master/lib/gitlab_projects.rb#L432 instead. I'd love to get it cleaned up to be more like https://gitlab.com/gitlab-org/gitlab-shell/merge_requests/147 but couldn't quite manage it. |
See #490