+3
-6
knotserver/git/git.go
+3
-6
knotserver/git/git.go
···
316
316
}
317
317
318
318
func (g *GitRepo) FindMainBranch() (string, error) {
319
-
ref, err := g.r.Head()
319
+
output, err := g.revParse("--abbrev-ref", "HEAD")
320
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
321
+
return "", fmt.Errorf("failed to find main branch: %w", err)
325
322
}
326
323
327
-
return "", fmt.Errorf("unable to find main branch: %w", err)
324
+
return strings.TrimSpace(string(output)), nil
328
325
}
329
326
330
327
// WriteTar writes itself from a tree into a binary tar file format.