Skip to content

Commit 84760e2

Browse files
committed
Remove cmd from the process manager as it is no longer used
1 parent 972ded0 commit 84760e2

File tree

6 files changed

+12
-15
lines changed

6 files changed

+12
-15
lines changed

modules/git/blame.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func createBlameReader(dir string, command ...string) (*BlameReader, error) {
117117
return nil, fmt.Errorf("Start: %v", err)
118118
}
119119

120-
pid := process.GetManager().Add(fmt.Sprintf("GetBlame [repo_path: %s]", dir), cmd, cancel)
120+
pid := process.GetManager().Add(fmt.Sprintf("GetBlame [repo_path: %s]", dir), cancel)
121121

122122
scanner := bufio.NewScanner(stdout)
123123

modules/git/command.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func (c *Command) RunInDirTimeoutEnvFullPipelineFunc(env []string, timeout time.
131131
if desc == "" {
132132
desc = fmt.Sprintf("%s %s %s [repo_path: %s]", GitExecutable, c.name, strings.Join(c.args, " "), dir)
133133
}
134-
pid := process.GetManager().Add(desc, cmd, cancel)
134+
pid := process.GetManager().Add(desc, cancel)
135135
defer process.GetManager().Remove(pid)
136136

137137
if fn != nil {

modules/process/manager.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ type Process struct {
3535
PID int64 // Process ID, not system one.
3636
Description string
3737
Start time.Time
38-
Cmd *exec.Cmd
3938
Cancel context.CancelFunc
4039
}
4140

@@ -58,14 +57,13 @@ func GetManager() *Manager {
5857
}
5958

6059
// Add a process to the ProcessManager and returns its PID.
61-
func (pm *Manager) Add(description string, cmd *exec.Cmd, cancel context.CancelFunc) int64 {
60+
func (pm *Manager) Add(description string, cancel context.CancelFunc) int64 {
6261
pm.mutex.Lock()
6362
pid := pm.counter + 1
6463
pm.processes[pid] = &Process{
6564
PID: pid,
6665
Description: description,
6766
Start: time.Now(),
68-
Cmd: cmd,
6967
Cancel: cancel,
7068
}
7169
pm.counter = pid
@@ -154,7 +152,7 @@ func (pm *Manager) ExecDirEnvStdIn(timeout time.Duration, dir, desc string, env
154152
return "", "", err
155153
}
156154

157-
pid := pm.Add(desc, cmd, cancel)
155+
pid := pm.Add(desc, cancel)
158156
err := cmd.Wait()
159157
pm.Remove(pid)
160158

modules/process/manager_test.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package process
22

33
import (
44
"context"
5-
"os/exec"
65
"testing"
76
"time"
87

@@ -12,18 +11,18 @@ import (
1211
func TestManager_Add(t *testing.T) {
1312
pm := Manager{processes: make(map[int64]*Process)}
1413

15-
pid := pm.Add("foo", exec.Command("foo"), nil)
14+
pid := pm.Add("foo", nil)
1615
assert.Equal(t, int64(1), pid, "expected to get pid 1 got %d", pid)
1716

18-
pid = pm.Add("bar", exec.Command("bar"), nil)
17+
pid = pm.Add("bar", nil)
1918
assert.Equal(t, int64(2), pid, "expected to get pid 2 got %d", pid)
2019
}
2120

2221
func TestManager_Cancel(t *testing.T) {
2322
pm := Manager{processes: make(map[int64]*Process)}
2423

2524
ctx, cancel := context.WithCancel(context.Background())
26-
pid := pm.Add("foo", exec.Command("foo"), cancel)
25+
pid := pm.Add("foo", cancel)
2726

2827
pm.Cancel(pid)
2928

@@ -37,10 +36,10 @@ func TestManager_Cancel(t *testing.T) {
3736
func TestManager_Remove(t *testing.T) {
3837
pm := Manager{processes: make(map[int64]*Process)}
3938

40-
pid1 := pm.Add("foo", exec.Command("foo"), nil)
39+
pid1 := pm.Add("foo", nil)
4140
assert.Equal(t, int64(1), pid1, "expected to get pid 1 got %d", pid1)
4241

43-
pid2 := pm.Add("bar", exec.Command("bar"), nil)
42+
pid2 := pm.Add("bar", nil)
4443
assert.Equal(t, int64(2), pid2, "expected to get pid 2 got %d", pid2)
4544

4645
pm.Remove(pid2)

routers/repo/http.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ func serviceRPC(h serviceHandler, service string) {
478478
cmd.Stdin = reqBody
479479
cmd.Stderr = &stderr
480480

481-
pid := process.GetManager().Add(fmt.Sprintf("%s %s %s [repo_path: %s]", git.GitExecutable, service, "--stateless-rpc", h.dir), cmd, cancel)
481+
pid := process.GetManager().Add(fmt.Sprintf("%s %s %s [repo_path: %s]", git.GitExecutable, service, "--stateless-rpc", h.dir), cancel)
482482
defer process.GetManager().Remove(pid)
483483

484484
if err := cmd.Run(); err != nil {

services/gitdiff/gitdiff.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,7 @@ func GetDiffRangeWithWhitespaceBehavior(repoPath, beforeCommitID, afterCommitID
859859
return nil, fmt.Errorf("Start: %v", err)
860860
}
861861

862-
pid := process.GetManager().Add(fmt.Sprintf("GetDiffRange [repo_path: %s]", repoPath), cmd, cancel)
862+
pid := process.GetManager().Add(fmt.Sprintf("GetDiffRange [repo_path: %s]", repoPath), cancel)
863863
defer process.GetManager().Remove(pid)
864864

865865
diff, err := ParsePatch(maxLines, maxLineCharacters, maxFiles, stdout)
@@ -947,7 +947,7 @@ func GetRawDiffForFile(repoPath, startCommit, endCommit string, diffType RawDiff
947947
cmd.Dir = repoPath
948948
cmd.Stdout = writer
949949
cmd.Stderr = stderr
950-
pid := process.GetManager().Add(fmt.Sprintf("GetRawDiffForFile: [repo_path: %s]", repoPath), cmd, cancel)
950+
pid := process.GetManager().Add(fmt.Sprintf("GetRawDiffForFile: [repo_path: %s]", repoPath), cancel)
951951
defer process.GetManager().Remove(pid)
952952

953953
if err = cmd.Run(); err != nil {

0 commit comments

Comments
 (0)