diff options
author | zeripath <art27@cantab.net> | 2021-11-30 20:06:32 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-30 20:06:32 +0000 |
commit | 01087e9eef21ff5ea1cebbb1e84933954671fdf2 (patch) | |
tree | ae618785a3bd46e012096683e2fd2309f87c571d /modules/git/repo_branch_nogogit.go | |
parent | d894c90b703ce215e2319ae2e2bf95989f77805d (diff) | |
download | gitea-01087e9eef21ff5ea1cebbb1e84933954671fdf2.tar.gz gitea-01087e9eef21ff5ea1cebbb1e84933954671fdf2.zip |
Make Requests Processes and create process hierarchy. Associate OpenRepository with context. (#17125)
This PR registers requests with the process manager and manages hierarchy within the processes.
Git repos are then associated with a context, (usually the request's context) - with sub commands using this context as their base context.
Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'modules/git/repo_branch_nogogit.go')
-rw-r--r-- | modules/git/repo_branch_nogogit.go | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/modules/git/repo_branch_nogogit.go b/modules/git/repo_branch_nogogit.go index 666ca81c1e..1928c7515b 100644 --- a/modules/git/repo_branch_nogogit.go +++ b/modules/git/repo_branch_nogogit.go @@ -11,6 +11,7 @@ package git import ( "bufio" "bytes" + "context" "io" "strings" @@ -23,7 +24,7 @@ func (repo *Repository) IsObjectExist(name string) bool { return false } - wr, rd, cancel := repo.CatFileBatchCheck() + wr, rd, cancel := repo.CatFileBatchCheck(repo.Ctx) defer cancel() _, err := wr.Write([]byte(name + "\n")) if err != nil { @@ -40,7 +41,7 @@ func (repo *Repository) IsReferenceExist(name string) bool { return false } - wr, rd, cancel := repo.CatFileBatchCheck() + wr, rd, cancel := repo.CatFileBatchCheck(repo.Ctx) defer cancel() _, err := wr.Write([]byte(name + "\n")) if err != nil { @@ -63,11 +64,11 @@ func (repo *Repository) IsBranchExist(name string) bool { // GetBranches returns branches from the repository, skipping skip initial branches and // returning at most limit branches, or all branches if limit is 0. func (repo *Repository) GetBranches(skip, limit int) ([]string, int, error) { - return callShowRef(repo.Path, BranchPrefix, "--heads", skip, limit) + return callShowRef(repo.Ctx, repo.Path, BranchPrefix, "--heads", skip, limit) } // callShowRef return refs, if limit = 0 it will not limit -func callShowRef(repoPath, prefix, arg string, skip, limit int) (branchNames []string, countAll int, err error) { +func callShowRef(ctx context.Context, repoPath, prefix, arg string, skip, limit int) (branchNames []string, countAll int, err error) { stdoutReader, stdoutWriter := io.Pipe() defer func() { _ = stdoutReader.Close() @@ -76,7 +77,7 @@ func callShowRef(repoPath, prefix, arg string, skip, limit int) (branchNames []s go func() { stderrBuilder := &strings.Builder{} - err := NewCommand("show-ref", arg).RunInDirPipeline(repoPath, stdoutWriter, stderrBuilder) + err := NewCommandContext(ctx, "show-ref", arg).RunInDirPipeline(repoPath, stdoutWriter, stderrBuilder) if err != nil { if stderrBuilder.Len() == 0 { _ = stdoutWriter.Close() |