summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd/generate/src_contribs.go19
-rw-r--r--cmd/generate/src_contribs_test.go10
2 files changed, 20 insertions, 9 deletions
diff --git a/cmd/generate/src_contribs.go b/cmd/generate/src_contribs.go
index f201ab5..5d34fef 100644
--- a/cmd/generate/src_contribs.go
+++ b/cmd/generate/src_contribs.go
@@ -92,6 +92,12 @@ var (
rePiperMailDate = regexp.MustCompile(`^\s*<I>([^<]+)</I>\s*$`)
)
+const (
+ statusOpen = "open"
+ statusMerged = "merged, not yet in a release"
+ statusReleasedFmt = "merged, released in %s"
+)
+
func (c Contribution) fetchStatus() (string, error) {
if m := reGitHubPR.FindStringSubmatch(c.URLs[0]); m != nil {
user := m[1]
@@ -111,13 +117,13 @@ func (c Contribution) fetchStatus() (string, error) {
}
ret := obj.State
if obj.Merged {
- ret = "merged"
+ ret = statusMerged
tag, err := getGitTagThatContainsAll("https://github.com/"+user+"/"+repo, obj.MergeCommitSha)
if err != nil {
return "", err
}
if tag != "" {
- ret = "released in " + tag
+ ret = fmt.Sprintf(statusReleasedFmt, tag)
}
}
@@ -142,10 +148,11 @@ func (c Contribution) fetchStatus() (string, error) {
ret := obj.State
if ret == "opened" {
- ret = "open"
+ ret = statusOpen
}
if ret == "merged" {
+ ret = statusMerged
var mergeCommit string
if obj.MergeCommitSha != "" {
mergeCommit = obj.MergeCommitSha
@@ -159,7 +166,7 @@ func (c Contribution) fetchStatus() (string, error) {
return "", err
}
if tag != "" {
- ret = "released in " + tag
+ ret = fmt.Sprintf(statusReleasedFmt, tag)
}
}
}
@@ -180,13 +187,13 @@ func (c Contribution) fetchStatus() (string, error) {
}
}
if len(gitCommits) > 0 {
- ret := "merged"
+ ret := statusMerged
tag, err := getGitTagThatContainsAll(gitURL, gitCommits...)
if err != nil {
return "", err
}
if tag != "" {
- ret = "released in " + tag
+ ret = fmt.Sprintf(statusReleasedFmt, tag)
}
return ret, nil
}
diff --git a/cmd/generate/src_contribs_test.go b/cmd/generate/src_contribs_test.go
index f7566c0..57ffc0f 100644
--- a/cmd/generate/src_contribs_test.go
+++ b/cmd/generate/src_contribs_test.go
@@ -11,10 +11,14 @@ func TestClassifyStatus(t *testing.T) {
Str string
Err string
}{
- "merged+deployed": {"released", ""},
- "released in v1.2": {"released", ""},
+ "merged+deployed": {"released", ""},
+ "merged, deployed": {"released", ""},
+ "released in v1.2": {"released", ""},
+ "merged, released in v1.2": {"released", ""},
+ statusReleasedFmt: {"released", ""},
- "merged": {"merged", ""},
+ "merged": {"merged", ""},
+ statusMerged: {"merged", ""},
"open": {"open", ""},