mirror of https://github.com/go-gitea/gitea.git
Fixed commit count
This commit is contained in:
parent
22f63d918f
commit
88d70d305b
|
|
@ -172,7 +172,7 @@ type CommitsCountOptions struct {
|
|||
|
||||
// CommitsCount returns number of total commits of until given revision.
|
||||
func CommitsCount(ctx context.Context, opts CommitsCountOptions) (int64, error) {
|
||||
cmd := NewCommand("rev-list", "--count")
|
||||
cmd := NewCommand(ctx, "--no-pager", "log", "--pretty=format:%H")
|
||||
|
||||
cmd.AddDynamicArguments(opts.Revision...)
|
||||
|
||||
|
|
@ -181,6 +181,7 @@ func CommitsCount(ctx context.Context, opts CommitsCountOptions) (int64, error)
|
|||
}
|
||||
|
||||
if len(opts.RelPath) > 0 {
|
||||
cmd.AddOptionValues("--follow")
|
||||
cmd.AddDashesAndList(opts.RelPath...)
|
||||
}
|
||||
|
||||
|
|
@ -188,8 +189,7 @@ func CommitsCount(ctx context.Context, opts CommitsCountOptions) (int64, error)
|
|||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return strconv.ParseInt(strings.TrimSpace(stdout), 10, 64)
|
||||
return int64(len(strings.Split(stdout, "\n"))), nil
|
||||
}
|
||||
|
||||
// CommitsCount returns number of total commits of until current revision.
|
||||
|
|
|
|||
Loading…
Reference in New Issue