git-pr-release 1.2.0 → 1.7.0

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
  SHA256:
3
- metadata.gz: c62affe0022fbc68eb4fb5d6f3ac2ad27c6bb37779c2977619ac7636bfed8340
4
- data.tar.gz: 66793e7118f37575b3121ca87c5575322a1b7ec406e94c929165bce4698fdc4c
3
+ metadata.gz: 50f0bc6156728f1409b494f7d58c93574f8d022c452e935e245c8c36fa083e02
4
+ data.tar.gz: bc9a65dc34ac07b069885daaea51e81082045da6a5d152d10bafaea3e4dc2ca4
5
5
  SHA512:
6
- metadata.gz: 6b89116177f0b77ff0ac6aec85b123117cf1aedc84843581e88d84d54106a3cc2f5c400ad072976c4764691336947f6c036b8bc01454929f64dcb6bf0028a2b2
7
- data.tar.gz: 3e31b988775f96af5f619f23cb28ce29a5096ad8a785b7e592f8241c40e0326c24abbd6ae50114934c53fda97fbc164477cdc52e97fb07cc690a633638895530
6
+ metadata.gz: 56c638066c3cca4b0732bb2ac8ec86139d18ba3ef5c9d1ee05f112b737e996395171f6c3998ffa82532fe7de457f7cad754f6efd6a023eb808d7c64aa9f54190
7
+ data.tar.gz: b80feeefd29cf5326b7cb83fcb7a2d6c52e0ec3a63aa7a068a1a335f21180c515d75f7f64000c63fb363b11dea21f6dacc60e2959a331ebf76b9cbb8410b0271
data/CHANGELOG.md CHANGED
@@ -1,8 +1,43 @@
1
1
  # git-pr-release
2
2
 
