Skip to content

Commit

Permalink
Remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Bodner committed May 19, 2016
1 parent cd5522a commit db9a19f
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 144 deletions.
69 changes: 0 additions & 69 deletions remote/github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,65 +440,6 @@ func (g *Github) GetPRHook(r *http.Request) (*model.PRHook, error) {
return hook, nil
}

func (g *Github) GetPushHook(r *http.Request) (*model.PushHook, error) {

// only process comment hooks
if r.Header.Get("X-Github-Event") != "push" {
return nil, nil
}

data := pushHook{}
err := json.NewDecoder(r.Body).Decode(&data)
if err != nil {
return nil, err
}

log.Debug(data)

if data.HeadCommit == nil {
return nil, nil
}

hook := new(model.PushHook)

hook.SHA = data.HeadCommit.ID
hook.Repo = new(model.Repo)
hook.Repo.Owner = data.Repository.Owner.Login
hook.Repo.Name = data.Repository.Name
hook.Repo.Slug = data.Repository.FullName

log.Debug(*hook)

return hook, nil
}

func (g *Github) UpdatePRsForCommit(u *model.User, r *model.Repo, sha *string) (bool, error) {
//if we have a new commit on an existing open PR, then we need to put a new pending LGTM status on it
//if the commit is not associated with an open PR, then we don't do any status update
client := setupClient(g.API, u.Token)
log.Debug("sha == ", *sha)
issues, _, err := client.Search.Issues(fmt.Sprintf("%s&type=pr", *sha), &github.SearchOptions{
TextMatch: false,
})
if err != nil {
return false, err
}
if issues.Total != nil && *issues.Total > 0 {
status := "pending"
desc := "this commit is pending approval"

data := github.RepoStatus{
Context: github.String(context),
State: github.String(status),
Description: github.String(desc),
}

_, _, err = client.Repositories.CreateStatus(r.Owner, r.Name, *sha, &data)
return true, err
}
return false, nil
}

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)
Expand Down Expand Up @@ -562,16 +503,6 @@ func (g *Github) GetPullRequestsForCommit(u *model.User, r *model.Repo, sha *str
return out, nil
}

func (g *Github) GetBranchStatus(u *model.User, r *model.Repo, branch string) (*model.BranchStatus, error) {
client := setupClient(g.API, u.Token)
statuses, _, err := client.Repositories.GetCombinedStatus(r.Owner, r.Name, branch, nil)
if err != nil {
return nil, err
}

return (*model.BranchStatus)(statuses.State), nil
}

func (g *Github) MergePR(u *model.User, r *model.Repo, pullRequest model.PullRequest, approvers []*model.Person) (*string, error) {
client := setupClient(g.API, u.Token)

Expand Down
23 changes: 0 additions & 23 deletions remote/mock/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,6 @@ func (_m *Remote) DelHook(_a0 *model.User, _a1 *model.Repo, _a2 string) error {
return r0
}

// GetBranchStatus provides a mock function with given fields: _a0, _a1, _a2
func (_m *Remote) GetBranchStatus(_a0 *model.User, _a1 *model.Repo, _a2 string) (*model.BranchStatus, error) {
ret := _m.Called(_a0, _a1, _a2)

var r0 *model.BranchStatus
if rf, ok := ret.Get(0).(func(*model.User, *model.Repo, string) *model.BranchStatus); ok {
r0 = rf(_a0, _a1, _a2)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*model.BranchStatus)
}
}

var r1 error
if rf, ok := ret.Get(1).(func(*model.User, *model.Repo, string) error); ok {
r1 = rf(_a0, _a1, _a2)
} else {
r1 = ret.Error(1)
}

return r0, r1
}

// GetComments provides a mock function with given fields: _a0, _a1, _a2
func (_m *Remote) GetComments(_a0 *model.User, _a1 *model.Repo, _a2 int) ([]*model.Comment, error) {
ret := _m.Called(_a0, _a1, _a2)
Expand Down
23 changes: 0 additions & 23 deletions remote/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,6 @@ type Remote interface {
// GetPRHook gets the pull request hook from the http Request.
GetPRHook(r *http.Request) (*model.PRHook, error)

// GetPushHook gets the push hook from the http Request.
GetPushHook(r *http.Request) (*model.PushHook, error)

// GetBranchStatus returns overall status for the named branch from the remote system
GetBranchStatus(*model.User, *model.Repo, string) (*model.BranchStatus, error)

// MergePR merges the named pull request from the remote system
MergePR(u *model.User, r *model.Repo, pullRequest model.PullRequest, approvers []*model.Person) (*string, error)

Expand All @@ -77,9 +71,6 @@ type Remote interface {
// GetPullRequestsForCommit returns all pull requests associated with a commit SHA
GetPullRequestsForCommit(u *model.User, r *model.Repo, sha *string) ([]model.PullRequest, error)

// UpdatePRsForCommit sets the commit's status to pending for LGTM if it is already on an open Pull Request
UpdatePRsForCommit(u *model.User, r *model.Repo, sha *string) (bool, error)

// WriteComment puts a new comment from LGTM into the PR
WriteComment(u *model.User, r *model.Repo, num int, message string) error
}
Expand Down Expand Up @@ -165,16 +156,6 @@ func GetPRHook(c context.Context, r *http.Request) (*model.PRHook, error) {
return FromContext(c).GetPRHook(r)
}

// GetPushHook gets the push hook from the http Request.
func GetPushHook(c context.Context, r *http.Request) (*model.PushHook, error) {
return FromContext(c).GetPushHook(r)
}

// GetBranchStatus gets the overal status for a branch from the remote repository.
func GetBranchStatus(c context.Context, u *model.User, r *model.Repo, branch string) (*model.BranchStatus, error) {
return FromContext(c).GetBranchStatus(u, r, branch)
}

func MergePR(c context.Context, u *model.User, r *model.Repo, pullRequest model.PullRequest, approvers []*model.Person) (*string, error) {
return FromContext(c).MergePR(u, r, pullRequest, approvers)
}
Expand All @@ -192,10 +173,6 @@ func GetPullRequestsForCommit(c context.Context, u *model.User, r *model.Repo, s

}

func UpdatePRsForCommit(c context.Context, u *model.User, r *model.Repo, sha *string) (bool, error) {
return FromContext(c).UpdatePRsForCommit(u, r, sha)
}

func WriteComment(c context.Context, u *model.User, r *model.Repo, num int, message string) error {
return FromContext(c).WriteComment(u, r, num, message)
}
29 changes: 0 additions & 29 deletions web/push_hook.go

This file was deleted.

0 comments on commit db9a19f

Please sign in to comment.