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 all 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
5 changes: 2 additions & 3 deletions modules/git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
)

// RequiredVersion is the minimum Git version required
const RequiredVersion = "2.0.0"
const RequiredVersion = "2.24.0"

var (
// GitExecutable is the command name of git
Expand Down Expand Up @@ -116,8 +116,7 @@ func VersionInfo() string {
}
format := "%s"
args := []interface{}{gitVersion.Original()}
// Since git wire protocol has been released from git v2.18
if setting.Git.EnableAutoGitWireProtocol && CheckGitVersionAtLeast("2.18") == nil {
if setting.Git.EnableAutoGitWireProtocol {
format += ", Wire Protocol %s Enabled"
args = append(args, "Version 2") // for focus color
}
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