Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix index too many file names bug #31903

Merged
merged 7 commits into from
Sep 1, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions modules/indexer/code/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ func nonGenesisChanges(ctx context.Context, repo *repo_model.Repository, revisio
var changes internal.RepoChanges
var err error
updatedFilenames := make([]string, 0, 10)
for _, line := range strings.Split(stdout, "\n") {
lines := strings.Split(stdout, "\n")
for i, line := range lines {
line = strings.TrimSpace(line)
if len(line) == 0 {
continue
Expand Down Expand Up @@ -161,15 +162,23 @@ func nonGenesisChanges(ctx context.Context, repo *repo_model.Repository, revisio
default:
log.Warn("Unrecognized status: %c (line=%s)", status, line)
}
}

cmd := git.NewCommand(ctx, "ls-tree", "--full-tree", "-l").AddDynamicArguments(revision).
AddDashesAndList(updatedFilenames...)
lsTreeStdout, _, err := cmd.RunStdBytes(&git.RunOpts{Dir: repo.RepoPath()})
if err != nil {
return nil, err
if (i%50 == 0 || i == len(lines)-1) && len(updatedFilenames) > 0 {
lunny marked this conversation as resolved.
Show resolved Hide resolved
cmd := git.NewCommand(ctx, "ls-tree", "--full-tree", "-l").AddDynamicArguments(revision).
AddDashesAndList(updatedFilenames...)
lsTreeStdout, _, err := cmd.RunStdBytes(&git.RunOpts{Dir: repo.RepoPath()})
if err != nil {
return nil, err
}

updates, err1 := parseGitLsTreeOutput(lsTreeStdout)
wxiaoguang marked this conversation as resolved.
Show resolved Hide resolved
if err1 != nil {
return nil, err1
}
changes.Updates = append(changes.Updates, updates...)
updatedFilenames = updatedFilenames[0:0]
wxiaoguang marked this conversation as resolved.
Show resolved Hide resolved
}
}

changes.Updates, err = parseGitLsTreeOutput(lsTreeStdout)
return &changes, err
}