|
|
|
@@ -434,3 +434,34 @@ func GetDivergingCommits(repoPath string, baseBranch string, targetBranch string |
|
|
|
|
|
|
|
return DivergeObject{ahead, behind}, nil |
|
|
|
} |
|
|
|
|
|
|
|
type Contributor struct { |
|
|
|
CommitCnt int |
|
|
|
Committer string |
|
|
|
Email string |
|
|
|
} |
|
|
|
|
|
|
|
func GetContributors(repoPath string) ([]Contributor, error){ |
|
|
|
cmd := NewCommand("shortlog", "-sne", "--all") |
|
|
|
stdout, err := cmd.RunInDir(repoPath) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
contributorRows := strings.Split(stdout, "\n") |
|
|
|
if len(contributorRows) > 0 { |
|
|
|
contributorsInfo := make([]Contributor, len(contributorRows)) |
|
|
|
for i := 0; i < len(contributorRows); i++ { |
|
|
|
var oneCount string = strings.Trim(contributorRows[i], " ") |
|
|
|
number := oneCount[0:strings.Index(oneCount," ")] |
|
|
|
commitCnt, _ := strconv.Atoi(number) |
|
|
|
committer := oneCount[strings.Index(oneCount," "):strings.LastIndex(oneCount," ")] |
|
|
|
committer = strings.Trim(committer, " ") |
|
|
|
email := oneCount[strings.LastIndex(oneCount," "):] |
|
|
|
contributorsInfo[i] = Contributor{ |
|
|
|
commitCnt, committer, email, |
|
|
|
} |
|
|
|
} |
|
|
|
return contributorsInfo, nil |
|
|
|
} |
|
|
|
return nil, nil |
|
|
|
} |