pully 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -0
- data/lib/pully/version.rb +1 -1
- data/lib/pully.rb +11 -6
- data/spec/lib_spec.rb +22 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72439241dc5b76e35e22d418d4d9d244461dda6f
|
4
|
+
data.tar.gz: 4902037b47f120482a278373ae6135d93e80daa6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80906d784784c1e7fc625a02f2731edb055debb605392a8ddf537ab3f04085f605c32991a62c57fe41f9e5bcaa4b1a8ae8b2afc1482155e2c49554303f888d96
|
7
|
+
data.tar.gz: 96c64213e4265778e44f6dfef352eba64cd7a2d814ae02a3c76d0e3d91ce5153233c877cf7f15b09a33bb33db43ab130338bb98f8cf290ae37f8286a2011d277
|
data/README.md
CHANGED
@@ -20,6 +20,9 @@ require 'pully'
|
|
20
20
|
#Create a new pully object, each pully object targets (1) repository.
|
21
21
|
pully = Pully.new(user:"github_username", pass:"github_password", repo:"my_repository")
|
22
22
|
|
23
|
+
#Get a list of all open pull requests (An array of pull numbers)
|
24
|
+
open = pully.pull_requests
|
25
|
+
|
23
26
|
#Create a new pull request to merge 'my_branch' into 'master' with the title 'My pull request' and the message 'Hey XXX...'
|
24
27
|
pull_number = pully.create_pull_request(from:"my_branch", to:"master", subject:"My pull request", message:"Hey XXXX, can you merge this for me?")
|
25
28
|
|
data/lib/pully/version.rb
CHANGED
data/lib/pully.rb
CHANGED
@@ -48,17 +48,17 @@ module Pully
|
|
48
48
|
@gh_client.combined_status(@repo_selector, sha)["state"]
|
49
49
|
end
|
50
50
|
|
51
|
+
def pull_requests
|
52
|
+
return @gh_client.pull_requests(@repo_selector, :state => 'open').map{|e| e["number"]}
|
53
|
+
end
|
54
|
+
|
51
55
|
def set_pull_request_status(pull_number, status)
|
52
56
|
sha = sha_for_pull_request pull_number
|
53
57
|
@gh_client.create_status(@repo_selector, sha, status)
|
54
58
|
end
|
55
59
|
|
56
|
-
def merge_pull_request(pull_number)
|
57
|
-
|
58
|
-
from_name = branches[:from]
|
59
|
-
to_name = branches[:to]
|
60
|
-
@gh_client.merge(@repo_selector, to_name, from_name)
|
61
|
-
@gh_client.close_pull_request(@repo_selector, pull_number)
|
60
|
+
def merge_pull_request(pull_number, message='Merged Pull Request')
|
61
|
+
@gh_client.merge_pull_request(@repo_selector, pull_number, message)
|
62
62
|
end
|
63
63
|
|
64
64
|
def pull_request_branches(pull_number)
|
@@ -160,6 +160,11 @@ module Pully
|
|
160
160
|
@git_client.object("HEAD").sha
|
161
161
|
end
|
162
162
|
|
163
|
+
def latest_message branch_name
|
164
|
+
@git_client.checkout(branch_name)
|
165
|
+
@git_client.object("HEAD").message
|
166
|
+
end
|
167
|
+
|
163
168
|
def master_branch
|
164
169
|
@repo.default_branch
|
165
170
|
end
|
data/spec/lib_spec.rb
CHANGED
@@ -188,7 +188,7 @@ RSpec.describe "Library" do
|
|
188
188
|
th.create_branch(new_branch_name)
|
189
189
|
th.commit_new_random_file(new_branch_name)
|
190
190
|
|
191
|
-
pully = Pully.new(user: gh_info["user"], pass: gh_info["pass"], repo: gh_info["org_repo"])
|
191
|
+
pully = Pully.new(user: gh_info["user"], pass: gh_info["pass"], repo: gh_info["org_repo"], owner: gh_info["org_owner"])
|
192
192
|
pull_number = pully.create_pull_request(from:new_branch_name, to:"master", subject:"My pull request", message:"Hey XXXX, can you merge this for me?")
|
193
193
|
branches = pully.pull_request_branches(pull_number)
|
194
194
|
|
@@ -208,15 +208,33 @@ RSpec.describe "Library" do
|
|
208
208
|
|
209
209
|
pully = Pully.new(user: gh_info["user"], pass: gh_info["pass"], repo: gh_info["repo"])
|
210
210
|
pull_number = pully.create_pull_request(from:new_branch_name, to:"master", subject:"My pull request", message:"Hey XXXX, can you merge this for me?")
|
211
|
-
|
211
|
+
msg = SecureRandom.hex
|
212
|
+
pully.merge_pull_request(pull_number, msg)
|
212
213
|
|
213
|
-
#
|
214
|
+
#Commit message contains message given
|
214
215
|
th = Pully::TestHelpers::Branch.new(user: gh_info["user"], pass: gh_info["pass"], repo_selector: repo_selector(user: gh_info["user"], repo: gh_info["repo"], owner:nil), clone_url: gh_info["clone_url"])
|
215
|
-
expect(th.
|
216
|
+
expect(th.latest_message("master") =~ /#{msg}/).not_to eq(nil)
|
216
217
|
|
217
218
|
#We expect the pull request to be closed
|
218
219
|
expect(pully.pull_request_is_open?(pull_number)).to eq(false)
|
219
220
|
|
220
221
|
th.delete_branch(new_branch_name)
|
221
222
|
end
|
223
|
+
|
224
|
+
it "Can list pull requests" do
|
225
|
+
sleep 10
|
226
|
+
#test branch creator
|
227
|
+
new_branch_name = SecureRandom.hex
|
228
|
+
th = Pully::TestHelpers::Branch.new(user: gh_info["user"], pass: gh_info["pass"], repo_selector: repo_selector(user: gh_info["user"], repo: gh_info["repo"], owner:nil), clone_url: gh_info["clone_url"])
|
229
|
+
th.create_branch(new_branch_name)
|
230
|
+
last_sha = th.commit_new_random_file(new_branch_name)
|
231
|
+
|
232
|
+
pully = Pully.new(user: gh_info["user"], pass: gh_info["pass"], repo: gh_info["repo"])
|
233
|
+
pull_number = pully.create_pull_request(from:new_branch_name, to:"master", subject:"My pull request", message:"Hey XXXX, can you merge this for me?")
|
234
|
+
|
235
|
+
expect(pully.pull_requests).to include(pull_number)
|
236
|
+
|
237
|
+
th.delete_branch(new_branch_name)
|
238
|
+
|
239
|
+
end
|
222
240
|
end
|