3
+ ## v1.7.0 (2021-05-24)
4
+
5
+ [full changelog](https://github.com/x-motemen/git-pr-release/compare/v1.6.0...v1.7.0)
6
+
7
+ * (#64) fix wrong pr number due to sleep (@mpon)
8
+
9
+ ## v1.6.0 (2021-05-15)
10
+
11
+ [full changelog](https://github.com/x-motemen/git-pr-release/compare/v1.5.0...v1.6.0)
12
+
13
+ * (#63) Sort merged_pull_request_numbers numerically by default (@yutailang0119)
14
+
15
+ ## v1.5.0 (2021-04-02)
16
+
17
+ [full changelog](https://github.com/x-motemen/git-pr-release/compare/v1.4.0...v1.5.0)
18
+
19
+ * (#60, #61) Get issue number from GitHub API for squashed PR (@yuuan)
20
+ * (#58) Make stable test (@kachick)
21
+ * (#55) Suppress warning for ERB (@ohbarye)
22
+ * (#50) support `GIT_PR_RELEASE_MENTION` environment variable (@dabutvin)
23
+ * (#49) Transfer repository to x-motemen organization (@onk)
24
+
25
+ ## v1.4.0 (2020-02-22)
26
+
27
+ [full changelog](https://github.com/x-motemen/git-pr-release/compare/v1.3.0...v1.4.0)
28
+
29
+ * (#48) List PR API needs head user or head organization and branch name (@sasasin)
30
+
31
+ ## v1.3.0 (2020-02-19)
32
+
33
+ [full changelog](https://github.com/x-motemen/git-pr-release/compare/v1.2.0...v1.3.0)
34
+
35
+ * (#47) Fix Errno::ENOENT when finding the specified template (@onk)
36
+ * (#45) Fix "warning: instance variable @xxx not initialized" (@onk)
37
+
3
38
  ## v1.2.0 (2020-02-07)
4
39
 
5
- [full changelog](https://github.com/motemen/git-pr-release/compare/v1.1.0...v1.2.0)
40
+ [full changelog](https://github.com/x-motemen/git-pr-release/compare/v1.1.0...v1.2.0)
6
41
 
7
42
  * (#44) Use API option when detecting existing release PR (@onk)
8
43
  * (#41, #42) Refactor (@onk)
@@ -10,13 +45,13 @@
10
45
 
11
46
  ## v1.1.0 (2020-01-02)
12
47
 
13
- [full changelog](https://github.com/motemen/git-pr-release/compare/v1.0.1...v1.1.0)
48
+ [full changelog](https://github.com/x-motemen/git-pr-release/compare/v1.0.1...v1.1.0)
14
49
 
15
50
  * (#38) Fetch changed files as many as possible (@shibayu36)
16
51
 
17
52
  ## v1.0.1 (2019-12-17)
18
53
 
19
- [full changelog](https://github.com/motemen/git-pr-release/compare/v1.0.0...v1.0.1)
54
+ [full changelog](https://github.com/x-motemen/git-pr-release/compare/v1.0.0...v1.0.1)
20
55
 
21
56
  * (#37) Fix NameError (@onk)
22
57
 
data/README.md CHANGED
@@ -75,6 +75,15 @@ You can specify this value by `GIT_PR_RELEASE_LABELS` environment variable.
75
75
 
76
76
  If not specified, any labels will not be added for PRs.
77
77
 
78
+ ### `pr-release.mention`
79
+
80
+ The name that is listed next to each PR title.
81
+ Accepted values: `author`
82
+
83
+ You can specify this value by `GIT_PR_RELEASE_MENTION` environment variable.
84
+
85
+ If not specified, the mention will be the PR assignee
86
+
78
87
 
79
88
  Errors and exit statuses
80
89
  ------------------------
@@ -4,12 +4,12 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "git-pr-release"
7
- spec.version = '1.2.0'
7
+ spec.version = '1.7.0'
8
8
  spec.authors = ["motemen"]
9
9
  spec.email = ["motemen@gmail.com"]
10
10
  spec.summary = 'Creates a release pull request'
11
11
  spec.description = 'git-pr-release creates a pull request which summarizes feature branches that are to be released into production'
12
- spec.homepage = 'https://github.com/motemen/git-pr-release'
12
+ spec.homepage = 'https://github.com/x-motemen/git-pr-release'
13
13
 
14
14
  spec.files = `git ls-files`.split($/)
15
15
  spec.bindir = "exe"
@@ -13,6 +13,13 @@ module Git
13
13
  exit result
14
14
  end
15
15
 
16
+ def initialize
17
+ @dry_run = false
18
+ @json = false
19
+ @no_fetch = false
20
+ @squashed = false
21
+ end
22
+
16
23
  def start
17
24
  OptionParser.new do |opts|
18
25
  opts.on('-n', '--dry-run', 'Do not create/update a PR. Just prints out') do |v|
@@ -24,6 +31,9 @@ module Git
24
31
  opts.on('--no-fetch', 'Do not fetch from remote repo before determining target PRs (CI friendly)') do |v|
25
32
  @no_fetch = v
26
33
  end
34
+ opts.on('--squashed', 'Handle squash merged PRs') do |v|
35
+ @squashed = v
36
+ end
27
37
  end.parse!
28
38
 
29
39
  ### Set up configuration
@@ -75,14 +85,24 @@ module Git
75
85
  def fetch_merged_prs
76
86
  git :remote, 'update', 'origin' unless @no_fetch
77
87
 
78
- merged_feature_head_sha1s = git(
79
- :log, '--merges', '--pretty=format:%P', "origin/#{production_branch}..origin/#{staging_branch}"
80
- ).map do |line|
88
+ merged_pull_request_numbers = @squashed ? fetch_merged_pr_numbers_from_github : fetch_merged_pr_numbers_from_git_remote
89
+
90
+ merged_prs = merged_pull_request_numbers.sort.map do |nr|
91
+ pr = client.pull_request repository, nr
92
+ say "To be released: ##{pr.number} #{pr.title}", :notice
93
+ pr
94
+ end
95
+
96
+ merged_prs
97
+ end
98
+
99
+ def fetch_merged_pr_numbers_from_git_remote
100
+ merged_feature_head_sha1s = git(:log, '--merges', '--pretty=format:%P', "origin/#{production_branch}..origin/#{staging_branch}").map do |line|
81
101
  main_sha1, feature_sha1 = line.chomp.split /\s+/
82
102
  feature_sha1
83
103
  end
84
104
 
85
- merged_pull_request_numbers = git('ls-remote', 'origin', 'refs/pull/*/head').map do |line|
105
+ git('ls-remote', 'origin', 'refs/pull/*/head').map do |line|
86
106
  sha1, ref = line.chomp.split /\s+/
87
107
 
88
108
  if merged_feature_head_sha1s.include? sha1
@@ -100,14 +120,13 @@ module Git
100
120
  end
101
121
  end
102
122
  end.compact
123
+ end
103
124
 
104
- merged_prs = merged_pull_request_numbers.map do |nr|
105
- pr = client.pull_request repository, nr
106
- say "To be released: ##{pr.number} #{pr.title}", :notice
107
- pr
108
- end
109
-
110
- merged_prs
125
+ def fetch_merged_pr_numbers_from_github
126
+ git(:log, '--pretty=format:%H', "origin/#{production_branch}..origin/#{staging_branch}").map(&:chomp).map do |sha1|
127
+ sleep 1
128
+ client.search_issues("repo:#{repository} is:pr is:closed #{sha1}")[:items].map(&:number)
129
+ end.flatten
111
130
  end
112
131
 
113
132
  def create_release_pr(merged_prs)
@@ -145,7 +164,8 @@ module Git
145
164
 
146
165
  def detect_existing_release_pr
147
166
  say 'Searching for existing release pull requests...', :info
148
- client.pull_requests(repository, head: staging_branch, base: production_branch).first
167
+ user=repository.split("/")[0]
168
+ client.pull_requests(repository, head: "#{user}:#{staging_branch}", base: production_branch).first
149
169
  end
150
170
 
151
171
  def prepare_release_pr
@@ -34,7 +34,7 @@ module Git
34
34
  end
35
35
 
36
36
  def self.mention_type
37
- @mention_type ||= (git_config('mention') || 'default')
37
+ @mention_type ||= (ENV.fetch('GIT_PR_RELEASE_MENTION') { git_config('mention') } || 'default')
38
38
  end
39
39
  end
40
40
  end
@@ -89,12 +89,16 @@ ERB
89
89
 
90
90
  template = if template_path
91
91
  template_fullpath = File.join(git('rev-parse', '--show-toplevel').first.chomp, template_path)
92
- File.read(template_path)
92
+ File.read(template_fullpath)
93
93
  else
94
94
  DEFAULT_PR_TEMPLATE
95
95
  end
96
96
 
97
- erb = ERB.new template, nil, '-'
97
+ erb = if RUBY_VERSION >= '2.6'
98
+ ERB.new template, trim_mode: '-'
99
+ else
100
+ ERB.new template, nil, '-'
101
+ end
98
102
  content = erb.result binding
99
103
  content.split(/\n/, 2)
100
104
  end
data/spec/spec_helper.rb CHANGED
@@ -19,6 +19,15 @@ RSpec.configure do |config|
19
19
  config.order = :random
20
20
  Kernel.srand config.seed
21
21
 
22
+ config.around(:each) do |example|
23
+ begin
24
+ ENV['TZ'], old = 'Asia/Tokyo', ENV['TZ']
25
+ example.run
26
+ ensure
27
+ ENV['TZ'] = old
28
+ end
29
+ end
30
+
22
31
  config.after do
23
32
  Timecop.return
24
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-pr-release
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - motemen
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-02-06 00:00:00.000000000 Z
11
+ date: 2021-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octokit
@@ -143,11 +143,11 @@ files:
143
143
  - spec/spec_helper.rb
144
144
  - spec/support/capture_support.rb
145
145
  - spec/support/file_fixture_support.rb
146
- homepage: https://github.com/motemen/git-pr-release
146
+ homepage: https://github.com/x-motemen/git-pr-release
147
147
  licenses:
148
148
  - MIT
149
149
  metadata: {}
150
- post_install_message:
150
+ post_install_message:
151
151
  rdoc_options: []
152
152
  require_paths:
153
153
  - lib
@@ -162,8 +162,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
162
162
  - !ruby/object:Gem::Version
163
163
  version: '0'
164
164
  requirements: []
165
- rubygems_version: 3.1.2
166
- signing_key:
165
+ rubygems_version: 3.3.0.dev
166
+ signing_key:
167
167
  specification_version: 4
168
168
  summary: Creates a release pull request
169
169
  test_files: