gitlab_mr_release 0.2.0 → 0.3.0.beta1

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: 61e097e8b3a6fa3ce74183de3146060ca452dc4d
4
- data.tar.gz: b773591304833694146b9e60de9a09ad37eb19be
3
+ metadata.gz: dfd1bd012a6623b07ec88422301e7a903bd27e52
4
+ data.tar.gz: c210cb149e78a9633a35a6e99a4a88f2058bc40f
5
5
  SHA512:
6
- metadata.gz: 813dcb7a7f0cfc50f5df943e98eb46c5046f41f4ef89fe0f5fa361a24e831e33397f204b1b65831547fc9bc65a2fb37740b0b55c804102df07d77d1c765cd868
7
- data.tar.gz: 50512479fd6a58bf347b3924241d1b9803af96fb3d50fc95ffa0613161130c27b4863c5129e31fe39e73455e87df0fc5c60f8b10277043177eaad1fdc88a8598
6
+ metadata.gz: b0f883786063a983f7d1e822fa40845835a19b00b71439835ee34c60049f1639e8523fd7928abf06aaa8d2e55a8397b3bd537eb491d1a7bfca5f32b9876e62c6
7
+ data.tar.gz: f9babb8178923687b0f47b7d5ca066f5efc0bdd04d25b84e86fd2d9450103095c3ce702f40c6ac07a0bfca086c1d5cc6426b425c7c60dd99e7a4ced9d21ecf0a
data/.travis.yml CHANGED
@@ -1,8 +1,8 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 2.1
4
- - 2.2
5
- - 2.3
4
+ - 2.2.5
5
+ - 2.3.1
6
6
  - ruby-head
7
7
  cache: bundler
8
8
  sudo: false
@@ -22,4 +22,3 @@ notifications:
22
22
  matrix:
23
23
  allow_failures:
24
24
  - rvm: ruby-head
25
- - rvm: 2.3
data/CHANGELOG.md CHANGED
@@ -1,14 +1,19 @@
1
1
  ## Unreleased
