renuo-cli 4.6.0 → 4.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/renuo/cli/app/github_pull_request_creator.rb +30 -0
- data/lib/renuo/cli/version.rb +1 -1
- data/lib/renuo/cli.rb +18 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 267952952d37a267fa02cfb82918927cde5127ed27cde56826a87cf87446faf2
|
4
|
+
data.tar.gz: 9dbc20c994af13f8458cf9668dbccda3f91490d4cff6cab2069eaf4363d90137
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ade65a29e9197e8672ff964c067bedb0d43b973725e420f7d66abe1ab93b00b7dda716ecde26c570d3b81f4d10129dafae0c05c2918159219d413b9d66c4d075
|
7
|
+
data.tar.gz: 2ad6c9fc136289afa61d737059ff7856cb80bdca7112cfa6ac8eafd8b5baffdddc69f2ddfc1e3a2dec6b332bbded850eb8c9a7886510571a97419dcd31b4f9d2
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class GithubPullRequestCreator
|
4
|
+
def run(opts)
|
5
|
+
validate_options(opts)
|
6
|
+
create_pr(opts)
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def validate_options(opts)
|
12
|
+
abort ">> specify a title" unless opts.title
|
13
|
+
end
|
14
|
+
|
15
|
+
def create_pr(opts)
|
16
|
+
puts `gh pr create --assignee @me --title "#{opts.title}" --body "#{pr_body(opts)}" #{opts.draft ? "--draft" : ""}`
|
17
|
+
end
|
18
|
+
|
19
|
+
def pr_body(opts)
|
20
|
+
redmine_ticket_number = redmine_ticket_number(opts)
|
21
|
+
return "" unless redmine_ticket_number
|
22
|
+
|
23
|
+
"TICKET-#{redmine_ticket_number}"
|
24
|
+
end
|
25
|
+
|
26
|
+
def redmine_ticket_number(opts)
|
27
|
+
current_branch = `git branch --show-current`.strip
|
28
|
+
current_branch.match(/(\d+)/)&.captures&.first || opts.redmine_ticket
|
29
|
+
end
|
30
|
+
end
|
data/lib/renuo/cli/version.rb
CHANGED
data/lib/renuo/cli.rb
CHANGED
@@ -29,6 +29,7 @@ require "renuo/cli/app/create_slidev_presentation"
|
|
29
29
|
require "renuo/cli/app/commit_leaderboard_stage"
|
30
30
|
require "renuo/cli/app/commit_leaderboard_sync"
|
31
31
|
require "renuo/cli/app/github_replace"
|
32
|
+
require "renuo/cli/app/github_pull_request_creator"
|
32
33
|
require "renuo/cli/app/secrets_fetcher"
|
33
34
|
require "highline"
|
34
35
|
|
@@ -38,6 +39,7 @@ def agree(question)
|
|
38
39
|
end
|
39
40
|
|
40
41
|
# rubocop:disable Metrics/AbcSize, Metrics/ClassLength, Metrics/MethodLength
|
42
|
+
# :nocov:
|
41
43
|
module Renuo
|
42
44
|
class CLI
|
43
45
|
def start
|
@@ -312,6 +314,21 @@ module Renuo
|
|
312
314
|
end
|
313
315
|
end
|
314
316
|
|
317
|
+
command "create-pr" do |c|
|
318
|
+
c.syntax = "renuo create-pr"
|
319
|
+
c.summary = "Creates a PR for the current branch"
|
320
|
+
c.description = "Creates a PR, assigns it to you and automatically inserts the Redmine ticket number into " \
|
321
|
+
"the PR body"
|
322
|
+
c.option "--title <title>", String, "The title of the pull request"
|
323
|
+
c.option "--redmine-ticket <number>", Integer, "The redmine ticket number (optional)"
|
324
|
+
c.option "--draft", "Mark the PR as draft"
|
325
|
+
c.example "Create a PR with the title 'Implement XYZ'",
|
326
|
+
"renuo create-pr --title 'Implement XYZ'"
|
327
|
+
c.action do |_, opts|
|
328
|
+
GithubPullRequestCreator.new.run(opts)
|
329
|
+
end
|
330
|
+
end
|
331
|
+
|
315
332
|
command "fetch-secrets" do |c|
|
316
333
|
c.syntax = "renuo fetch-secrets"
|
317
334
|
c.summary = "Fetches the needed secrets in a project from the renuo secrets store"
|
@@ -326,4 +343,5 @@ module Renuo
|
|
326
343
|
end
|
327
344
|
end
|
328
345
|
end
|
346
|
+
# :nocov:
|
329
347
|
# rubocop:enable Metrics/AbcSize, Metrics/ClassLength, Metrics/MethodLength
|
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.
|
4
|
+
version: 4.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Renuo AG
|
@@ -332,6 +332,7 @@ files:
|
|
332
332
|
- lib/renuo/cli/app/environments.rb
|
333
333
|
- lib/renuo/cli/app/fetch_emails.rb
|
334
334
|
- lib/renuo/cli/app/generate_password.rb
|
335
|
+
- lib/renuo/cli/app/github_pull_request_creator.rb
|
335
336
|
- lib/renuo/cli/app/github_replace.rb
|
336
337
|
- lib/renuo/cli/app/heroku_apps.rb
|
337
338
|
- lib/renuo/cli/app/heroku_users.rb
|