pull-request 0.3.0 → 0.5.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: 1a24bfa9cadb0ef0ede06d5e1c94ae69f6eb15d765a64c7ab3c6ad9af28eee44
4
- data.tar.gz: d91143af59fdeb21f53827bbea50b48237fadeb7b0d31a3f24d714d3901b5fe3
3
+ metadata.gz: 47bc3713218fc982a1c0194c811be0c87c6b10689b6724644fc786c00b14dad3
4
+ data.tar.gz: cb56af729482bfe0836989ba9365f7538c4c8265410c3088a21ca7ffdcd259b4
5
5
  SHA512:
6
- metadata.gz: 1418f787d24cfca340f6bfaf477277b80ad1f081068abdb685ed70a8c94997f21e9d113f8fd04b85d911d787363834be46232d2bfafe08bb48d1ac882f0e72f0
7
- data.tar.gz: f0c48a452e439ca7791b412253e59d6a66714c6c6c08f089e2391fa6af3a032f9845fd490681b4b2a88ff6ecb7f3d3e50046c65e99577d487df0fe44b0eb9c16
6
+ metadata.gz: b64964a0ad5ffa1b04a537ed53a1cbe1eb3f893a348e20856b5bac2f3473eee239a763b16457b97a6063f4bec99ec4577cd70a45014355df568af9a03f06c2f8
7
+ data.tar.gz: bf3a4d8b62903d52470c6807cc2eb94a41c2c85ccc5b2b8964c40bc0d7c450434b8b1a5f6fd89090047c7e21d00b9116d35e9185f3c7b0fd45af18376434241c
@@ -0,0 +1,16 @@
1
+ name: Publish to RubyGems
2
+ on:
3
+ release:
4
+ types: [created]
5
+ jobs:
6
+ gem:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v2
10
+ - name: Set up Ruby
11
+ uses: ruby/setup-ruby@v1
12
+ - run: sed -i "s/0.0.1/$(echo $GITHUB_REF_NAME | cut -c 2-)/" pullrequest.gemspec
13
+ - name: Publish gem
14
+ uses: dawidd6/action-publish-gem@v1
15
+ with:
16
+ api_key: ${{secrets.RUBYGEMS_API_KEY}}
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.1.2
data/README.md CHANGED
@@ -6,12 +6,12 @@ Automatically branch and create an empty pull request, automating an early-revie
6
6
 
7
7
  ### Requirements
8
8
 
9
- #### hub
9
+ #### GitHub CLI
10
10
 
