Monorepo for Tangled tangled.org

knotserver/git: move git.Branch into branch.go #1042

merged opened by oppi.li targeting master from op/wvsztzxwqmyk

makes more sense imo.

Signed-off-by: oppiliappan me@oppi.li

Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:qfpnj4og54vl56wngdriaxug/sh.tangled.repo.pull/3mdujr3y4fr22
+14 -14
Diff #0
+13
knotserver/git/branch.go
··· 141 141 return branches, nil 142 142 } 143 143 144 + func (g *GitRepo) Branch(name string) (*plumbing.Reference, error) { 145 + ref, err := g.r.Reference(plumbing.NewBranchReferenceName(name), false) 146 + if err != nil { 147 + return nil, fmt.Errorf("branch: %w", err) 148 + } 149 + 150 + if !ref.Name().IsBranch() { 151 + return nil, fmt.Errorf("branch: %s is not a branch", ref.Name()) 152 + } 153 + 154 + return ref, nil 155 + } 156 + 144 157 func (g *GitRepo) DeleteBranch(branch string) error { 145 158 ref := plumbing.NewBranchReferenceName(branch) 146 159 return g.r.Storer.RemoveReference(ref)
+1 -14
knotserver/git/git.go
··· 122 122 func (g *GitRepo) TotalCommits() (int, error) { 123 123 output, err := g.revList( 124 124 g.h.String(), 125 - fmt.Sprintf("--count"), 125 + "--count", 126 126 ) 127 127 if err != nil { 128 128 return 0, fmt.Errorf("failed to run rev-list: %w", err) ··· 252 252 return nil, ErrNotSubmodule 253 253 } 254 254 255 - func (g *GitRepo) Branch(name string) (*plumbing.Reference, error) { 256 - ref, err := g.r.Reference(plumbing.NewBranchReferenceName(name), false) 257 - if err != nil { 258 - return nil, fmt.Errorf("branch: %w", err) 259 - } 260 - 261 - if !ref.Name().IsBranch() { 262 - return nil, fmt.Errorf("branch: %s is not a branch", ref.Name()) 263 - } 264 - 265 - return ref, nil 266 - } 267 - 268 255 func (g *GitRepo) SetDefaultBranch(branch string) error { 269 256 ref := plumbing.NewSymbolicReference(plumbing.HEAD, plumbing.NewBranchReferenceName(branch)) 270 257 return g.r.Storer.SetReference(ref)

History

1 round 0 comments
sign up or login to add to the discussion
oppi.li submitted #0
1 commit
expand
knotserver/git: move git.Branch into branch.go
2/3 failed, 1/3 success
expand
expand 0 comments
pull request successfully merged