Skip to content
This repository has been archived by the owner on Feb 14, 2023. It is now read-only.

Commit

Permalink
Merge pull request #101 from tetsuharuohzeki/log
Browse files Browse the repository at this point in the history
Add the log if this action sucess to remove the label
  • Loading branch information
tetsuharuohzeki authored Jul 8, 2020
2 parents b09061e + afe5352 commit 1652887
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ func main() {
switch actionType {
case ACTION_TYPE_PUSH:
log.Println("Search and mark unmergeable pull requests.")
onPushEvent(githubClient, githubEventPath, repoOwner, repoName, needRebaseLabel)
checkWhetherPushCausedUnmergeable(githubClient, githubEventPath, repoOwner, repoName, needRebaseLabel)
case ACTION_TYPE_PULL_REQ:
log.Println("Check whether the synced pull request is mergeable or not.")
onPullRequestEvent(githubClient, githubEventPath, repoOwner, repoName, needRebaseLabel)
checkPrIsChangedToMergeable(githubClient, githubEventPath, repoOwner, repoName, needRebaseLabel)
default:
return
}
Expand All @@ -91,7 +91,7 @@ func createGithubClient(token string) *github.Client {
return client
}

func onPushEvent(githubClient *github.Client, githubEventPath string, repoOwner string, repoName string, needRebaseLabel string) {
func checkWhetherPushCausedUnmergeable(githubClient *github.Client, githubEventPath string, repoOwner string, repoName string, needRebaseLabel string) {
eventData := loadJSONFileForPushEventData(githubEventPath)
if eventData == nil {
log.Fatal("Could not get eventData")
Expand Down Expand Up @@ -139,7 +139,7 @@ func onPushEvent(githubClient *github.Client, githubEventPath string, repoOwner
wg.Wait()
}

func onPullRequestEvent(githubClient *github.Client, githubEventPath string, repoOwner string, repoName string, needRebaseLabel string) {
func checkPrIsChangedToMergeable(githubClient *github.Client, githubEventPath string, repoOwner string, repoName string, needRebaseLabel string) {
eventData := loadJSONFileForPullRequestEventData(githubEventPath)
if eventData == nil {
log.Fatal("Could not get eventData")
Expand Down Expand Up @@ -172,4 +172,6 @@ func onPullRequestEvent(githubClient *github.Client, githubEventPath string, rep
log.Printf("#%v is mergeable but fail to remove the label `%v`", prNumber, needRebaseLabel)
return
}

log.Printf("#%v is mergeable. We removed the label `%v`", prNumber, needRebaseLabel)
}

0 comments on commit 1652887

Please sign in to comment.