gitlab_mr_release 1.0.1 → 1.1.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
- SHA1:
3
- metadata.gz: e69b5810bf061f37ae9f366d2d5bb5617db1542f
4
- data.tar.gz: 52c996083b7d9109618d58edbb77ee77a2a85861
2
+ SHA256:
3
+ metadata.gz: 69b7126c1aca9a96bb04c081db7e50c0609a78990d792f55eb1c8cfdc4688d5c
4
+ data.tar.gz: 1033a6b4d36af3ae5e31568b0d88ead48eabc4a38fc40947b29ea249c67c0771
5
5
  SHA512:
6
- metadata.gz: 9664a05defc958d24c6ebd690b4fd875544c58c3082a56a797cbd136874d49cdbd20a6e9b9e53d06bf41e627b300d5abbe0437e28ebb2edd9bd5390a044176fa
7
- data.tar.gz: 4f1e30528718c8cef8bee930c7c50a45e8ea1e1e8ca6e42450a62dc4c2cb969fd812ee39c3bae54b4d89ea26b344f536af4d9b6127fad6403f6d536f32dbb873
6
+ metadata.gz: 5a4d2b7496f4fc07530d91325c4c2134f24040f811ee52f757fee8833434be323e800a578ff55bc677a902ffe35d213fe91decf9382c5fe479e8b3ab898ab2ec
7
+ data.tar.gz: 69d575164e5fed8d72a39b5d0308e359cb8a9dd98cfe0987b6f7646634100821e6c62e38d01cbdea72dd0cc933274a5905870d21f49d13049211b0890c06ebd8
@@ -0,0 +1,107 @@
1
+ name: test
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+ types:
7
+ - opened
8
+ - synchronize
9
+ - reopened
10
+ schedule:
11
+ - cron: "0 10 * * 5" # JST 19:00 (Fri)
12
+
13
+ env:
14
+ CI: "true"
15
+
16
+ jobs:
17
+ test:
18
+ runs-on: ubuntu-latest
19
+
20
+ container: ${{ matrix.ruby }}
21
+
22
+ strategy:
23
+ fail-fast: false
24
+
25
+ matrix:
26
+ ruby:
27
+ - ruby:2.2
28
+ - ruby:2.3
29
+ - ruby:2.4
30
+ - ruby:2.5
31
+ - ruby:2.6
32
+ - ruby:2.7
33
+ - rubylang/ruby:master-nightly-bionic
34
+ include:
35
+ - ruby: rubylang/ruby:master-nightly-bionic
36
+ allow_failures: "true"
37
+
38
+ steps:
39
+ - uses: actions/checkout@v2
40
+
41
+ - name: Cache vendor/bundle
42
+ uses: actions/cache@v1
43
+ id: cache_gem
44
+ with:
45
+ path: vendor/bundle
46
+ key: v1-gem-${{ runner.os }}-${{ matrix.ruby }}-${{ github.sha }}
47
+ restore-keys: |
48
+ v1-gem-${{ runner.os }}-${{ matrix.ruby }}-
49
+ continue-on-error: ${{ matrix.allow_failures == 'true' }}
50
+
51
+ - name: bundle update
52
+ run: |
53
+ set -xe
54
+ bundle config path vendor/bundle
55
+ bundle update --jobs $(nproc) --retry 3
56
+ continue-on-error: ${{ matrix.allow_failures == 'true' }}
57
+
58
+ - name: Setup Code Climate Test Reporter
59
+ uses: aktions/codeclimate-test-reporter@v1
60
+ with:
61
+ codeclimate-test-reporter-id: ${{ secrets.CC_TEST_REPORTER_ID }}
62
+ command: before-build
63
+ if: matrix.ruby >= 'ruby:2.4'
64
+ continue-on-error: true
65
+
66
+ - name: Run test
67
+ run: |
68
+ set -xe
69
+ bundle exec rspec
70
+ continue-on-error: ${{ matrix.allow_failures == 'true' }}
71
+
72
+ - name: Teardown Code Climate Test Reporter
73
+ uses: aktions/codeclimate-test-reporter@v1
74
+ with:
75
+ codeclimate-test-reporter-id: ${{ secrets.CC_TEST_REPORTER_ID }}
76
+ command: after-build
77
+ if: matrix.ruby >= 'ruby:2.4' && always()
78
+ continue-on-error: true
79
+
80
+ - name: Slack Notification (not success)
81
+ uses: homoluctus/slatify@master
82
+ if: "! success()"
83
+ continue-on-error: true
84
+ with:
85
+ job_name: ${{ format('*build* ({0})', matrix.ruby) }}
86
+ type: ${{ job.status }}
87
+ icon_emoji: ":octocat:"
88
+ url: ${{ secrets.SLACK_WEBHOOK }}
89
+ token: ${{ secrets.GITHUB_TOKEN }}
90
+
91
+ notify:
92
+ needs:
93
+ - test
94
+
95
+ runs-on: ubuntu-latest
96
+
97
+ steps:
98
+ - name: Slack Notification (success)
99
+ uses: homoluctus/slatify@master
100
+ if: always()
101
+ continue-on-error: true
102
+ with:
103
+ job_name: '*build*'
104
+ type: ${{ job.status }}
105
+ icon_emoji: ":octocat:"
106
+ url: ${{ secrets.SLACK_WEBHOOK }}
107
+ token: ${{ secrets.GITHUB_TOKEN }}
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  ## Unreleased
2
- [full changelog](http://github.com/sue445/gitlab_mr_release/compare/v1.0.1...master)
2
+ [full changelog](http://github.com/sue445/gitlab_mr_release/compare/v1.1.0...master)
3
+
4
+ ## v1.1.0
5
+ [full changelog](http://github.com/sue445/gitlab_mr_release/compare/v1.0.1...v1.1.0)
6
+
7
+ * Update the release MR when release MR is already exists
8
+ * https://github.com/sue445/gitlab_mr_release/pull/41
3
9
 
4
10
  ## v1.0.1
5
11
  [full changelog](http://github.com/sue445/gitlab_mr_release/compare/v1.0.0...v1.0.1)
data/Gemfile CHANGED
@@ -4,11 +4,26 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  if Gem::Version.create(RUBY_VERSION) < Gem::Version.create("2.2.2")
7
- # NOTE: activesupport 5.x supports only ruby 2.2.2+
8
- gem "activesupport", "< 5.0.0"
7
+ group :development do
8
+ # NOTE: activesupport 5.x supports only ruby 2.2.2+
9
+ gem "activesupport", "< 5.0.0", group: :test
10
+ end
9
11
  end
10
12
 
11
13
  if Gem::Version.create(RUBY_VERSION) < Gem::Version.create("2.2.0")
12
- # NOTE: byebug 9.1.0+ requires ruby 2.2.0+
13
- gem "byebug", "< 9.1.0"
14
+ group :development do
15
+ # NOTE: byebug 9.1.0+ requires ruby 2.2.0+
16
+ gem "byebug", "< 9.1.0", group: :test
17
+ end
18
+ end
19
+
20
+ if Gem::Version.create(RUBY_VERSION) < Gem::Version.create("2.5.0")
21
+ # NOTE: unparser v0.3.0+ requires Ruby 2.5+
22
+ gem "unparser", "< 0.3.0"
23
+ end
24
+
25
+ if Gem::Version.create(RUBY_VERSION) < Gem::Version.create("2.4.0")
26
+ # String#unpack1 is available since ruby 2.4, but gitlab gem uses String#unpack1 ...
27
+ # c.f. https://github.com/NARKOZ/gitlab/commit/d9ef580#diff-84e3ba49bf244c6684f7d26a3312adc4R81
28
+ gem "gitlab", "< 4.14.0"
14
29
  end
data/README.md CHANGED
@@ -3,10 +3,9 @@
3
3
  Release MergeRequest generator for [GitLab](https://about.gitlab.com/)
4
4
 
5
5
  [![Gem Version](https://badge.fury.io/rb/gitlab_mr_release.svg)](https://badge.fury.io/rb/gitlab_mr_release)
6
- [![Build Status](https://travis-ci.org/sue445/gitlab_mr_release.svg?branch=master)](https://travis-ci.org/sue445/gitlab_mr_release)
6
+ [![Build Status](https://github.com/sue445/gitlab_mr_release/workflows/test/badge.svg?branch=master)](https://github.com/sue445/gitlab_mr_release/actions?query=workflow%3Atest)
7
7
  [![Code Climate](https://codeclimate.com/github/sue445/gitlab_mr_release/badges/gpa.svg)](https://codeclimate.com/github/sue445/gitlab_mr_release)
8
8
  [![Coverage Status](https://coveralls.io/repos/sue445/gitlab_mr_release/badge.svg?branch=master&service=github)](https://coveralls.io/github/sue445/gitlab_mr_release?branch=master)
9
- [![Dependency Status](https://gemnasium.com/sue445/gitlab_mr_release.svg)](https://gemnasium.com/sue445/gitlab_mr_release)
10
9
 
11
10
  This is inspired by the [git-pr-release](https://github.com/motemen/git-pr-release)
12
11
 
@@ -24,13 +24,13 @@ Gem::Specification.new do |spec|
24
24
  spec.add_dependency "thor"
25
25
 
26
26
  spec.add_development_dependency "activesupport"
27
- spec.add_development_dependency "bundler", "~> 1.10"
27
+ spec.add_development_dependency "bundler", ">= 1.10"
28
28
  spec.add_development_dependency "coveralls"
29
- spec.add_development_dependency "codeclimate-test-reporter", "~> 1.0.0"
30
29
  spec.add_development_dependency "pry-byebug"
31
- spec.add_development_dependency "rake", "~> 10.0"
30
+ spec.add_development_dependency "rake"
32
31
  spec.add_development_dependency "rspec"
33
32
  spec.add_development_dependency "rspec-parameterized"
34
33
  spec.add_development_dependency "simplecov"
34
+ spec.add_development_dependency "unparser", ">= 0.4.5"
35
35
  spec.add_development_dependency "webmock", ">= 3.0.0"
36
36
  end
@@ -78,60 +78,62 @@ MergeRequest is created
78
78
 
79
79
  private
80
80
 
81
- def assert_env(name)
82
- if !ENV[name] || ENV[name].empty?
83
- puts "Error: Environment variable #{name} is required"
84
- exit!
81
+ no_commands do
82
+ def assert_env(name)
83
+ if !ENV[name] || ENV[name].empty?
84
+ puts "Error: Environment variable #{name} is required"
85
+ exit!
86
+ end
85
87
  end
86
- end
87
88
 
88
- def assert_option_or_env(option_name, env_name)
89
- option_or_env!(option_name, env_name)
90
- end
89
+ def assert_option_or_env(option_name, env_name)
90
+ option_or_env!(option_name, env_name)
91
+ end
91
92
 
92
- def generate_title
93
- return options[:title] if options[:title]
93
+ def generate_title
94
+ return options[:title] if options[:title]
94
95
 
95
- generate_default_title(
96
- title_template: ENV["DEFAULT_TITLE"],
97
- source_branch: source_branch,
98
- target_branch: target_branch,
99
- )
100
- end
96
+ generate_default_title(
97
+ title_template: ENV["DEFAULT_TITLE"],
98
+ source_branch: source_branch,
99
+ target_branch: target_branch,
100
+ )
101
+ end
101
102
 
102
- def generate_default_title(title_template:, source_branch:, target_branch:)
103
- title_template ||= DEFAULT_TITLE_TEMPLATE
104
- ERB.new(title_template).result(binding).strip
105
- end
103
+ def generate_default_title(title_template:, source_branch:, target_branch:)
104
+ title_template ||= DEFAULT_TITLE_TEMPLATE
105
+ ERB.new(title_template).result(binding).strip
106
+ end
106
107
 
107
- def template_file
108
- ENV["TEMPLATE_FILE"] || "#{__dir__}/../templates/gitlab_mr_release.md.erb"
109
- end
108
+ def template_file
109
+ ENV["TEMPLATE_FILE"] || "#{__dir__}/../templates/gitlab_mr_release.md.erb"
110
+ end
110
111
 
111
- def source_branch
112
- option_or_env(:source, "DEFAULT_SOURCE_BRANCH")
113
- end
112
+ def source_branch
113
+ option_or_env(:source, "DEFAULT_SOURCE_BRANCH")
114
+ end
114
115
 
115
- def target_branch
116
- option_or_env(:target, "DEFAULT_TARGET_BRANCH")
117
- end
116
+ def target_branch
117
+ option_or_env(:target, "DEFAULT_TARGET_BRANCH")
118
+ end
118
119
 
119
- def labels
120
- option_or_env(:labels, "DEFAULT_LABELS")
121
- end
120
+ def labels
121
+ option_or_env(:labels, "DEFAULT_LABELS")
122
+ end
122
123
 
123
- def option_or_env(option_name, env_name, default = nil)
124
- return options[option_name] if options[option_name] && !options[option_name].empty?
125
- return ENV[env_name] if ENV[env_name] && !ENV[env_name].empty?
126
- default
127
- end
124
+ def option_or_env(option_name, env_name, default = nil)
125
+ return options[option_name] if options[option_name] && !options[option_name].empty?
126
+ return ENV[env_name] if ENV[env_name] && !ENV[env_name].empty?
127
+ default
128
+ end
128
129
 
129
- def option_or_env!(option_name, env_name)
130
- value = option_or_env(option_name, env_name)
131
- return value if value
130
+ def option_or_env!(option_name, env_name)
131
+ value = option_or_env(option_name, env_name)
132
+ return value if value
132
133
 
133
- puts "Error: --#{option_name} or #{env_name} is either required!"
134
- exit!
134
+ puts "Error: --#{option_name} or #{env_name} is either required!"
135
+ exit!
136
+ end
135
137
  end
136
138
  end
137
139
  end
@@ -42,13 +42,31 @@ module GitlabMrRelease
42
42
 
43
43
  def create_merge_request(source_branch:, target_branch:, title:, template:, labels:)
44
44
  iids = merge_request_iids_between(target_branch, source_branch)
45
- options = {
46
- source_branch: source_branch,
47
- target_branch: target_branch,
48
- description: generate_description(iids, template),
49
- labels: labels,
50
- }
51
- Gitlab.create_merge_request(@project_name, title, options)
45
+ description = generate_description(iids, template)
46
+
47
+ mr = find_current_release_mr(source_branch, target_branch)
48
+ if mr.nil?
49
+ options = {
50
+ source_branch: source_branch,
51
+ target_branch: target_branch,
52
+ description: description,
53
+ labels: labels,
54
+ }
55
+ Gitlab.create_merge_request(@project_name, title, options)
56
+ else
57
+ options = {
58
+ title: title,
59
+ description: description
60
+ }
61
+ Gitlab.update_merge_request(@project_name, mr.iid, options)
62
+ end
63
+ end
64
+
65
+ # find release mr already exists
66
+ def find_current_release_mr(source_branch, target_branch)
67
+ Gitlab.merge_requests(@project_name, state: :opened).find do |mr|
68
+ mr.source_branch == source_branch && mr.target_branch == target_branch
69
+ end
52
70
  end
53
71
  end
54
72
  end
@@ -1,3 +1,3 @@
1
1
  module GitlabMrRelease
2
- VERSION = "1.0.1"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab_mr_release
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - sue445
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-12-19 00:00:00.000000000 Z
11
+ date: 2020-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dotenv
@@ -70,14 +70,14 @@ dependencies:
70
70
  name: bundler
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '1.10'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '1.10'
83
83
  - !ruby/object:Gem::Dependency
@@ -95,21 +95,21 @@ dependencies:
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: codeclimate-test-reporter
98
+ name: pry-byebug
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - "~>"
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
- version: 1.0.0
103
+ version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - "~>"
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
- version: 1.0.0
110
+ version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
- name: pry-byebug
112
+ name: rake
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - ">="
@@ -123,21 +123,21 @@ dependencies:
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
- name: rake
126
+ name: rspec
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - "~>"
129
+ - - ">="
130
130
  - !ruby/object:Gem::Version
131
- version: '10.0'
131
+ version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - "~>"
136
+ - - ">="
137
137
  - !ruby/object:Gem::Version
138
- version: '10.0'
138
+ version: '0'
139
139
  - !ruby/object:Gem::Dependency
140
- name: rspec
140
+ name: rspec-parameterized
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - ">="
@@ -151,7 +151,7 @@ dependencies:
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  - !ruby/object:Gem::Dependency
154
- name: rspec-parameterized
154
+ name: simplecov
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
157
  - - ">="
@@ -165,19 +165,19 @@ dependencies:
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
167
  - !ruby/object:Gem::Dependency
168
- name: simplecov
168
+ name: unparser
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
171
  - - ">="
172
172
  - !ruby/object:Gem::Version
173
- version: '0'
173
+ version: 0.4.5
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - ">="
179
179
  - !ruby/object:Gem::Version
180
- version: '0'
180
+ version: 0.4.5
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: webmock
183
183
  requirement: !ruby/object:Gem::Requirement
@@ -202,9 +202,9 @@ extra_rdoc_files: []
202
202
  files:
203
203
  - ".coveralls.yml"
204
204
  - ".env.gitlab.example"
205
+ - ".github/workflows/test.yml"
205
206
  - ".gitignore"
206
207
  - ".rspec"
207
- - ".travis.yml"
208
208
  - CHANGELOG.md
209
209
  - Gemfile
210
210
  - LICENSE.txt
@@ -240,8 +240,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
240
240
  - !ruby/object:Gem::Version
241
241
  version: '0'
242
242
  requirements: []
243
- rubyforge_project:
244
- rubygems_version: 2.6.11
243
+ rubygems_version: 3.1.2
245
244
  signing_key:
246
245
  specification_version: 4
247
246
  summary: Release MergeRequest generator for GitLab
data/.travis.yml DELETED
@@ -1,26 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.1
4
- - 2.2.5
5
- - 2.3.1
6
- - 2.4.1
7
- - ruby-head
8
- cache: bundler
9
- sudo: false
10
- before_install: gem install bundler -v 1.10.6
11
- before_script:
12
- - export CODECLIMATE_REPO_TOKEN=771643fe0b3a3f2185eacf5fb025ec009d40cab4402d97b83ece04436e5e1739
13
- - export CI=true
14
- script:
15
- - bundle exec rspec
16
- - bundle exec codeclimate-test-reporter
17
- branches:
18
- only:
19
- - master
20
- notifications:
21
- email: false
22
- slack:
23
- secure: dkjEtoWyHEstKewrX6InD/wym1hmUZMdr/JfSP2HJLWS5U4mWyq8UY3ulvRWgoElKFhEUtQYYTzAp0BwoM4pQ9VdXX+tR0wIg6ETte2uP/ETTv/bZLbCm6ZfD0pk86Wq5NJVAVskwjZcxL3GKYVJz5kru83h7yGGHJ2oxB0ClZLK0DPJSReC7fItzcKHiz0LQe1P26BqOSeRIzTLiJldNiu/tCQyZxN8m5rRiaDfsWxeH0oRnz0VCY8L3ZU0ji5qTXZeE89o+TikL4fNri78bziDRXOiC+PGAsr03F8fNCja6UgofNSRsVkpjkbQhyBnjQJnU4aVzRIOcZDcRXXRvk/VNfvxiodZ8EpEwn9qkjx71rfklTyOj2HMNpuWLeNfFkdnh2qaVOfKAQ/hW0wfStn2Pcxm1mBV0bAFQuon2mXcj+vUYrXo9iHslXlzO6nf/wQR7R6rvqJGgmjSpVomehoR5EllD6AmhaWyboh0i0Kyr6INKzvLtV4bHqaYlZXD931gRXGW0PWHrX8KvXAtYVngjmouJ8Jqu5PdJm2nH0OQMHfwxWbh991gGG76UIga4Pfou+XSxTji3G3T0D1btHvMLpNvx6rfeL+cPXq5LGc2UVf9QEwEwJyKB/i2XjXUNQE4X5yl+rfgky9dWOBu+D8yYxnoUoKYfo1uOg/kns8=
24
- matrix:
25
- allow_failures:
26
- - rvm: ruby-head