txgh-server 2.1.0 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9e75d11d351052dcae4752db36b41f3bfe213b7c
4
- data.tar.gz: 26d3a5ace61faa39884854fc336e70490fbb1bd6
3
+ metadata.gz: 08999181efe8b160394afe81270055aea22ba8df
4
+ data.tar.gz: 80f4a180a3a7d20f97adb2c587bcf884f3ba85c1
5
5
  SHA512:
6
- metadata.gz: 9a230bc3d628166f714d41a4705c85b1331c44f267b9c593e5049903149f91ca379d050a5f8e7ed31b09ac52eebaa01ae0bc903c235044ed10c6a322e9df1b9a
7
- data.tar.gz: 2c594d254994d92586b44653448387e450e52931719f6819e0657a7dc7e472a375c72a55bac7abdf00652f837e268d5d9824b2cb310c1e0a8e0e96b45e8e9bdc
6
+ metadata.gz: 11edfef929681456b7e0977a34a67b99e658341e82e6f6a71f18034fada792614eaf4d3547f14ee9205c6d4fc0a14fe944676c6e0cf1c8e1ca8df1bf6b4716e4
7
+ data.tar.gz: ee273984933596d9363ecf632e2f85a895fc06559c6458f7244946459dac03f9b7350a603f6069fc5c825980bfb444720e08837886f4b607bc20c109945fe96c
@@ -1,3 +1,3 @@
1
1
  module TxghServer
2
- VERSION = '2.1.0'
2
+ VERSION = '2.1.1'
3
3
  end
@@ -45,7 +45,12 @@ module TxghServer
45
45
  end
46
46
 
47
47
  def author(payload)
48
- payload.fetch('head_commit').fetch('committer').fetch('name')
48
+ if head_commit = payload.fetch('head_commit')
49
+ head_commit.fetch('committer').fetch('name')
50
+ else
51
+ # fall back to pusher if no head commit
52
+ payload.fetch('pusher').fetch('name')
53
+ end
49
54
  end
50
55
 
51
56
  def extract_files(payload, state)
@@ -22,7 +22,11 @@ class GithubPayload
22
22
  @result.to_json
23
23
  end
24
24
 
25
- protected
25
+ def merge!(hash)
26
+ @result.merge!(hash)
27
+ end
28
+
29
+ private
26
30
 
27
31
  def digits
28
32
  @@digits ||= ('a'..'f').to_a + ('0'..'9').to_a
@@ -92,6 +96,7 @@ class GithubPushPayload < GithubPayload
92
96
  deleted: false,
93
97
  forced: true,
94
98
  base_ref: nil,
99
+ head_commit: nil,
95
100
  compare: "https://github.com/#{@repo}/commit/#{@after[0..12]}",
96
101
  commits: [],
97
102
  repository: {
@@ -11,44 +11,57 @@ describe PushAttributes do
11
11
  let(:modified) { ['modified_file.txt'] }
12
12
 
13
13
  let(:payload) do
14
- GithubPayloadBuilder.push_payload(repo_name, ref).tap do |payload|
15
- payload.add_commit(added: added, modified: modified)
16
- end
14
+ GithubPayloadBuilder.push_payload(repo_name, ref)
17
15
  end
18
16
 
19
17
  describe '#from_webhook_payload' do
20
18
  let(:attributes) { PushAttributes.from_webhook_payload(payload.to_h) }
21
19
 
22
- it 'pulls out repo name' do
23
- expect(attributes.repo_name).to eq(repo_name)
20
+ it "when no head commit, uses the pusher's name instead" do
21
+ payload.merge!(pusher: { name: 'Fu Barro', email: 'fu@barro.com' })
22
+ expect(attributes.author).to eq('Fu Barro')
24
23
  end
24
+ end
25
25
 
26
- it 'pulls out ref' do
27
- expect(attributes.ref).to eq("refs/#{ref}")
26
+ context 'with a commit added to the payload' do
27
+ before(:each) do
28
+ payload.add_commit(added: added, modified: modified)
28
29
  end
29
30
 
30
- it 'pulls out before sha' do
31
- expect(attributes.before).to eq(payload.to_h['before'])
32
- end
31
+ describe '#from_webhook_payload' do
32
+ let(:attributes) { PushAttributes.from_webhook_payload(payload.to_h) }
33
33
 
34
- it 'pulls out after sha' do
35
- expect(attributes.after).to eq(payload.to_h['after'])
36
- end
34
+ it 'pulls out repo name' do
35
+ expect(attributes.repo_name).to eq(repo_name)
36
+ end
37
37
 
38
- it 'pulls out added files' do
39
- expect(attributes.added_files.to_a).to eq(added)
40
- end
38
+ it 'pulls out ref' do
39
+ expect(attributes.ref).to eq("refs/#{ref}")
40
+ end
41
41
 
42
- it 'pulls out modified files' do
43
- expect(attributes.modified_files.to_a).to eq(modified)
44
- end
42
+ it 'pulls out before sha' do
43
+ expect(attributes.before).to eq(payload.to_h['before'])
44
+ end
45
45
 
46
- it 'combines all files into one handy array' do
47
- expect(attributes.files.sort).to eq((added + modified).sort)
48
- end
46
+ it 'pulls out after sha' do
47
+ expect(attributes.after).to eq(payload.to_h['after'])
48
+ end
49
+
50
+ it 'pulls out added files' do
51
+ expect(attributes.added_files.to_a).to eq(added)
52
+ end
53
+
54
+ it 'pulls out modified files' do
55
+ expect(attributes.modified_files.to_a).to eq(modified)
56
+ end
57
+
58
+ it 'combines all files into one handy array' do
59
+ expect(attributes.files.sort).to eq((added + modified).sort)
60
+ end
49
61
 
50
- it 'pulls out the author' do
51
- expect(attributes.author).to eq('Test User')
62
+ it 'pulls out the author' do
63
+ expect(attributes.author).to eq('Test User')
64
+ end
52
65
  end
53
66
  end
54
67
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: txgh-server
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Jackowski
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-10-04 00:00:00.000000000 Z
12
+ date: 2016-10-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mime-types
@@ -166,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
166
  version: '0'
167
167
  requirements: []
168
168
  rubyforge_project:
169
- rubygems_version: 2.6.6
169
+ rubygems_version: 2.5.1
170
170
  signing_key:
171
171
  specification_version: 4
172
172
  summary: An HTTP server for interacting with txgh.