renuo-cli 4.15.0 → 4.16.0

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
  SHA256:
3
- metadata.gz: 803278ba1e1fc8859287b68a32e3c3545afbaea2423f1a6eb3a8d5754d777f65
4
- data.tar.gz: fb96573c7ae9899aa951ec5af5a11d2e6f8be58f753af48243095a7bb6e6f75d
3
+ metadata.gz: b7d2be942a488e9f935ad409f20fa275aea27af14713c6b98b155718208fbbbe
4
+ data.tar.gz: 8b854cf2514442624fe57d6f25e6540575140f14b2ece1ecda41ad2f5ef767cb
5
5
  SHA512:
6
- metadata.gz: d593c03a92f2df9d17839056d156f125677ceb3780022aef734a4bb6c1d48d1ec3dde08875dd25fb86775aeb3908d02c41e850e95b203e0d20009d4756d33645
7
- data.tar.gz: 707d0f050955cb8a56e8ef7803351a4fa23b9c2a6b153e6b9ed2913ef3544b4a480f7faaa4c95a55d7eb629985dd719afd11fae70ab543450ac2e5b1b64c84d0
6
+ metadata.gz: 2b3b6acf9f8c2899d818ab72a1429835fc3f94ad003d8d6974c2bbee8d39819aeec07e5c947dd814f0626d1151fc007dff8d78664b7f84bd63d3d1ef2c6b68cc
7
+ data.tar.gz: 612d0f7b4f197079cbb8e48c0cf7262a9d07f175e03c2318a7cc7a803451bc0c39c812ecebf13cd07b0c666090c0c21b1eedfecba3105ba6758fc616436349de
@@ -6,13 +6,17 @@ class Renuo::Cli::Commands::Release # rubocop:disable Metrics/ClassLength
6
6
  UPDATE_TYPES = %w[major minor patch custom].freeze
7
7
  TMP_FOLDER_NAME = "_RENUO_RELEASE_TEMP_#{rand(100_000_000)}".freeze
8
8
  MOVE_TO_TMP_FOLDER = "mkdir -p #{TMP_FOLDER_NAME} && cd #{TMP_FOLDER_NAME}".freeze
9
+ SUPPORTED_HOSTS = %w[github.com gitlab.com].freeze
9
10
 
10
11
  command "release" do |c|
11
12
  c.syntax = "renuo release"
12
- c.summary = "Release a projects state of develop (on github) to main in one command."
13
+ c.summary = "Release a project's state of develop to main in one command."
13
14
  c.description = "Creates a new release version of a project on main as either a Major, Minor, " \
14
- "Patch or Custom release based on the current state of develop on Github"
15
- c.example "renuo release my-project minor", "release a minor release of my-project"
15
+ "Patch or Custom release based on the current state of develop. " \
16
+ "Supports GitHub and GitLab repositories."
17
+ c.example "renuo release my-project minor", "release a minor release of renuo/my-project on GitHub"
18
+ c.example "renuo release renuo/my-project minor", "release a minor release of renuo/my-project on GitHub"
19
+ c.example "renuo release https://gitlab.com/renuo/project patch", "release a patch of a GitLab project"
16
20
  c.example "renuo release my-project custom 2.5.0", "release my-project as release 2.5.0"
17
21
  c.action { |args| new.run(args) }
18
22
  end
@@ -39,6 +43,23 @@ class Renuo::Cli::Commands::Release # rubocop:disable Metrics/ClassLength
39
43
 
40
44
  def validate_project_name
41
45
  abort(">> No project name given.") unless @project_name
