diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2022-10-15 18:49:26 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-15 12:49:26 +0200 |
commit | d98c5db58fdeded983bf5c0fe781fd7b77a1235f (patch) | |
tree | 2816c975613f2f44b80bdd9cba01ebb1ee6bc9e4 /modules/gitgraph | |
parent | 7917123209d7974662baccf21346f1989247550a (diff) | |
download | gitea-d98c5db58fdeded983bf5c0fe781fd7b77a1235f.tar.gz gitea-d98c5db58fdeded983bf5c0fe781fd7b77a1235f.zip |
alternative to PR "improve code quality" (#21464)
This PR doesn't require new git version, and can be backported easily.
Co-authored-by: 6543 <6543@obermui.de>
Diffstat (limited to 'modules/gitgraph')
-rw-r--r-- | modules/gitgraph/graph.go | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/modules/gitgraph/graph.go b/modules/gitgraph/graph.go index 271382525a..0f3c021344 100644 --- a/modules/gitgraph/graph.go +++ b/modules/gitgraph/graph.go @@ -24,19 +24,17 @@ func GetCommitGraph(r *git.Repository, page, maxAllowedColors int, hidePRRefs bo page = 1 } - args := make([]string, 0, 12+len(branches)+len(files)) - - args = append(args, "--graph", "--date-order", "--decorate=full") + graphCmd := git.NewCommand(r.Ctx, "log", "--graph", "--date-order", "--decorate=full") if hidePRRefs { - args = append(args, "--exclude="+git.PullPrefix+"*") + graphCmd.AddArguments("--exclude=" + git.PullPrefix + "*") } if len(branches) == 0 { - args = append(args, "--all") + graphCmd.AddArguments("--all") } - args = append(args, + graphCmd.AddArguments( "-C", "-M", fmt.Sprintf("-n %d", setting.UI.GraphMaxCommitNum*page), @@ -44,15 +42,12 @@ func GetCommitGraph(r *git.Repository, page, maxAllowedColors int, hidePRRefs bo fmt.Sprintf("--pretty=format:%s", format)) if len(branches) > 0 { - args = append(args, branches...) + graphCmd.AddDynamicArguments(branches...) } - args = append(args, "--") if len(files) > 0 { - args = append(args, files...) + graphCmd.AddArguments("--") + graphCmd.AddArguments(files...) } - - graphCmd := git.NewCommand(r.Ctx, "log") - graphCmd.AddArguments(args...) graph := NewGraph() stderr := new(strings.Builder) |