Signed-off-by: oppiliappan me@oppi.li
+3
-6
knotserver/git/git.go
+3
-6
knotserver/git/git.go
···
316
}
317
318
func (g *GitRepo) FindMainBranch() (string, error) {
319
-
ref, err := g.r.Head()
320
if err != nil {
321
-
return "", fmt.Errorf("unable to find main branch: %w", err)
322
-
}
323
-
if ref.Name().IsBranch() {
324
-
return strings.TrimPrefix(string(ref.Name()), "refs/heads/"), nil
325
}
326
327
-
return "", fmt.Errorf("unable to find main branch: %w", err)
328
}
329
330
// WriteTar writes itself from a tree into a binary tar file format.
···
316
}
317
318
func (g *GitRepo) FindMainBranch() (string, error) {
319
+
output, err := g.revParse("--abbrev-ref", "HEAD")
320
if err != nil {
321
+
return "", fmt.Errorf("failed to find main branch: %w", err)
322
}
323
324
+
return strings.TrimSpace(string(output)), nil
325
}
326
327
// WriteTar writes itself from a tree into a binary tar file format.