Skip to content

Commit a244fe9

Browse files
committed
Able to set timeout for git pull
1 parent a1c5096 commit a244fe9

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

git.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"time"
1111
)
1212

13-
const _VERSION = "0.2.7"
13+
const _VERSION = "0.2.8"
1414

1515
func Version() string {
1616
return _VERSION

repo.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,23 @@ func Clone(from, to string, opts CloneRepoOptions) (err error) {
105105
return err
106106
}
107107

108+
type PullRemoteOptions struct {
109+
All bool
110+
Timeout time.Duration
111+
}
112+
108113
// Pull pulls changes from remotes.
109-
func Pull(repoPath string, all bool) error {
114+
func Pull(repoPath string, opts PullRemoteOptions) error {
110115
cmd := NewCommand("pull")
111-
if all {
116+
if opts.All {
112117
cmd.AddArguments("--all")
113118
}
114-
_, err := cmd.RunInDir(repoPath)
119+
120+
if opts.Timeout <= 0 {
121+
opts.Timeout = -1
122+
}
123+
124+
_, err := cmd.RunInDirTimeout(opts.Timeout, repoPath)
115125
return err
116126
}
117127

0 commit comments

Comments
 (0)