Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: octokit/octokit.rb
base: fceb9a677b
...
head fork: octokit/octokit.rb
compare: af6cfe5caf
Checking mergeability… Don't worry, you can still create the pull request.
  • 4 commits
  • 4 files changed
  • 0 commit comments
  • 2 contributors
View
26 lib/octokit/client/repositories.rb
@@ -127,6 +127,32 @@ def branches(repo, options={})
get "/repos/#{Repository.new repo}/branches", options, 3
end
+ def hooks(repo, options={})
+ get "/repos/#{Repository.new repo}/hooks", options, 3
+ end
+
+ def hook(repo, id, options={})
+ get "/repos/#{Repository.new repo}/hooks/#{id}", options, 3
+ end
+
+ def create_hook(repo, name, config, options={})
+ options = {:name => name, :config => config, :events => ["push"], :active => true}.merge(options)
+ post "/repos/#{Repository.new repo}/hooks", options, 3
+ end
+
+ def edit_hook(repo, id, name, config, options={})
+ options = {:name => name, :config => config, :events => ["push"], :active => true}.merge(options)
+ patch "/repos/#{Repository.new repo}/hooks/#{id}", options, 3
+ end
+
+ def remove_hook(repo, id, options={})
+ delete "/repos/#{Repository.new repo}/hooks/#{id}", options, 3
+ end
+
+ def test_hook(repo, id, options={})
+ post "/repos/#{Repository.new repo}/hooks/#{id}/test", options, 3
+ end
+
# Get all Issue Events for a given Repository
#
# @param repo [String, Repository, Hash] A GitHub repository
View
18 spec/fixtures/v3/hook.json
@@ -0,0 +1,18 @@
+{
+ "active": true,
+ "config": {
+ "railsbp_url": "http://railsbp.com",
+ "token": "xAAQZtJhYHGagsed1kYR"
+ },
+ "created_at": "2012-01-23T14:11:50Z",
+ "events": ["push"],
+ "id": 154284,
+ "last_response": {
+ "code": 200,
+ "message": "OK",
+ "status": "ok"
+ },
+ "name": "railsbp",
+ "updated_at": "2012-05-13T13:09:51Z",
+ "url": "https://api.github.com/repos/railsbp/railsbp.com/hooks/154284"
+}
View
70 spec/fixtures/v3/hooks.json
@@ -0,0 +1,70 @@
+[{
+ "active": true,
+ "config": {
+ "token": "f2a00b0bb2e270afcfeb6659d67c0561",
+ "user": "flyerhzm"
+ },
+ "created_at": "2011-11-28T05:00:58Z",
+ "events": ["push"],
+ "id": 121594,
+ "last_response": {
+ "code": 200,
+ "message": "OK",
+ "status": "ok"
+ },
+ "name": "gemnasium",
+ "updated_at": "2012-05-13T13:09:51Z",
+ "url": "https://api.github.com/repos/railsbp/railsbp.com/hooks/121594"
+}, {
+ "active": true,
+ "config": {
+ "railsbp_url": "http://railsbp.com",
+ "token": "xAAQZtJhYHGagsed1kYR"
+ },
+ "created_at": "2012-01-23T14:11:50Z",
+ "events": ["push"],
+ "id": 154284,
+ "last_response": {
+ "code": 200,
+ "message": "OK",
+ "status": "ok"
+ },
+ "name": "railsbp",
+ "updated_at": "2012-05-13T13:09:51Z",
+ "url": "https://api.github.com/repos/railsbp/railsbp.com/hooks/154284"
+}, {
+ "active": true,
+ "config": {
+ "token": "BCxleMW8q0IOCeuBABKAkpcRwMdH7TlNxb3f7R6Tjwk5E4gIDL0nW156xIcz",
+ "user": "flyerhzm"
+ },
+ "created_at": "2012-02-20T06:07:24Z",
+ "events": ["push"],
+ "id": 175702,
+ "last_response": {
+ "code": 200,
+ "message": "OK",
+ "status": "ok"
+ },
+ "name": "travis",
+ "updated_at": "2012-05-13T13:09:52Z",
+ "url": "https://api.github.com/repos/railsbp/railsbp.com/hooks/175702"
+}, {
+ "active": true,
+ "config": {
+ "content_type": "form",
+ "insecure_ssl": "1",
+ "url": "http://rails-brakeman.com/"
+ },
+ "created_at": "2012-05-14T00:05:41Z",
+ "events": ["push"],
+ "id": 249928,
+ "last_response": {
+ "code": 200,
+ "message": "OK",
+ "status": "ok"
+ },
+ "name": "web",
+ "updated_at": "2012-05-14T00:05:47Z",
+ "url": "https://api.github.com/repos/railsbp/railsbp.com/hooks/249928"
+}]
View
68 spec/octokit/client/repositories_spec.rb
@@ -316,6 +316,74 @@
end
+ describe ".hooks" do
+
+ it "should return a repository's hooks" do
+ stub_get("/repos/railsbp/railsbp.com/hooks").
+ to_return(:body => fixture("v3/hooks.json"))
+ hooks = @client.hooks("railsbp/railsbp.com")
+ hook = hooks.find { |hook| hook.name == "railsbp" }
+ hook.config.token.should == "xAAQZtJhYHGagsed1kYR"
+ end
+
+ end
+
+ describe ".hook" do
+
+ it "should return a repository's single hook" do
+ stub_get("/repos/railsbp/railsbp.com/hooks/154284").
+ to_return(:body => fixture("v3/hook.json"))
+ hook = @client.hook("railsbp/railsbp.com", 154284)
+ hook.config.token.should == "xAAQZtJhYHGagsed1kYR"
+ end
+
+ end
+
+ describe ".create_hook" do
+
+ it "should create a hook" do
+ stub_post("/repos/railsbp/railsbp.com/hooks").
+ with(:body => {:name => "railsbp", :config => {:railsbp_url => "http://railsbp.com", :token => "xAAQZtJhYHGagsed1kYR"}, :events => ["push"], :active => true}).
+ to_return(:body => fixture("v3/hook.json"))
+ hook = @client.create_hook("railsbp/railsbp.com", "railsbp", {:railsbp_url => "http://railsbp.com", :token => "xAAQZtJhYHGagsed1kYR"})
+ hook.id.should == 154284
+ end
+
+ end
+
+ describe ".edit_hook" do
+
+ it "should edit a hook" do
+ stub_patch("/repos/railsbp/railsbp.com/hooks/154284").
+ with(:body => {:name => "railsbp", :config => {:railsbp_url => "http://railsbp.com", :token => "xAAQZtJhYHGagsed1kYR"}, :events => ["push"], :active => true}).
+ to_return(:body => fixture("v3/hook.json"))
+ hook = @client.edit_hook("railsbp/railsbp.com", 154284, "railsbp", {:railsbp_url => "http://railsbp.com", :token => "xAAQZtJhYHGagsed1kYR"})
+ hook.id.should == 154284
+ hook.config.token.should == "xAAQZtJhYHGagsed1kYR"
+ end
+
+ end
+
+ describe ".remove_hook" do
+
+ it "should remove a hook" do
+ stub_delete("/repos/railsbp/railsbp.com/hooks/154284").
+ to_return(:status => 204)
+ @client.remove_hook("railsbp/railsbp.com", 154284).should be_nil
+ end
+
+ end
+
+ describe ".test_hook" do
+
+ it "should test a hook" do
+ stub_post("/repos/railsbp/railsbp.com/hooks/154284/test").
+ to_return(:status => 204)
+ @client.test_hook("railsbp/railsbp.com", 154284).should be_nil
+ end
+
+ end
+
describe ".events" do
it "should list event for all issues in a repository" do

No commit comments for this range

Something went wrong with that request. Please try again.