socialcast-git-extensions 4.1.3 → 4.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f505bfd44845962283348e9f86c4bdf32fe13909
4
- data.tar.gz: 751be9171dbb1746af72a7b09862b5431921d980
3
+ metadata.gz: f6df565ab7992070e2b73ec347a44c2f25bf2838
4
+ data.tar.gz: ac2cfdc3044973c434d7d3ec803e875d9eec9c34
5
5
  SHA512:
6
- metadata.gz: e4d63a034d7da66a1bd0b0783d1092fc4b23a95928d7661d9b5064cb40737989875bad32059cbdc43d5f484bdd766617b8a0def926f34ca13705311cedd0248c
7
- data.tar.gz: 839e0b8fb1c1fa61032b1a3736f02bd50f1ea213650bd0487169678fcb6da4a132d29be698148b94376fa2061e65a22b98b29a632874b0190ac130ffb5f71293
6
+ metadata.gz: 976edeb8500ab67b7d6789cc454017e0867f980ee012686be02b48f2587e82f071c0699d4ac4a4d9d71925090822ba767d12fbaf61e6c7d62c3648b62d4395f4
7
+ data.tar.gz: 51db07e95b22c332e1599c7744c1aed17fd2eeeca66c74454fcb73a137ee311759d1c72b45ba277ac3d6aa9066af5094428eb4bd396ab3fa902ff747a33095df
@@ -128,13 +128,24 @@ module Socialcast
128
128
  socialcast_reviewer = socialcast_track_reviewer('Backport')
129
129
 
130
130
  pull_request_data = github_api_request('GET', "repos/#{repo}/pulls/#{pull_request_num}")
131
- commits_data = github_api_request('GET', pull_request_data['commits_url'])
132
131
 
133
- non_merge_commits_data = commits_data.select { |commit_data| commit_data['parents'].length == 1 }
134
- shas = non_merge_commits_data.map { |commit| commit['sha'] }
132
+ commits_to_cherry_pick = []
133
+ commit_count = pull_request_data['commits']
134
+ commits_checked_count = 0
135
+ page = 1
136
+
137
+ while commits_checked_count < commit_count
138
+ commits_data = github_api_request('GET', pull_request_data['commits_url'] + "?page=#{page}")
139
+ commits_checked_count += commits_data.size
140
+ raise 'Received empty commits data response! Could not pull all commits from PR' if commits_data.size == 0
141
+
142
+ non_merge_commits_data = commits_data.select { |commit_data| commit_data['parents'].length == 1 }
143
+ commits_to_cherry_pick += non_merge_commits_data.map { |commit| commit['sha'] }
144
+ page += 1
145
+ end
135
146
 
136
147
  backport_branch = "backport_#{pull_request_num}_to_#{maintenance_branch}"
137
- backport_to(backport_branch, shas)
148
+ backport_to(backport_branch, commits_to_cherry_pick)
138
149
 
139
150
  maintenance_branch_url = "https://github.com/#{repo}/tree/#{maintenance_branch}"
140
151
  description = "Backport ##{pull_request_num} to #{maintenance_branch_url}\n***\n#{pull_request_data['body']}"
@@ -1,5 +1,5 @@
1
1
  module Socialcast
2
2
  module Gitx
3
- VERSION = "4.1.3"
3
+ VERSION = "4.1.4"
4
4
  end
5
5
  end
@@ -971,7 +971,7 @@ describe Socialcast::Gitx::CLI do
971
971
  .to_return(:status => 200, :body => pr_response.to_json, :headers => {})
972
972
  end
973
973
  let!(:github_pr_commits_list) do
974
- stub_request(:get, "https://api.github.com/repos/socialcast/socialcast-git-extensions/pulls/59/commits")
974
+ stub_request(:get, "https://api.github.com/repos/socialcast/socialcast-git-extensions/pulls/59/commits?page=1")
975
975
  .to_return(:status => 200, :body => commits_response.to_json, :headers => {})
976
976
  end
977
977
  let!(:github_pr_create) do
@@ -1056,6 +1056,90 @@ describe Socialcast::Gitx::CLI do
1056
1056
  expect(socialcast_message_create).to_not have_been_requested
1057
1057
  end
1058
1058
  end
