summaryrefslogtreecommitdiffstats
path: root/modules/git/commit_info_nogogit.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/git/commit_info_nogogit.go')
-rw-r--r--modules/git/commit_info_nogogit.go47
1 files changed, 24 insertions, 23 deletions
diff --git a/modules/git/commit_info_nogogit.go b/modules/git/commit_info_nogogit.go
index f57355d16e..261252dab1 100644
--- a/modules/git/commit_info_nogogit.go
+++ b/modules/git/commit_info_nogogit.go
@@ -37,21 +37,18 @@ func (tes Entries) GetCommitsInfo(ctx context.Context, commit *Commit, treePath
}
if len(unHitPaths) > 0 {
sort.Strings(unHitPaths)
- commits, err := GetLastCommitForPaths(ctx, commit, treePath, unHitPaths)
+ commits, err := GetLastCommitForPaths(ctx, cache, commit, treePath, unHitPaths)
if err != nil {
return nil, nil, err
}
for pth, found := range commits {
- if err := cache.Put(commit.ID.String(), path.Join(treePath, pth), found.ID.String()); err != nil {
- return nil, nil, err
- }
revs[pth] = found
}
}
} else {
sort.Strings(entryPaths)
- revs, err = GetLastCommitForPaths(ctx, commit, treePath, entryPaths)
+ revs, err = GetLastCommitForPaths(ctx, nil, commit, treePath, entryPaths)
}
if err != nil {
return nil, nil, err
@@ -62,27 +59,31 @@ func (tes Entries) GetCommitsInfo(ctx context.Context, commit *Commit, treePath
commitsInfo[i] = CommitInfo{
Entry: entry,
}
+
+ // Check if we have found a commit for this entry in time
if entryCommit, ok := revs[entry.Name()]; ok {
commitsInfo[i].Commit = entryCommit
- if entry.IsSubModule() {
- subModuleURL := ""
- var fullPath string
- if len(treePath) > 0 {
- fullPath = treePath + "/" + entry.Name()
- } else {
- fullPath = entry.Name()
- }
- if subModule, err := commit.GetSubModule(fullPath); err != nil {
- return nil, nil, err
- } else if subModule != nil {
- subModuleURL = subModule.URL
- }
- subModuleFile := NewSubModuleFile(entryCommit, subModuleURL, entry.ID.String())
- commitsInfo[i].SubModuleFile = subModuleFile
- }
} else {
log.Debug("missing commit for %s", entry.Name())
}
+
+ // If the entry if a submodule add a submodule file for this
+ if entry.IsSubModule() {
+ subModuleURL := ""
+ var fullPath string
+ if len(treePath) > 0 {
+ fullPath = treePath + "/" + entry.Name()
+ } else {
+ fullPath = entry.Name()
+ }
+ if subModule, err := commit.GetSubModule(fullPath); err != nil {
+ return nil, nil, err
+ } else if subModule != nil {
+ subModuleURL = subModule.URL
+ }
+ subModuleFile := NewSubModuleFile(commitsInfo[i].Commit, subModuleURL, entry.ID.String())
+ commitsInfo[i].SubModuleFile = subModuleFile
+ }
}
// Retrieve the commit for the treePath itself (see above). We basically
@@ -121,9 +122,9 @@ func getLastCommitForPathsByCache(ctx context.Context, commitID, treePath string
}
// GetLastCommitForPaths returns last commit information
-func GetLastCommitForPaths(ctx context.Context, commit *Commit, treePath string, paths []string) (map[string]*Commit, error) {
+func GetLastCommitForPaths(ctx context.Context, cache *LastCommitCache, commit *Commit, treePath string, paths []string) (map[string]*Commit, error) {
// We read backwards from the commit to obtain all of the commits
- revs, err := WalkGitLog(ctx, commit.repo, commit, treePath, paths...)
+ revs, err := WalkGitLog(ctx, cache, commit.repo, commit, treePath, paths...)
if err != nil {
return nil, err
}