From a032635665d956615d2b4e700929e5ae08ea39d8 Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 2 Feb 2023 14:48:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E9=82=AE=E7=AE=B1?= =?UTF-8?q?=E5=8C=B9=E9=85=8D=E8=A7=84=E5=88=99=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/git/repo_stats.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/git/repo_stats.go b/modules/git/repo_stats.go index 1cffcdb..7dbe00a 100644 --- a/modules/git/repo_stats.go +++ b/modules/git/repo_stats.go @@ -37,7 +37,13 @@ func GetCodeActivityStatsWithoutSince(repo *gitea_git.Repository, branch string, stats := &CodeActivityStats{} - authorStdout, _, runErr := gitea_git.NewCommand(repo.Ctx, "log", "--all", "--format='%aN <%cE>'").RunStdString(&gitea_git.RunOpts{Dir: repo.Path}) + authorCmd := gitea_git.NewCommand(repo.Ctx, "log", "--no-merges", "--format=%aN <%aE>", "--date=iso") + if len(branch) == 0 { + authorCmd.AddArguments("--branches=*") + } else { + authorCmd.AddArguments("--first-parent").AddDynamicArguments(branch) + } + authorStdout, _, runErr := authorCmd.RunStdString(&gitea_git.RunOpts{Dir: repo.Path}) if runErr != nil { return total, nil, runErr } @@ -56,7 +62,6 @@ func GetCodeActivityStatsWithoutSince(repo *gitea_git.Repository, branch string, authorSet[author] = true authorArr[total] = author total++ - author = strings.ReplaceAll(author, "'", "") if skip > 0 { skip-- } else {