Avoid unused line statistics when refreshing merge facts
This commit is contained in:
@@ -123,11 +123,10 @@ func (m *Manager) gitFacts(ctx context.Context, t api.Task, p api.Project) (stor
|
||||
if err != nil {
|
||||
return g, err
|
||||
}
|
||||
all, err := git.Compare(t.WorktreePath, p.DefaultBranch, "HEAD", tree, "")
|
||||
g.UnmergedFiles, err = git.ChangedFileCount(t.WorktreePath, p.DefaultBranch, tree)
|
||||
if err != nil {
|
||||
return g, err
|
||||
}
|
||||
g.UnmergedFiles = len(all.Files)
|
||||
latest, err := m.store.LastReviewable(ctx, t.Id)
|
||||
if errors.Is(err, store.ErrNotFound) {
|
||||
return g, nil
|
||||
|
||||
@@ -43,6 +43,18 @@ func Compare(dir, defaultBranch, head, tree, since string) (api.TaskChanges, err
|
||||
return api.TaskChanges{Base: base, Tree: tree, Files: files}, nil
|
||||
}
|
||||
|
||||
func ChangedFileCount(dir, defaultBranch, tree string) (int, error) {
|
||||
base, err := run(dir, "merge-base", "HEAD", defaultBranch)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
paths, err := run(dir, "diff", "--find-renames", "--name-only", "-z", base, tree)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return strings.Count(paths, "\x00"), nil
|
||||
}
|
||||
|
||||
func Snapshot(dir string) (string, error) {
|
||||
index, err := run(dir, "rev-parse", "--path-format=absolute", "--git-path", "index")
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user