Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add convention label variations #58

Merged
merged 1 commit into from
Aug 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions rcpr.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,16 @@ func Run(ctx context.Context, argv []string, outStream, errStream io.Writer) err
if err != nil {
return err
}
var currRcpr *github.PullRequest

var (
labels []*github.Label
currRcpr *github.PullRequest
)
if len(pulls) > 0 {
currRcpr = pulls[0]
labels = currRcpr.Labels
}

nextVer := guessNextSemver(currVer, currRcpr)
nextVer := guessNextSemver(currVer, labels)

var vfile string
if rp.cfg.versionFile == nil {
Expand Down Expand Up @@ -430,16 +434,14 @@ func (rp *rcpr) detectRemote() (string, error) {
return remotes[len(remotes)-1], nil
}

func guessNextSemver(ver *semv, pr *github.PullRequest) *semv {
func guessNextSemver(ver *semv, labels []*github.Label) *semv {
var isMajor, isMinor bool
if pr != nil {
for _, l := range pr.Labels {
switch l.GetName() {
case autoLableName + ":major":
isMajor = true
case autoLableName + ":minor":
isMinor = true
}
for _, l := range labels {
switch l.GetName() {
case autoLableName + ":major", autoLableName + "/major":
isMajor = true
case autoLableName + ":minor", autoLableName + "/minor":
isMinor = true
}
}

Expand Down
2 changes: 1 addition & 1 deletion tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (rp *rcpr) tagRelease(ctx context.Context, pr *github.PullRequest, currVer
}
nextTag = nextVer.Tag()
} else {
nextTag = guessNextSemver(currVer, pr).Tag()
nextTag = guessNextSemver(currVer, pr.Labels).Tag()
}
previousTag := &latestSemverTag
if *previousTag == "" {
Expand Down