Skip to content

Commit

Permalink
Add no-dco label before closing no_newbies PRs
Browse files Browse the repository at this point in the history
In a PR raised on the openfaas/faasd repo, the no-dco label
wasn't added, when it should have been. If the PR was re-
opened then it may be merged in error, even without the DCO.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
  • Loading branch information
alexellis committed Oct 2, 2020
1 parent c4a6f55 commit a59e053
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
13 changes: 6 additions & 7 deletions handler/hacktoberfest_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,19 @@ func HandleFirstTimerPR(req types.PullRequestOuter, contributingURL string, conf

fmt.Println(fmt.Sprintf("Request to close issue #%d was successful.\n", req.PullRequest.Number))

body := firstTimerComment(contributingURL)
if err = createPullRequestComment(ctx, body, req, client); err != nil {
log.Fatalf("unable to add comment on PR %d: %s", req.PullRequest.Number, err)
return true, err
}

_, res, assignLabelErr := client.Issues.AddLabelsToIssue(ctx, req.Repository.Owner.Login, req.Repository.Name, req.PullRequest.Number,
[]string{invalidLabel})
if assignLabelErr != nil {
log.Fatalf("%s limit: %d, remaining: %d", assignLabelErr, res.Limit, res.Remaining)
return true, assignLabelErr
}

body := firstTimerComment(contributingURL)

if err = createPullRequestComment(ctx, body, req, client); err != nil {
log.Fatalf("unable to add comment on PR %d: %s", req.PullRequest.Number, err)
return true, err
}

return true, nil
}
}
Expand Down
16 changes: 10 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,24 +134,28 @@ func handleEvent(eventType string, bytesIn []byte, config config.Config) error {

if req.Action != handler.ClosedConstant && req.PullRequest.State != handler.ClosedConstant {
contributingURL := getContributingURL(derekConfig.ContributingURL, req.Repository.Owner.Login, req.Repository.Name)

if handler.EnabledFeature(dcoCheck, derekConfig) {
handler.HandlePullRequest(req, contributingURL, config)
}

if handler.EnabledFeature(prDescriptionRequired, derekConfig) {
handler.VerifyPullRequestDescription(req, contributingURL, config)
}

if handler.EnabledFeature(noNewbies, derekConfig) {
isSpamPR, _ := handler.HandleFirstTimerPR(req, contributingURL, config)
if isSpamPR {
return nil
}
}

if handler.EnabledFeature(hacktoberfest, derekConfig) {
isSpamPR, _ := handler.HandleHacktoberfestPR(req, contributingURL, config)
if isSpamPR {
return nil
}
}
if handler.EnabledFeature(dcoCheck, derekConfig) {
handler.HandlePullRequest(req, contributingURL, config)
}
if handler.EnabledFeature(prDescriptionRequired, derekConfig) {
handler.VerifyPullRequestDescription(req, contributingURL, config)
}
}
break

Expand Down

0 comments on commit a59e053

Please sign in to comment.