1
0
mirror of https://github.com/go-gitea/git.git synced 2026-02-05 06:45:03 +01:00

improve log and clone repo command

This commit is contained in:
Unknwon
2015-12-08 20:05:32 -05:00
parent de77627290
commit 05d41d51a1
3 changed files with 44 additions and 10 deletions

View File

@@ -122,8 +122,18 @@ func (c *Command) RunInDir(dir string) (string, error) {
return string(stdout), nil
}
// RunTimeout executes the command in defualt working directory with given timeout,
// and returns stdout in string and error (combined with stderr).
func (c *Command) RunTimeout(timeout time.Duration) (string, error) {
stdout, err := c.RunInDirTimeout(timeout, "")
if err != nil {
return "", err
}
return string(stdout), nil
}
// Run executes the command in defualt working directory
// and returns stdout in string and error (combined with stderr).
func (c *Command) Run() (string, error) {
return c.RunInDir("")
return c.RunTimeout(-1)
}