Make commit info cancelable (#16032)
* Make modules/context.Context a context.Context Signed-off-by: Andrew Thornton <art27@cantab.net> * Simplify context calls Signed-off-by: Andrew Thornton <art27@cantab.net> * Set the base context for requests to the HammerContext Signed-off-by: Andrew Thornton <art27@cantab.net> * pass context into get-last-commit Signed-off-by: Andrew Thornton <art27@cantab.net> * Make commit_info cancellable Signed-off-by: Andrew Thornton <art27@cantab.net> * use context as context Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de>
This commit is contained in:
@ -8,6 +8,7 @@ package git
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"context"
|
||||
"path"
|
||||
)
|
||||
|
||||
@ -61,11 +62,11 @@ func (c *LastCommitCache) Get(ref, entryPath string, wr WriteCloserError, rd *bu
|
||||
}
|
||||
|
||||
// CacheCommit will cache the commit from the gitRepository
|
||||
func (c *LastCommitCache) CacheCommit(commit *Commit) error {
|
||||
return c.recursiveCache(commit, &commit.Tree, "", 1)
|
||||
func (c *LastCommitCache) CacheCommit(ctx context.Context, commit *Commit) error {
|
||||
return c.recursiveCache(ctx, commit, &commit.Tree, "", 1)
|
||||
}
|
||||
|
||||
func (c *LastCommitCache) recursiveCache(commit *Commit, tree *Tree, treePath string, level int) error {
|
||||
func (c *LastCommitCache) recursiveCache(ctx context.Context, commit *Commit, tree *Tree, treePath string, level int) error {
|
||||
if level == 0 {
|
||||
return nil
|
||||
}
|
||||
@ -82,7 +83,7 @@ func (c *LastCommitCache) recursiveCache(commit *Commit, tree *Tree, treePath st
|
||||
entryMap[entry.Name()] = entry
|
||||
}
|
||||
|
||||
commits, err := GetLastCommitForPaths(commit, treePath, entryPaths)
|
||||
commits, err := GetLastCommitForPaths(ctx, commit, treePath, entryPaths)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -97,7 +98,7 @@ func (c *LastCommitCache) recursiveCache(commit *Commit, tree *Tree, treePath st
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := c.recursiveCache(commit, subTree, entry, level-1); err != nil {
|
||||
if err := c.recursiveCache(ctx, commit, subTree, entry, level-1); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user