Skip to content

Commit a014afd

Browse files
committed
clean up remote.go
1 parent 46428f5 commit a014afd

File tree

2 files changed

+16
-36
lines changed

2 files changed

+16
-36
lines changed

cmd/git-remote-gitopia/gitopia.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ func (h *GitopiaHandler) Fetch(remote *core.Remote, refsToFetch []core.RefToFetc
198198
return nil
199199
}
200200

201-
func (h *GitopiaHandler) Push(remote *core.Remote, refsToPush []core.RefToPush) (*[]string, error) {
201+
func (h *GitopiaHandler) Push(remote *core.Remote, refsToPush []core.RefToPush) ([]string, error) {
202202
var err error
203203

204204
if h.wallet == nil {
@@ -364,7 +364,7 @@ func (h *GitopiaHandler) Push(remote *core.Remote, refsToPush []core.RefToPush)
364364
return nil, err
365365
}
366366

367-
return &res, nil
367+
return res, nil
368368
}
369369

370370
func (h *GitopiaHandler) havePushPermission(walletAddress string) (havePermission bool, err error) {

core/remote.go

Lines changed: 14 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
type RemoteHandler interface {
1616
List(remote *Remote, forPush bool) ([]string, error)
1717
Fetch(remote *Remote, refsToFetch []RefToFetch) error
18-
Push(remote *Remote, refsToPush []RefToPush) (*[]string, error)
18+
Push(remote *Remote, refsToPush []RefToPush) ([]string, error)
1919

2020
Initialize(remote *Remote) error
2121
}
@@ -30,10 +30,8 @@ type Remote struct {
3030

3131
Handler RemoteHandler
3232

33-
todo []func() (string, error)
34-
pushList []func() (*[]string, error)
35-
fetchList []func() error
36-
Force bool
33+
todo []func() (string, error)
34+
Force bool
3735
}
3836

3937
type RefToPush struct {
@@ -89,23 +87,12 @@ func (r *Remote) Printf(format string, a ...interface{}) (n int, err error) {
8987
return fmt.Fprintf(r.writer, format, a...)
9088
}
9189

92-
func (r *Remote) push(refsToPush []RefToPush) {
93-
r.pushList = append(r.pushList, func() (*[]string, error) {
94-
locals, err := r.Handler.Push(r, refsToPush)
95-
if err != nil {
96-
return nil, err
97-
}
98-
99-
return locals, nil
100-
101-
//return fmt.Sprintf("ok %s\n", done), nil, nil
102-
})
90+
func (r *Remote) push(refsToPush []RefToPush) ([]string, error) {
91+
return r.Handler.Push(r, refsToPush)
10392
}
10493

105-
func (r *Remote) fetch(refsToFetch []RefToFetch) {
106-
r.fetchList = append(r.fetchList, func() error {
107-
return r.Handler.Fetch(r, refsToFetch)
108-
})
94+
func (r *Remote) fetch(refsToFetch []RefToFetch) error {
95+
return r.Handler.Fetch(r, refsToFetch)
10996
}
11097

11198
func (r *Remote) ProcessCommands() error {
@@ -161,16 +148,12 @@ loop:
161148
fallthrough
162149
case command == "\n":
163150
if strings.HasPrefix(prevCommand, "push ") {
164-
r.push(refsToPush)
165-
var locals *[]string
166-
for _, task := range r.pushList {
167-
locals, err = task()
168-
if err != nil {
169-
return err
170-
}
151+
locals, err := r.push(refsToPush)
152+
if err != nil {
153+
return err
171154
}
172155
if locals != nil {
173-
for _, local := range *locals {
156+
for _, local := range locals {
174157
r.Printf("ok %s\n", local)
175158
}
176159
r.Printf("\n")
@@ -181,12 +164,9 @@ loop:
181164
}
182165

183166
if strings.HasPrefix(prevCommand, "fetch ") {
184-
r.fetch(refsToFetch)
185-
for _, task := range r.fetchList {
186-
err = task()
187-
if err != nil {
188-
return err
189-
}
167+
err = r.fetch(refsToFetch)
168+
if err != nil {
169+
return err
190170
}
191171

192172
r.Printf("\n")

0 commit comments

Comments
 (0)