11
- [GitHub's `hub`](https://hub.github.com/) CLI tool is required. On macOS, simply install it through _HomeBrew_
11
+ [GitHub's CLI](https://cli.github.com//) (aka `gh`) is required. On _macOS_, simply install it through _HomeBrew_.
12
12
 
13
13
  ```bash
14
- brew install hub
14
+ brew install gh
15
15
  ```
16
16
 
17
17
  ### Installing pr (pull-request) as part of your application
@@ -34,7 +34,7 @@ Install it yourself as:
34
34
 
35
35
  ```bash
36
36
  gem install pull-request
37
- ````
37
+ ```
38
38
 
39
39
  ## Usage
40
40
 
@@ -69,8 +69,6 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
69
69
 
70
70
  Bug reports and pull requests are welcome on GitHub at https://github.com/Jens Ravens/pullrequest. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
71
71
 
72
-
73
72
  ## License
74
73
 
75
74
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
76
-
data/exe/pr CHANGED
@@ -12,6 +12,12 @@ def error(title)
12
12
  exit 1
13
13
  end
14
14
 
15
+ def confirm(title)
16
+ printf "#{title}\npress 'y' to continue: "
17
+ prompt = STDIN.gets.chomp
18
+ prompt == 'y'
19
+ end
20
+
15
21
  def sh(command)
16
22
  return puts "▶️ #{command}" if @simulate
17
23
 
@@ -22,11 +28,22 @@ def sh_get(command)
22
28
  value = `#{command}`
23
29
  error "could not execute '#{command}'" unless $? == 0
24
30
 
25
- value
31
+ value.strip
32
+ end
33
+
34
+ def current_branch
35
+ sh_get "git rev-parse --abbrev-ref HEAD"
36
+ end
37
+
38
+ def issue_json
39
+ @issue_json ||= begin
40
+ error "can't get issue information from GitHub unless the '-i' options is used" unless @issue_number.present?
41
+ JSON.parse(sh_get("gh issue view #{@issue_number} --json title"))
42
+ end
26
43
  end
27
44
 
28
45
  OptionParser.new do |opts|
29
- opts.banner = "Usage: pr [options] [name]\nDefaults: pr" + File::SEPARATOR
46
+ opts.banner = "Usage: pr [options] [title]\nDefaults: pr" + File::SEPARATOR
30
47
  opts.on("-e", "--estimation ESTIMATION", Integer, "Estimated time in hours.") do |e|
31
48
  @estimation = e.presence
32
49
  end
@@ -38,32 +55,33 @@ OptionParser.new do |opts|
38
55
  end
39
56
  end.parse!
40
57
 
41
- name =
42
- if @issue_number
43
- sh_get("hub issue show #{@issue_number} -f %t")
44
- else
45
- ARGV.join(" ")
46
- end
47
- error "Please specify a name for your Pull Request" if name.blank?
48
-
49
- title = name
50
- title += " [#{@estimation}]" if @estimation
51
- title += "\n\nfixes ##{@issue_number}" if @issue_number
58
+ name = @issue_number ? issue_json["title"] : ARGV.join(" ")
59
+ error "Please specify a title for your Pull Request" if name.blank?
52
60
 
53
61
  branch = "feature/"
54
62
  branch += "#{@issue_number}_" if @issue_number
55
63
  branch += name.parameterize.underscore
56
64
 
65
+ title = name
66
+ title += " [#{@estimation}]" if @estimation
67
+
68
+ body_lines = []
69
+ body_lines.push "fixes ##{@issue_number}" if @issue_number
70
+ body = body_lines.join("\n")
71
+
72
+ base_branch = current_branch
73
+ exit 1 unless ["master", "main", "develop"].include?(base_branch) || confirm("Your base branch #{base_branch} doesn't seem to be a common base branch name. Do you want to continue?")
74
+
57
75
  puts "Creating new PR for feature '#{title}'"
58
76
 
59
77
  puts "Creating branch #{branch}"
60
78
  sh "git checkout -b #{branch}"
61
79
 
62
80
  puts "Creating empty commit"
63
- sh "git commit -m 'initial commit for #{name}' --allow-empty"
81
+ sh "git commit -m 'initial commit for #{title}' --allow-empty"
64
82
 
65
83
  puts "Pushing to origin"
66
84
  sh "git push -u origin #{branch}"
67
85
 
68
86
  puts "Creating pull request"
69
- sh "hub pull-request -d -m '#{title}'"
87
+ sh "gh pr create --draft --title '#{title}' --body '#{body}' --base #{base_branch}"
data/pullrequest.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  # coding: utf-8
2
2
  Gem::Specification.new do |spec|
3
3
  spec.name = "pull-request"
4
- spec.version = "0.3.0"
4
+ spec.version = "0.5.0"
5
5
  spec.authors = ["Jens Ravens", "David Dufour-Boivin"]
6
6
  spec.email = ["jens@nerdgeschoss.de", "david@nerdgeschoss.de"]
7
7
 
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pull-request
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jens Ravens
8
8
  - David Dufour-Boivin
9
- autorequire:
9
+ autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2020-08-10 00:00:00.000000000 Z
12
+ date: 2022-11-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -53,7 +53,7 @@ dependencies:
53
53
  - - ">="
54
54
  - !ruby/object:Gem::Version
55
55
  version: '0'
56
- description:
56
+ description:
57
57
  email:
58
58
  - jens@nerdgeschoss.de
59
59
  - david@nerdgeschoss.de
@@ -62,8 +62,10 @@ executables:
62
62
  extensions: []
63
63
  extra_rdoc_files: []
64
64
  files:
65
+ - ".github/workflows/publish.yml"
65
66
  - ".gitignore"
66
67
  - ".rubocop.yml"
68
+ - ".ruby-version"
67
69
  - CODE_OF_CONDUCT.md
68
70
  - Gemfile
69
71
  - LICENSE.txt
@@ -77,7 +79,7 @@ homepage: https://nerdgeschoss.de
77
79
  licenses:
78
80
  - MIT
79
81
  metadata: {}
80
- post_install_message:
82
+ post_install_message:
81
83
  rdoc_options: []
82
84
  require_paths:
83
85
  - lib
@@ -92,8 +94,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
94
  - !ruby/object:Gem::Version
93
95
  version: '0'
94
96
  requirements: []
95
- rubygems_version: 3.0.6
96
- signing_key:
97
+ rubygems_version: 3.3.7
98
+ signing_key:
97
99
  specification_version: 4
98
100
  summary: Automatically create PRs for GitHub Flow
99
101
  test_files: []