|
|
@ -12,8 +12,6 @@ import ( |
|
|
|
"net/http" |
|
|
|
"net/http" |
|
|
|
"strconv" |
|
|
|
"strconv" |
|
|
|
"strings" |
|
|
|
"strings" |
|
|
|
|
|
|
|
|
|
|
|
"github.com/mcuadros/go-version" |
|
|
|
|
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
// Commit represents a git commit.
|
|
|
|
// Commit represents a git commit.
|
|
|
@ -160,13 +158,7 @@ func CommitChanges(repoPath string, opts CommitChangesOptions) error { |
|
|
|
|
|
|
|
|
|
|
|
func commitsCount(repoPath, revision, relpath string) (int64, error) { |
|
|
|
func commitsCount(repoPath, revision, relpath string) (int64, error) { |
|
|
|
var cmd *Command |
|
|
|
var cmd *Command |
|
|
|
isFallback := false |
|
|
|
|
|
|
|
if version.Compare(gitVersion, "1.8.0", "<") { |
|
|
|
|
|
|
|
isFallback = true |
|
|
|
|
|
|
|
cmd = NewCommand("log", "--pretty=format:''") |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
cmd = NewCommand("rev-list", "--count") |
|
|
|
cmd = NewCommand("rev-list", "--count") |
|
|
|
} |
|
|
|
|
|
|
|
cmd.AddArguments(revision) |
|
|
|
cmd.AddArguments(revision) |
|
|
|
if len(relpath) > 0 { |
|
|
|
if len(relpath) > 0 { |
|
|
|
cmd.AddArguments("--", relpath) |
|
|
|
cmd.AddArguments("--", relpath) |
|
|
@ -177,9 +169,6 @@ func commitsCount(repoPath, revision, relpath string) (int64, error) { |
|
|
|
return 0, err |
|
|
|
return 0, err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if isFallback { |
|
|
|
|
|
|
|
return int64(strings.Count(stdout, "\n")) + 1, nil |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return strconv.ParseInt(strings.TrimSpace(stdout), 10, 64) |
|
|
|
return strconv.ParseInt(strings.TrimSpace(stdout), 10, 64) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|