UpdateRemoteMirror fails if repository doesn't have a `master` branch
I came across this error when developing a new remote mirror feature. It so happened that I had deleted the master
branch on my test repo at some point, and I started getting errors like these:
code = Unknown desc = NoMethodError: undefined method `id' for nil:NilClass
It can be reproduced with this patch on the test:
diff --git a/internal/service/remote/update_remote_mirror_test.go b/internal/service/remote/update_remote_mirror_test.go
index cd08bb08..a5a3a5bf 100644
--- a/internal/service/remote/update_remote_mirror_test.go
+++ b/internal/service/remote/update_remote_mirror_test.go
@@ -44,4 +44,5 @@ func TestSuccessfulUpdateRemoteMirrorRequest(t *testing.T) {
testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "tag", "-fam", "Overriding tag", "v1.0.0", "0b4bc9a49b562e85de7cc9e834518ea6828729b9") // Update tag
testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "tag", "-d", "v0.0.1") // Delete tag
+ testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "branch", "-d", "master")
newTagOid := string(testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "rev-parse", "v1.0.0"))
A repository without a master branch is still a valid repository, so I'd say this is a ~bug. From a cursory view, the culprit seems to be here.
/cc @gl-gitaly