aboutsummaryrefslogtreecommitdiffstats
path: root/modules/git
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2019-11-11 11:46:28 +0000
committerGitHub <noreply@github.com>2019-11-11 11:46:28 +0000
commit74bb292fe3f4c02fc1dc5f32622c74d820cadd78 (patch)
treef4b6692f37ba56f368264fbb9406edf68a54f945 /modules/git
parent8d9e625f83bf05086cfb72087548d203aff96db3 (diff)
downloadgitea-74bb292fe3f4c02fc1dc5f32622c74d820cadd78.tar.gz
gitea-74bb292fe3f4c02fc1dc5f32622c74d820cadd78.zip
Migrate temp_repo.go to use git.NewCommand (#8918)
This PR migrates temp_repo.go to use git.NewCommand instead creating processes by itself - this fixes the problem underlying PR #8905. There are other places that run git outside of the controlled locale defined in #8548 but temp_repo.go is the only cause of failure of local testing in cases where English is not the default - implying that error messages from those other commands are not interpreted. Replaces #8905
Diffstat (limited to 'modules/git')
-rw-r--r--modules/git/command.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/modules/git/command.go b/modules/git/command.go
index 2b5288aeab..7772abd2d5 100644
--- a/modules/git/command.go
+++ b/modules/git/command.go
@@ -67,6 +67,13 @@ func (c *Command) RunInDirTimeoutEnvPipeline(env []string, timeout time.Duration
// RunInDirTimeoutEnvFullPipeline executes the command in given directory with given timeout,
// it pipes stdout and stderr to given io.Writer and passes in an io.Reader as stdin.
func (c *Command) RunInDirTimeoutEnvFullPipeline(env []string, timeout time.Duration, dir string, stdout, stderr io.Writer, stdin io.Reader) error {
+ return c.RunInDirTimeoutEnvFullPipelineFunc(env, timeout, dir, stdout, stderr, stdin, nil)
+}
+
+// RunInDirTimeoutEnvFullPipelineFunc executes the command in given directory with given timeout,
+// it pipes stdout and stderr to given io.Writer and passes in an io.Reader as stdin. Between cmd.Start and cmd.Wait the passed in function is run.
+func (c *Command) RunInDirTimeoutEnvFullPipelineFunc(env []string, timeout time.Duration, dir string, stdout, stderr io.Writer, stdin io.Reader, fn func(context.Context, context.CancelFunc)) error {
+
if timeout == -1 {
timeout = DefaultCommandExecutionTimeout
}
@@ -98,6 +105,10 @@ func (c *Command) RunInDirTimeoutEnvFullPipeline(env []string, timeout time.Dura
pid := process.GetManager().Add(fmt.Sprintf("%s %s %s [repo_path: %s]", GitExecutable, c.name, strings.Join(c.args, " "), dir), cmd)
defer process.GetManager().Remove(pid)
+ if fn != nil {
+ fn(ctx, cancel)
+ }
+
if err := cmd.Wait(); err != nil {
return err
}