2
- [full changelog](http://github.com/sue445/rubicure/compare/v0.2.0...master)
2
+ [full changelog](http://github.com/sue445/gitlab_mr_release/compare/v0.2.0...master)
3
+
4
+ * Support MR labels
5
+ * https://github.com/sue445/gitlab_mr_release/pull/13
6
+ * Support default params in .env.gitlab
7
+ * https://github.com/sue445/gitlab_mr_release/pull/14
3
8
 
4
9
  ## v0.2.0
5
- [full changelog](http://github.com/sue445/rubicure/compare/v0.1.1...v0.2.0)
10
+ [full changelog](http://github.com/sue445/gitlab_mr_release/compare/v0.1.1...v0.2.0)
6
11
 
7
12
  * Support `DEFAULT_TITLE` with erb
8
13
  * https://github.com/sue445/gitlab_mr_release/pull/11
9
14
 
10
15
  ## v0.1.1
11
- [full changelog](http://github.com/sue445/rubicure/compare/v0.1.0...v0.1.1)
16
+ [full changelog](http://github.com/sue445/gitlab_mr_release/compare/v0.1.0...v0.1.1)
12
17
 
13
18
  * Enable ERB trim_mode `"-"` (i.g. `<%-` , `-%>`) and tweak default template #10
14
19
  * https://github.com/sue445/gitlab_mr_release/pull/10
data/Gemfile CHANGED
@@ -2,3 +2,8 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in gitlab_mr_release.gemspec
4
4
  gemspec
5
+
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"
9
+ end
data/README.md CHANGED
@@ -32,9 +32,11 @@ $ gitlab_mr_release init
32
32
  create gitlab_mr_release.md.erb
33
33
  ```
34
34
 
35
+ see [lib/templates/](lib/templates/)
36
+
35
37
  ### create
36
38
  ```sh
37
- $ gitlab_mr_release create --source=develop --target=master
39
+ $ gitlab_mr_release create --source=develop --target=master --labels=release
38
40
  MergeRequest is created
39
41
 
40
42
  [Title] Release develop -> master
@@ -56,12 +58,13 @@ detail
56
58
  ```sh
57
59
  $ gitlab_mr_release help create
58
60
  Usage:
59
- gitlab_mr_release create -s, --source=SOURCE -t, --target=TARGET
61
+ gitlab_mr_release create
60
62
 
61
63
  Options:
62
- -s, --source=SOURCE # Source branch (e.g. develop)
63
- -t, --target=TARGET # Target branch (e.g. master)
64
- [--title=TITLE] # MergeRequest title (default. 'Release :source -> :target')
64
+ -s, [--source=SOURCE] # Source branch (e.g. develop)
65
+ -t, [--target=TARGET] # Target branch (e.g. master)
66
+ [--title=TITLE] # MergeRequest title (default. 'Release :source -> :target')
67
+ -l, [--labels=LABELS] # Labels for MR as a comma-separated list (e.g. 'label1,label2')
65
68
 
66
69
  Create merge requrst
67
70
  ```
@@ -84,6 +87,9 @@ current `.env.gitlab`
84
87
  ```
85
88
  GITLAB_PROJECT_NAME=group/name
86
89
  TEMPLATE_FILE=gitlab_mr_release.md.erb
90
+ DEFAULT_SOURCE_BRANCH=develop
91
+ DEFAULT_TARGET_BRANCH=master
92
+ DEFAULT_LABELS=release
87
93
  ```
88
94
 
89
95
  If defined both `~/.env.gitlab` and current `.env.gitlab`, current `.env.gitlab` is priority
@@ -26,9 +26,10 @@ module GitlabMrRelease
26
26
  end
27
27
 
28
28
  desc "create", "Create merge requrst"
29
- option :source, aliases: "-s", required: true, desc: "Source branch (e.g. develop)"
30
- option :target, aliases: "-t", required: true, desc: "Target branch (e.g. master)"
29
+ option :source, aliases: "-s", desc: "Source branch (e.g. develop)"
30
+ option :target, aliases: "-t", desc: "Target branch (e.g. master)"
31
31
  option :title, desc: "MergeRequest title (default. 'Release :source -> :target')"
32
+ option :labels, aliases: "-l", desc: "Labels for MR as a comma-separated list (e.g. 'label1,label2')"
32
33
  def create
33
34
  Dotenv.load(*GITLAB_ENV_FILES)
34
35
 
@@ -36,6 +37,9 @@ module GitlabMrRelease
36
37
  assert_env("GITLAB_API_PRIVATE_TOKEN")
37
38
  assert_env("GITLAB_PROJECT_NAME")
38
39
 
40
+ assert_option_or_env(:source, "DEFAULT_SOURCE_BRANCH")
41
+ assert_option_or_env(:target, "DEFAULT_TARGET_BRANCH")
42
+
39
43
  template = File.read(template_file)
40
44
 
41
45
  project = GitlabMrRelease::Project.new(
@@ -45,8 +49,9 @@ module GitlabMrRelease
45
49
  )
46
50
 
47
51
  mr = project.create_merge_request(
48
- source_branch: options[:source],
49
- target_branch: options[:target],
52
+ source_branch: source_branch,
53
+ target_branch: target_branch,
54
+ labels: labels,
50
55
  title: generate_title,
51
56
  template: template,
52
57
  )
@@ -70,7 +75,14 @@ MergeRequest is created
70
75
  private
71
76
 
72
77
  def assert_env(name)
73
- raise "Error: Environment variable #{name} is required" unless ENV[name]
78
+ if !ENV[name] || ENV[name].empty?
79
+ puts "Error: Environment variable #{name} is required"
80
+ exit!
81
+ end
82
+ end
83
+
84
+ def assert_option_or_env(option_name, env_name)
85
+ option_or_env!(option_name, env_name)
74
86
  end
75
87
 
76
88
  def generate_title
@@ -78,8 +90,8 @@ MergeRequest is created
78
90
 
79
91
  generate_default_title(
80
92
  title_template: ENV["DEFAULT_TITLE"],
81
- source_branch: options[:source],
82
- target_branch: options[:target],
93
+ source_branch: source_branch,
94
+ target_branch: target_branch,
83
95
  )
84
96
  end
85
97
 
@@ -91,5 +103,31 @@ MergeRequest is created
91
103
  def template_file
92
104
  ENV["TEMPLATE_FILE"] || "#{__dir__}/../templates/gitlab_mr_release.md.erb"
93
105
  end
106
+
107
+ def source_branch
108
+ option_or_env(:source, "DEFAULT_SOURCE_BRANCH")
109
+ end
110
+
111
+ def target_branch
112
+ option_or_env(:target, "DEFAULT_TARGET_BRANCH")
113
+ end
114
+
115
+ def labels
116
+ option_or_env(:labels, "DEFAULT_LABELS")
117
+ end
118
+
119
+ def option_or_env(option_name, env_name, default = nil)
120
+ return options[option_name] if options[option_name] && !options[option_name].empty?
121
+ return ENV[env_name] if ENV[env_name] && !ENV[env_name].empty?
122
+ default
123
+ end
124
+
125
+ def option_or_env!(option_name, env_name)
126
+ value = option_or_env(option_name, env_name)
127
+ return value if value
128
+
129
+ puts "Error: --#{option_name} or #{env_name} is either required!"
130
+ exit!
131
+ end
94
132
  end
95
133
  end
@@ -41,12 +41,13 @@ module GitlabMrRelease
41
41
  ERB.new(template, nil, "-").result(binding).strip
42
42
  end
43
43
 
44
- def create_merge_request(source_branch:, target_branch:, title:, template:)
44
+ def create_merge_request(source_branch:, target_branch:, title:, template:, labels:)
45
45
  iids = merge_request_iids_between(target_branch, source_branch)
46
46
  options = {
47
47
  source_branch: source_branch,
48
48
  target_branch: target_branch,
49
49
  description: generate_description(iids, template),
50
+ labels: labels,
50
51
  }
51
52
  Gitlab.create_merge_request(escaped_project_name, title, options)
52
53
  end
@@ -1,3 +1,3 @@
1
1
  module GitlabMrRelease
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0.beta1"
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: 0.2.0
4
+ version: 0.3.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - sue445
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-11-28 00:00:00.000000000 Z
11
+ date: 2016-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dotenv
@@ -208,12 +208,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
208
208
  version: '0'
209
209
  required_rubygems_version: !ruby/object:Gem::Requirement
210
210
  requirements:
211
- - - ">="
211
+ - - ">"
212
212
  - !ruby/object:Gem::Version
213
- version: '0'
213
+ version: 1.3.1
214
214
  requirements: []
215
215
  rubyforge_project:
216
- rubygems_version: 2.4.5.1
216
+ rubygems_version: 2.5.1
217
217
  signing_key:
218
218
  specification_version: 4
219
219
  summary: Release MergeRequest generator for GitLab