1059
+ context 'when backport has multiple pages of commits' do
1060
+ let(:pr_response) do
1061
+ # https://developer.github.com/v3/search/#search-issues
1062
+ {
1063
+ "url" => "https://api.github.com/repos/socialcast/socialcast-git-extensions/pulls/59",
1064
+ "id" => 13712197,
1065
+ "html_url" => "https://github.com/socialcast/socialcast-git-extensions/pull/59",
1066
+ "diff_url" => "https://github.com/socialcast/socialcast-git-extensions/pull/59.diff",
1067
+ "patch_url" => "https://github.com/socialcast/socialcast-git-extensions/pull/59.patch",
1068
+ "issue_url" => "https://api.github.com/repos/socialcast/socialcast-git-extensions/issues/59",
1069
+ "number" => 59,
1070
+ "state" => "closed",
1071
+ "title" => "additional-notifications",
1072
+ "body" => "simply testing this out",
1073
+ "created_at" => "2014-03-18T22:39:37Z",
1074
+ "updated_at" => "2014-03-18T22:40:18Z",
1075
+ "closed_at" => "2014-03-18T22:39:46Z",
1076
+ "merged_at" => nil,
1077
+ "merge_commit_sha" => "f73009f4eb245c84da90e8abf9be846c58bc1e3b",
1078
+ "assignee" => nil,
1079
+ "milestone" => nil,
1080
+ "commits_url" => "https://api.github.com/repos/socialcast/socialcast-git-extensions/pulls/59/commits",
1081
+ "review_comments_url" => "https://api.github.com/repos/socialcast/socialcast-git-extensions/pulls/59/comments",
1082
+ "review_comment_url" => "https://api.github.com/repos/socialcast/socialcast-git-extensions/pulls/comments/{number}",
1083
+ "comments_url" => "https://api.github.com/repos/socialcast/socialcast-git-extensions/issues/59/comments",
1084
+ "statuses_url" => "https://api.github.com/repos/socialcast/socialcast-git-extensions/statuses/5e30d5af3f4d1bb3a34cc97568299be028b65f6f",
1085
+ "commits" => 2,
1086
+ }
1087
+ end
1088
+ let(:commits_response) do
1089
+ [
1090
+ {
1091
+ "sha" => "5e30d5af3f4d1bb3a34cc97568299be028b65f6f",
1092
+ "commit" => {
1093
+ "message" => "adding the ability to specify additional reviewers"
1094
+ },
1095
+ "url" => "https://api.github.com/repos/socialcast/socialcast-git-extensions/commits/5e30d5af3f4d1bb3a34cc97568299be028b65f6f",
1096
+ "parents" => [
1097
+ {
1098
+ "sha" => "1baae2de301c43d44297647f3f9c1e06697748ad",
1099
+ "url" => "https://api.github.com/repos/socialcast/socialcast-git-extensions/commits/1baae2de301c43d44297647f3f9c1e06697748ad",
1100
+ "html_url" => "https://github.com/socialcast/socialcast-git-extensions/commit/1baae2de301c43d44297647f3f9c1e06697748ad"
1101
+ }
1102
+ ]
1103
+ }
1104
+ ]
1105
+ end
1106
+
1107
+ let(:commits_response2) do
1108
+ [
1109
+ {
1110
+ "sha" => "5e30d5af3f4d1bb3a34cc97568299be028b65f6d",
1111
+ "commit" => {
1112
+ "message" => "adding the ability to specify additional reviewers"
1113
+ },
1114
+ "url" => "https://api.github.com/repos/socialcast/socialcast-git-extensions/commits/5e30d5af3f4d1bb3a34cc97568299be028b65f6d",
1115
+ "parents" => [
1116
+ {
1117
+ "sha" => "5e30d5af3f4d1bb3a34cc97568299be028b65f6f",
1118
+ "url" => "https://api.github.com/repos/socialcast/socialcast-git-extensions/commits/5e30d5af3f4d1bb3a34cc97568299be028b65f6f",
1119
+ "html_url" => "https://github.com/socialcast/socialcast-git-extensions/commit/5e30d5af3f4d1bb3a34cc97568299be028b65f6f"
1120
+ }
1121
+ ]
1122
+ }
1123
+ ]
1124
+ end
1125
+
1126
+ let!(:github_pr_commits_list2) do
1127
+ stub_request(:get, "https://api.github.com/repos/socialcast/socialcast-git-extensions/pulls/59/commits?page=2")
1128
+ .to_return(:status => 200, :body => commits_response2.to_json, :headers => {})
1129
+ end
1130
+ let(:use_pr_comments) { true }
1131
+ it 'creates a branch based on v1.x and cherry-picks in PR 59' do
1132
+ Socialcast::Gitx::CLI.start ['backportpr', '59', 'v1.x']
1133
+ expect(github_pr_show).to have_been_requested
1134
+ expect(github_pr_commits_list).to have_been_requested
1135
+ expect(github_pr_commits_list2).to have_been_requested
1136
+ expect(github_pr_create).to have_been_requested
1137
+
1138
+ expect(github_pr_comment_create).to have_been_requested
1139
+ expect(socialcast_message_create).to_not have_been_requested
1140
+ end
1141
+ end
1142
+
1059
1143
  end
1060
1144
 
1061
1145
  describe '#findpr' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: socialcast-git-extensions
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.3
4
+ version: 4.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Socialcast
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-28 00:00:00.000000000 Z
11
+ date: 2017-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rugged
@@ -212,6 +212,7 @@ files:
212
212
  - lib/socialcast-git-extensions/highline.rb
213
213
  - lib/socialcast-git-extensions/string_ext.rb
214
214
  - lib/socialcast-git-extensions/version.rb
215
+ - socialcast-git-extensions-4.1.3.gem
215
216
  - socialcast-git-extensions.gemspec
216
217
  - spec/cli_spec.rb
217
218
  - spec/git_spec.rb
@@ -236,7 +237,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
236
237
  version: '0'
237
238
  requirements: []
238
239
  rubyforge_project: socialcast-git-extensions
239
- rubygems_version: 2.4.8
240
+ rubygems_version: 2.6.12
240
241
  signing_key:
241
242
  specification_version: 4
242
243
  summary: git extension scripts for socialcast workflow