46
+
47
+ @host, @repo_path = repo_identifier(@project_name)
48
+ end
49
+
50
+ def repo_identifier(input)
51
+ return ["github.com", "renuo/#{input}"] unless input.include?("/")
52
+ return ["github.com", input] unless input.start_with?("http://", "https://", "git@")
53
+
54
+ # Convert git@host:path to https://host/path
55
+ uri = input.sub(/^git@([^:]+):/, 'https://\1/').sub(/\.git$/, "")
56
+ parsed = URI.parse(uri)
57
+ host = parsed.host
58
+ repo_path = parsed.path.sub(%r{^/}, "")
59
+
60
+ return [host, repo_path] if SUPPORTED_HOSTS.include?(host)
61
+
62
+ abort(">> Unsupported host '#{host}'. Supported hosts: #{SUPPORTED_HOSTS.join(", ")}")
42
63
  end
43
64
 
44
65
  def validate_update_type
@@ -74,11 +95,20 @@ class Renuo::Cli::Commands::Release # rubocop:disable Metrics/ClassLength
74
95
 
75
96
  def open_comparison_page
76
97
  puts "Opening browser to double-check what is going to be deployed…"
77
- open_path "https://github.com/#{@project_name}/compare/#{main_branch}...develop"
98
+ open_path comparison_url
99
+ end
100
+
101
+ def comparison_url
102
+ case @host
103
+ when "gitlab.com"
104
+ "https://#{@host}/#{@repo_path}/-/compare/#{main_branch}...develop"
105
+ else
106
+ "https://#{@host}/#{@repo_path}/compare/#{main_branch}...develop"
107
+ end
78
108
  end
79
109
 
80
110
  def checkout_project
81
- abort(">> Project not found on Github.") unless system("#{MOVE_TO_TMP_FOLDER} && gh repo clone #{@project_name}")
111
+ abort(">> Project not found.") unless system("#{MOVE_TO_TMP_FOLDER} && git clone git@#{@host}:#{@repo_path}.git")
82
112
 
83
113
  system(cmd_in_folder("git checkout #{main_branch} && git pull origin #{main_branch} &&" \
84
114
  "git checkout #{develop_branch} && git pull origin #{develop_branch}"))
@@ -173,7 +203,7 @@ class Renuo::Cli::Commands::Release # rubocop:disable Metrics/ClassLength
173
203
  end
174
204
 
175
205
  def ask_for_final_confirmation
176
- unless agree(">> Are you sure you wish to deploy '#{@project_name}' " \
206
+ unless agree(">> Are you sure you wish to deploy '#{@repo_path}' " \
177
207
  "as a #{@update_type} release (#{current_version} => #{@version})?")
178
208
  abort(">> Cancelling Release.")
179
209
  end
@@ -195,7 +225,7 @@ class Renuo::Cli::Commands::Release # rubocop:disable Metrics/ClassLength
195
225
  end
196
226
 
197
227
  def folder_name
198
- @project_name.split("/").last
228
+ @repo_path.split("/").last
199
229
  end
200
230
 
201
231
  def cleanup
@@ -203,7 +233,7 @@ class Renuo::Cli::Commands::Release # rubocop:disable Metrics/ClassLength
203
233
  end
204
234
 
205
235
  def main_branch
206
- remote_repo = "git@github.com:#{@project_name}.git"
236
+ remote_repo = "git@#{@host}:#{@repo_path}.git"
207
237
  @main_branch ||= `git ls-remote --heads #{remote_repo} main`.empty? ? "master" : "main"
208
238
  end
209
239
 
@@ -3,7 +3,7 @@
3
3
  # :nocov:
4
4
  module Renuo
5
5
  class Cli
6
- VERSION = "4.15.0"
6
+ VERSION = "4.16.0"
7
7
  NAME = "renuo-cli"
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: renuo-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.15.0
4
+ version: 4.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Renuo AG
@@ -135,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
135
  - !ruby/object:Gem::Version
136
136
  version: '0'
137
137
  requirements: []
138
- rubygems_version: 3.6.9
138
+ rubygems_version: 3.7.2
139
139
  specification_version: 4
140
140
  summary: The Renuo CLI automates some common workflows.
141
141
  test_files: []