|
|
@@ -445,8 +445,12 @@ type Contributor struct { |
|
|
|
Email string |
|
|
|
} |
|
|
|
|
|
|
|
func GetContributors(repoPath string) ([]Contributor, error){ |
|
|
|
cmd := NewCommand("shortlog", "-sne", "--all") |
|
|
|
func GetContributors(repoPath string, branchOrTag ...string) ([]Contributor, error) { |
|
|
|
targetBranchOrTag := "HEAD" |
|
|
|
if len(branchOrTag) > 0 && branchOrTag[0] != "" { |
|
|
|
targetBranchOrTag = branchOrTag[0] |
|
|
|
} |
|
|
|
cmd := NewCommand("shortlog", "-sne", targetBranchOrTag) |
|
|
|
stdout, err := cmd.RunInDir(repoPath) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
@@ -462,9 +466,9 @@ func GetContributors(repoPath string) ([]Contributor, error){ |
|
|
|
} |
|
|
|
number := oneCount[0:strings.Index(oneCount, "\t")] |
|
|
|
commitCnt, _ := strconv.Atoi(number) |
|
|
|
committer := oneCount[strings.Index(oneCount, "\t")+1:strings.LastIndex(oneCount, " ")] |
|
|
|
committer := oneCount[strings.Index(oneCount, "\t")+1 : strings.LastIndex(oneCount, " ")] |
|
|
|
committer = strings.Trim(committer, " ") |
|
|
|
email := oneCount[strings.Index(oneCount, "<")+1:strings.Index(oneCount, ">")] |
|
|
|
email := oneCount[strings.Index(oneCount, "<")+1 : strings.Index(oneCount, ">")] |
|
|
|
contributorsInfo[i] = Contributor{ |
|
|
|
commitCnt, committer, email, |
|
|
|
} |
|
|
|