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_index.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_index.go')
-rw-r--r-- | modules/git/repo_index.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/modules/git/repo_index.go b/modules/git/repo_index.go index 38c01295b6..f5533b25e7 100644 --- a/modules/git/repo_index.go +++ b/modules/git/repo_index.go @@ -18,7 +18,7 @@ import ( // ReadTreeToIndex reads a treeish to the index func (repo *Repository) ReadTreeToIndex(treeish string, indexFilename ...string) error { if len(treeish) != 40 { - res, err := NewCommand("rev-parse", "--verify", treeish).RunInDir(repo.Path) + res, err := NewCommandContext(repo.Ctx, "rev-parse", "--verify", treeish).RunInDir(repo.Path) if err != nil { return err } @@ -38,7 +38,7 @@ func (repo *Repository) readTreeToIndex(id SHA1, indexFilename ...string) error if len(indexFilename) > 0 { env = append(os.Environ(), "GIT_INDEX_FILE="+indexFilename[0]) } - _, err := NewCommand("read-tree", id.String()).RunInDirWithEnv(repo.Path, env) + _, err := NewCommandContext(repo.Ctx, "read-tree", id.String()).RunInDirWithEnv(repo.Path, env) if err != nil { return err } @@ -69,13 +69,13 @@ func (repo *Repository) ReadTreeToTemporaryIndex(treeish string) (filename, tmpD // EmptyIndex empties the index func (repo *Repository) EmptyIndex() error { - _, err := NewCommand("read-tree", "--empty").RunInDir(repo.Path) + _, err := NewCommandContext(repo.Ctx, "read-tree", "--empty").RunInDir(repo.Path) return err } // LsFiles checks if the given filenames are in the index func (repo *Repository) LsFiles(filenames ...string) ([]string, error) { - cmd := NewCommand("ls-files", "-z", "--") + cmd := NewCommandContext(repo.Ctx, "ls-files", "-z", "--") for _, arg := range filenames { if arg != "" { cmd.AddArguments(arg) @@ -95,7 +95,7 @@ func (repo *Repository) LsFiles(filenames ...string) ([]string, error) { // RemoveFilesFromIndex removes given filenames from the index - it does not check whether they are present. func (repo *Repository) RemoveFilesFromIndex(filenames ...string) error { - cmd := NewCommand("update-index", "--remove", "-z", "--index-info") + cmd := NewCommandContext(repo.Ctx, "update-index", "--remove", "-z", "--index-info") stdout := new(bytes.Buffer) stderr := new(bytes.Buffer) buffer := new(bytes.Buffer) @@ -111,14 +111,14 @@ func (repo *Repository) RemoveFilesFromIndex(filenames ...string) error { // AddObjectToIndex adds the provided object hash to the index at the provided filename func (repo *Repository) AddObjectToIndex(mode string, object SHA1, filename string) error { - cmd := NewCommand("update-index", "--add", "--replace", "--cacheinfo", mode, object.String(), filename) + cmd := NewCommandContext(repo.Ctx, "update-index", "--add", "--replace", "--cacheinfo", mode, object.String(), filename) _, err := cmd.RunInDir(repo.Path) return err } // WriteTree writes the current index as a tree to the object db and returns its hash func (repo *Repository) WriteTree() (*Tree, error) { - res, err := NewCommand("write-tree").RunInDir(repo.Path) + res, err := NewCommandContext(repo.Ctx, "write-tree").RunInDir(repo.Path) if err != nil { return nil, err } |