1
0
Fork 0
forked from forgejo/forgejo

improve code quality (#21464) (#21463)

Backport #21464 and #21465

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
6543 2022-10-15 14:24:39 +02:00 committed by GitHub
parent 6afbef5a8b
commit cd48a007bb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 64 additions and 27 deletions

View file

@ -59,15 +59,15 @@ func (repo *Repository) GetCodeActivityStats(fromTime time.Time, branch string)
_ = stdoutWriter.Close()
}()
args := []string{"log", "--numstat", "--no-merges", "--pretty=format:---%n%h%n%aN%n%aE%n", "--date=iso", fmt.Sprintf("--since='%s'", since)}
gitCmd := NewCommand(repo.Ctx, "log", "--numstat", "--no-merges", "--pretty=format:---%n%h%n%aN%n%aE%n", "--date=iso", fmt.Sprintf("--since='%s'", since))
if len(branch) == 0 {
args = append(args, "--branches=*")
gitCmd.AddArguments("--branches=*")
} else {
args = append(args, "--first-parent", branch)
gitCmd.AddArguments("--first-parent").AddDynamicArguments(branch)
}
stderr := new(strings.Builder)
err = NewCommand(repo.Ctx, args...).Run(&RunOpts{
err = gitCmd.Run(&RunOpts{
Env: []string{},
Dir: repo.Path,
Stdout: stdoutWriter,