Skip to content

improve code quality #21462

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

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from 9 commits
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
10 changes: 5 additions & 5 deletions modules/git/commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,15 +253,15 @@ func NewSearchCommitsOptions(searchString string, forAllRefs bool) SearchCommits
for _, k := range fields {
switch {
case strings.HasPrefix(k, "author:"):
authors = append(authors, strings.TrimPrefix(k, "author:"))
authors = append(authors, strings.ReplaceAll(strings.TrimSpace(strings.TrimPrefix(k, "author:")), "'", ""))
case strings.HasPrefix(k, "committer:"):
committers = append(committers, strings.TrimPrefix(k, "committer:"))
committers = append(committers, strings.ReplaceAll(strings.TrimSpace(strings.TrimPrefix(k, "committer:")), "'", ""))
case strings.HasPrefix(k, "after:"):
after = strings.TrimPrefix(k, "after:")
after = strings.ReplaceAll(strings.TrimSpace(strings.TrimPrefix(k, "after:")), "'", "")
case strings.HasPrefix(k, "before:"):
before = strings.TrimPrefix(k, "before:")
before = strings.ReplaceAll(strings.TrimSpace(strings.TrimPrefix(k, "before:")), "'", "")
default:
keywords = append(keywords, k)
keywords = append(keywords, strings.ReplaceAll(strings.TrimSpace(k), "'", ""))
}
}

Expand Down
8 changes: 5 additions & 3 deletions modules/git/repo_commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func (repo *Repository) searchCommits(id SHA1, opts SearchCommitsOptions) ([]*Co
// add previous arguments except for --grep and --all
hashCmd.AddArguments(args...)
// add keyword as <commit>
hashCmd.AddArguments(v)
hashCmd.AddArguments("--end-of-options", v)

// search with given constraints for commit matching sha hash of v
hashMatching, _, err := hashCmd.RunStdBytes(&RunOpts{Dir: repo.Path})
Expand Down Expand Up @@ -211,9 +211,11 @@ func (repo *Repository) CommitsByFileAndRange(revision, file string, page int) (
}()
go func() {
stderr := strings.Builder{}
err := NewCommand(repo.Ctx, "rev-list", revision,
err := NewCommand(repo.Ctx, "rev-list",
"--max-count="+strconv.Itoa(setting.Git.CommitsRangeSize*page),
"--skip="+strconv.Itoa(skip), "--", file).
"--skip="+strconv.Itoa(skip),
"--end-of-options", revision,
"--", file).
Run(&RunOpts{
Dir: repo.Path,
Stdout: stdoutWriter,
Expand Down
2 changes: 1 addition & 1 deletion modules/git/repo_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (repo *Repository) GetCodeActivityStats(fromTime time.Time, branch string)
if len(branch) == 0 {
args = append(args, "--branches=*")
} else {
args = append(args, "--first-parent", branch)
args = append(args, "--first-parent", "--", branch)
}

stderr := new(strings.Builder)
Expand Down