-
Notifications
You must be signed in to change notification settings - Fork 234
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 #746 from zendesk/matt/webhooks
Enable Webhooks for Pull Requests
- Loading branch information
Showing
10 changed files
with
193 additions
and
30 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
class Changeset::CodePush | ||
attr_reader :repo, :data | ||
|
||
def initialize(repo, data) | ||
@repo = repo | ||
@data = data | ||
end | ||
|
||
def self.changeset_from_webhook(project, params = {}) | ||
new(project.github_repo, params) | ||
end | ||
|
||
def self.valid_webhook?(_) | ||
true | ||
end | ||
|
||
def sha | ||
data[:after] | ||
end | ||
|
||
def branch | ||
data[:ref][/refs\/heads\/(.+)/, 1] | ||
end | ||
|
||
def service_type | ||
'code' # Samson webhook category | ||
end | ||
end |
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
class Changeset::IssueComment | ||
attr_reader :repo, :data | ||
|
||
def initialize(repo, data) | ||
@repo = repo | ||
@body = data['body'] | ||
@data = data['issue'] | ||
end | ||
|
||
def self.changeset_from_webhook(project, params = {}) | ||
new(project.github_repo, params) | ||
end | ||
|
||
def self.valid_webhook?(params) | ||
comment = params[:comment] || {} | ||
comment[:body] =~ Changeset::PullRequest::WEBHOOK_FILTER | ||
end | ||
|
||
def sha | ||
pull_request.sha | ||
end | ||
|
||
def branch | ||
pull_request.branch | ||
end | ||
|
||
def service_type | ||
'pull_request' # Samson webhook category | ||
end | ||
|
||
private | ||
|
||
def pull_request | ||
@pull_request ||= Changeset::PullRequest.find(repo, data['number']) | ||
end | ||
end |
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
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