forked from lgtmco/lgtm
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request lgtmco#6 from jonbodner/add_approvers_to_merge_mes…
…sage Add approvers to merge message
- Loading branch information
Showing
5 changed files
with
63 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -414,7 +414,7 @@ func (g *Github) GetPRHook(r *http.Request) (*model.PRHook, error) { | |
func (g *Github) GetPullRequestsForCommit(u *model.User, r *model.Repo, sha *string) ([]model.PullRequest, error) { | ||
client := setupClient(g.API, u.Token) | ||
log.Debug("sha == ", sha, *sha) | ||
issues, _, err := client.Search.Issues(fmt.Sprintf("%s&type=pr", *sha), &github.SearchOptions { | ||
issues, _, err := client.Search.Issues(fmt.Sprintf("%s&type=pr", *sha), &github.SearchOptions{ | ||
TextMatch: false, | ||
}) | ||
if err != nil { | ||
|
@@ -427,7 +427,7 @@ func (g *Github) GetPullRequestsForCommit(u *model.User, r *model.Repo, sha *str | |
return nil, err | ||
} | ||
|
||
mergeable:= true | ||
mergeable := true | ||
if pr.Mergeable != nil { | ||
mergeable = *pr.Mergeable | ||
} | ||
|
@@ -439,15 +439,15 @@ func (g *Github) GetPullRequestsForCommit(u *model.User, r *model.Repo, sha *str | |
|
||
log.Debug("current issue ==", v) | ||
log.Debug("current pr ==", *pr) | ||
log.Debug("combined status ==",*status) | ||
log.Debug("combined status ==", *status) | ||
|
||
combinedState := *status.State | ||
if combinedState == "success" { | ||
log.Debug("overall status is success -- checking to see if all status checks returned success") | ||
for _, v := range status.Statuses { | ||
log.Debugf("status check %s returned %s",*v.Context, *v.State) | ||
log.Debugf("status check %s returned %s", *v.Context, *v.State) | ||
if *v.State != "success" { | ||
log.Debugf("setting combined status check to %s",*v.State) | ||
log.Debugf("setting combined status check to %s", *v.State) | ||
combinedState = *v.State | ||
} | ||
} | ||
|
@@ -458,7 +458,7 @@ func (g *Github) GetPullRequestsForCommit(u *model.User, r *model.Repo, sha *str | |
Title: *v.Title, | ||
Author: *v.User.Login, | ||
}, | ||
Branch: model.Branch { | ||
Branch: model.Branch{ | ||
Name: *pr.Head.Ref, | ||
BranchStatus: combinedState, | ||
Mergeable: mergeable, | ||
|
@@ -479,10 +479,28 @@ func (g *Github) GetBranchStatus(u *model.User, r *model.Repo, branch string) (* | |
return (*model.BranchStatus)(statuses.State), nil | ||
} | ||
|
||
func (g *Github) MergePR(u *model.User, r *model.Repo, pullRequest model.PullRequest) (*string, error) { | ||
func (g *Github) MergePR(u *model.User, r *model.Repo, pullRequest model.PullRequest, approvers []*model.Person) (*string, error) { | ||
client := setupClient(g.API, u.Token) | ||
|
||
result, _, err := client.PullRequests.Merge(r.Owner, r.Name, pullRequest.Number, "Merged by LGTM") | ||
msg := "Merged by LGTM\n" | ||
if len(approvers) > 0 { | ||
apps := "Approved by:\n" | ||
for _, v := range approvers { | ||
//Brad Rydzewski <[email protected]> (@bradrydzewski) | ||
if len(v.Name) > 0 { | ||
apps += fmt.Sprintf("%s", v.Name) | ||
} | ||
if len(v.Email) > 0 { | ||
apps += fmt.Sprintf(" <%s>", v.Email) | ||
} | ||
if len(v.Login) > 0 { | ||
apps += fmt.Sprintf(" (@%s)", v.Login) | ||
} | ||
apps += "\n" | ||
} | ||
msg += apps | ||
} | ||
result, _, err := client.PullRequests.Merge(r.Owner, r.Name, pullRequest.Number, msg) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
@@ -500,7 +518,7 @@ func (g *Github) ListTags(u *model.User, r *model.Repo) ([]model.Tag, error) { | |
if err != nil { | ||
return nil, err | ||
} | ||
out := make([]model.Tag,len(tags)) | ||
out := make([]model.Tag, len(tags)) | ||
for k, v := range tags { | ||
out[k] = model.Tag(*v.Name) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters