Diff
1diff --git a/git/repo.go b/git/repo.go
2index 8c0b87c43dc642c6b107f7ddbb37014861b187a8..479a4581a6a0ddf3c2094224f98a37f595da1734 100644
3--- a/git/repo.go
4+++ b/git/repo.go
5@@ -230,10 +230,13 @@ func (r *Repository) SetConfig(key, value string, opts ...ConfigOptions) error {
6
7 // SymbolicRef returns or updates the symbolic reference for the given name.
8 // Both name and ref can be empty.
9-func (r *Repository) SymbolicRef(name string, ref string) (string, error) {
10- opt := git.SymbolicRefOptions{
11- Name: name,
12- Ref: ref,
13+func (r *Repository) SymbolicRef(name string, ref string, opts ...git.SymbolicRefOptions) (string, error) {
14+ var opt git.SymbolicRefOptions
15+ if len(opts) > 0 {
16+ opt = opts[0]
17 }
18+
19+ opt.Name = name
20+ opt.Ref = ref
21 return r.Repository.SymbolicRef(opt)
22 }
23diff --git a/server/git/git.go b/server/git/git.go
24index 0dba095eeb1347c8f689c07472e3ac4daf6efba4..e0f1e664ba43dde68c35d652088c89aa1c1dcb03 100644
25--- a/server/git/git.go
26+++ b/server/git/git.go
27@@ -11,6 +11,7 @@ import (
28 "github.com/charmbracelet/log"
29 "github.com/charmbracelet/soft-serve/git"
30 "github.com/go-git/go-git/v5/plumbing/format/pktline"
31+ gitm "github.com/gogs/git-module"
32 )
33
34 var (
35@@ -102,11 +103,10 @@ func EnsureDefaultBranch(ctx context.Context, scmd ServiceCommand) error {
36 }
37 }
38
39- cmd := git.NewCommand("branch", "-M", branch).WithContext(ctx)
40- if err := cmd.RunInDirWithOptions(scmd.Dir, git.RunInDirOptions{
41- Stdin: scmd.Stdin,
42- Stdout: scmd.Stdout,
43- Stderr: scmd.Stderr,
44+ if _, err := r.SymbolicRef(git.HEAD, git.RefsHeads+branch, gitm.SymbolicRefOptions{
45+ CommandOptions: gitm.CommandOptions{
46+ Context: ctx,
47+ },
48 }); err != nil {
49 return err
50 }
51diff --git a/server/ssh/cmd/branch.go b/server/ssh/cmd/branch.go
52index 8566a7d4d1945c7390267ad1eab56b4538339dde..7ed4603dbb022c07fa2b47b81f8bfd7ad69e08ae 100644
53--- a/server/ssh/cmd/branch.go
54+++ b/server/ssh/cmd/branch.go
55@@ -116,7 +116,11 @@ func branchDefaultCommand() *cobra.Command {
56 return git.ErrReferenceNotExist
57 }
58
59- if _, err := r.SymbolicRef("HEAD", gitm.RefsHeads+branch); err != nil {
60+ if _, err := r.SymbolicRef(git.HEAD, gitm.RefsHeads+branch, gitm.SymbolicRefOptions{
61+ CommandOptions: gitm.CommandOptions{
62+ Context: ctx,
63+ },
64+ }); err != nil {
65 return err
66 }
67 }