pr-with-params 1.2.1 → 1.3.1

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: c782747263091187d47cf06777699c11fea56d9fb74d1fd137c4cde86216a911
4
- data.tar.gz: f8217fa6768ed3ed8f81d553a496ab84e7008e8c493f5cac3232dc8606a35fa5
3
+ metadata.gz: 4374906553024e9cff3a612ac9baa8aed678fe6a025f6a7ad15c060b145a11c8
4
+ data.tar.gz: 2f0b0cc426dbbd284a19e74ae1ee197a12941957ae1bf95cbcd13517e0578dcc
5
5
  SHA512:
6
- metadata.gz: e5b569b26a32a57e47323544eaef3b56f538afce354cb3c2d33cb3d23f096b2070f0855fbc9c0111c46412627585c94493b12898569d7ca93c3c33785439d141
7
- data.tar.gz: 5fbf9e79107c81f09337f11f2fa0c91423df37bfc51b5dd759e77c07815a1d99053bb5e0d6f0ae930082bea9564837a28973ffefc56115138446389f20f95d08
6
+ metadata.gz: 0cfa3f9578b19dfcd1ba614cfa4dfc7b8b7001f057f00e3678ba3f42e2d3345c0d7a85886adb6e5891f622c5d35de10b9ab565643df973c30d10e5e58341e9ee
7
+ data.tar.gz: b92649ee79ff701cd40c20a78ecdf869700a6aa13f38dbb1fadc1628be66a7dc94248a8e7fc05ff1dd27f838c237e7d935378a275f4c1112d0aafddf45441e9e
data/.rubocop.yml CHANGED
@@ -1,3 +1,6 @@
1
+ # All Cops
2
+ AllCops:
3
+ TargetRubyVersion: 3.1.2
1
4
  # Style
2
5
  Style/StringLiterals:
3
6
  Enabled: false
data/Gemfile CHANGED
@@ -8,4 +8,3 @@ gemspec
8
8
  gem "rake", "~> 13.0"
9
9
  gem "minitest", "~> 5.0"
10
10
  gem "rubocop", "~> 0.80"
11
- gem "launchy"
data/Gemfile.lock CHANGED
@@ -1,13 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pr-with-params (1.2.1)
4
+ pr-with-params (1.3.1)
5
+ launchy (~> 2.5)
5
6
 
6
7
  GEM
7
8
  remote: https://rubygems.org/
8
9
  specs:
9
- addressable (2.8.0)
10
- public_suffix (>= 2.0.2, < 5.0)
10
+ addressable (2.8.1)
11
+ public_suffix (>= 2.0.2, < 6.0)
11
12
  ast (2.4.2)
12
13
  launchy (2.5.0)
13
14
  addressable (~> 2.7)
@@ -15,7 +16,7 @@ GEM
15
16
  parallel (1.22.1)
16
17
  parser (3.1.2.0)
17
18
  ast (~> 2.4.1)
18
- public_suffix (4.0.7)
19
+ public_suffix (5.0.1)
19
20
  rainbow (3.1.1)
20
21
  rake (13.0.6)
21
22
  regexp_parser (2.5.0)
@@ -38,7 +39,6 @@ PLATFORMS
38
39
  arm64-darwin-21
39
40
 
40
41
  DEPENDENCIES
41
- launchy
42
42
  minitest (~> 5.0)
43
43
  pr-with-params!
44
44
  rake (~> 13.0)
data/README.md CHANGED
@@ -1,8 +1,11 @@
1
1
  # PR::With::Params [![Gem Version](https://badge.fury.io/rb/pr-with-params.svg)](https://badge.fury.io/rb/pr-with-params)
2
- A lightweight gem that pushes current local branch to remote with upstream at origin/[local-branch-name]. It also opens a new pull request browser window at a URL with customized query params, based on specified options, which pre-populates certain fields in the pull request. This is especially useful when supporting multiple PR templates within a code base.
2
+ A lightweight ruby gem that pushes current local branch to remote with upstream at origin/[local-branch-name]. It also opens a new pull request browser window at a URL with customized query params, based on specified options, which pre-populates certain fields in the pull request. This is especially useful when supporting multiple PR templates within a code base.
3
3
 
4
4
  Inspired by GitHub's documentation on [using query params to create pull requets](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/using-query-parameters-to-create-a-pull-request)
5
5
 
6
+ ## Prerequisites
7
+ This gem currently uses the [launchy gem](https://github.com/copiousfreetime/launchy) to open URLs. Ensure your code base satisfies launchy's dependencies.
8
+
6
9
  ## Installation
7
10
 
8
11
  Add this line to your application's Gemfile:
data/exe/pr-with-params CHANGED
@@ -23,6 +23,13 @@ parser = OptionParser.new do |opt|
23
23
 
24
24
  opt.separator ''
25
25
 
26
+ opt.on('-v', '--version', 'Returns your current local gem version') do |_h|
27
+ puts 'pr-with-params ' + PR::With::Params::VERSION
28
+ exit
29
+ end
30
+
31
+ opt.separator ''
32
+
26
33
  opt.on('--conf FILE_PATH', 'Path to yaml file where options are defined. NOTE that relative paths are not supported.') do |conf_file|
27
34
  stdout, _stderr, _status = Open3.capture3("echo #{conf_file}")
28
35
  config_file_path = stdout.chomp
@@ -32,7 +39,7 @@ parser = OptionParser.new do |opt|
32
39
  config_scope = scope
33
40
  end
34
41
 
35
- opt.on('--base-branch BRANCH', "Specify the base branch for your PR (e.g: 'develop'). Will use default branch otherwise.") do |pr_base_branch|
42
+ opt.on('-b', '--base-branch BRANCH', "Specify the base branch for your PR (e.g: 'develop'). Will use default branch otherwise.") do |pr_base_branch|
36
43
  options[:base_branch] = pr_base_branch
37
44
  end
38
45
 
@@ -70,7 +77,7 @@ begin
70
77
  default_title = `git show-branch --no-name $(git log #{base_branch}..#{branch_name} --pretty=format:"%h" | tail -1)`.chomp
71
78
  options[:title] ||= default_title
72
79
 
73
- PR::With::Params.validate_options(options)
80
+ PR::With::Params.validate_options!(options)
74
81
 
75
82
  remote_git_uri = `git config --get remote.origin.url`.sub('git@github.com:', '').sub('.git', '').chomp
76
83
  uri_host = 'www.github.com'
@@ -90,12 +97,11 @@ begin
90
97
  `sleep 1`
91
98
  PR::With::Params.open(host: uri_host, path: uri_path, query: options)
92
99
  rescue StandardError => e
93
- error_message = {
94
- message: 'An error occurred while building or opening your custom pull request URL',
95
- reason: e.message,
96
- backtrace: e.backtrace&.last(10)
97
- }.to_json
100
+ message = "\e[31mERROR\e[0m: An error occurred while building or opening your custom pull request URL"
101
+ reason = "reason: #{e.message}"
102
+ backtrace = "backtrace: #{e.backtrace&.last(10)&.join("\n")}"
103
+ error_message = [message, reason, backtrace, "\n\n"].join("\n")
98
104
 
99
- warn "\e[31mERROR\e[0m: " + error_message + "\n"
105
+ warn error_message
100
106
  exit 1
101
107
  end
@@ -25,7 +25,7 @@ module PR
25
25
  end
26
26
 
27
27
  class ConventionalCommitValidator
28
- CONVENTIONAL_COMMIT_REGEX = /^((build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(\w+\))?(!)?(: (.*\s*)*))|(^Merge (.*\s*)*)|(^Initial commit$)/.freeze
28
+ CONVENTIONAL_COMMIT_REGEX = /^((build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(.*\))?(!)?(: (.*\s*)*))|(^Merge (.*\s*)*)|(^Initial commit$)/.freeze
29
29
 
30
30
  def initialize(options)
31
31
  @commit_message = options[:title]
@@ -3,7 +3,7 @@
3
3
  module PR
4
4
  module With
5
5
  module Params
6
- VERSION = "1.2.1"
6
+ VERSION = "1.3.1"
7
7
  end
8
8
  end
9
9
  end
@@ -23,18 +23,17 @@ module PR
23
23
  def parse_config(file_path, scope)
24
24
  file_path.empty? ? {} : ConfigParser.new(config_file_path: file_path, scope: scope).parse!
25
25
  rescue StandardError => e
26
- error_message = {
27
- message: "Error parsing config file. Using defaults",
28
- reason: e.message,
29
- backtrace: e.backtrace&.last(10)
30
- }.to_json
26
+ message = "\e[35mWARNING\e[0m: Error parsing config file. Using defaults"
27
+ reason = "reason: #{e.message}"
28
+ backtrace = "backtrace: #{e.backtrace&.last(10)&.join("\n")}"
29
+ error_message = [message, reason, backtrace, "\n\n"].join("\n")
31
30
 
32
- warn "\e[35mWARNING\e[0m: " + error_message + "\n"
31
+ warn error_message
33
32
 
34
33
  {}
35
34
  end
36
35
 
37
- def validate_options(options)
36
+ def validate_options!(options)
38
37
  validators = options.delete(:validators)
39
38
  OptionsValidator.validate!(options, validators: validators)
40
39
  end
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
  spec.summary = "Pushes current local branch to remote with upstream at origin/[local-branch-name]. It also opens a new pull request browser window at a URL with customized query params, based on specified options, which pre-populates certain fields in the pull request. This is especially useful when supporting multiple PR templates within a code base."
12
12
  spec.homepage = "https://github.com/2k-joker/pr-with-params"
13
13
  spec.licenses = ["MIT"]
14
- spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
14
+ spec.required_ruby_version = Gem::Requirement.new(">= 3.1.0")
15
15
 
16
16
  spec.metadata["homepage_uri"] = spec.homepage
17
17
 
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.require_paths = ["lib"]
26
26
 
27
27
  # Uncomment to register a new dependency of your gem
28
- # spec.add_dependency "example-gem", "~> 1.0"
28
+ spec.add_dependency "launchy", "~> 2.5"
29
29
 
30
30
  # For more information and examples about making a new gem, checkout our
31
31
  # guide at: https://bundler.io/guides/creating_gem.html
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pr-with-params
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - 2k-joker
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-09-21 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2022-12-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: launchy
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.5'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.5'
13
27
  description:
14
28
  email:
15
29
  - kum.vanjunior@gmail.com
@@ -48,14 +62,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
48
62
  requirements:
49
63
  - - ">="
50
64
  - !ruby/object:Gem::Version
51
- version: 2.3.0
65
+ version: 3.1.0
52
66
  required_rubygems_version: !ruby/object:Gem::Requirement
53
67
  requirements:
54
68
  - - ">="
55
69
  - !ruby/object:Gem::Version
56
70
  version: '0'
57
71
  requirements: []
58
- rubygems_version: 3.2.3
72
+ rubygems_version: 3.3.26
59
73
  signing_key:
60
74
  specification_version: 4
61
75
  summary: Pushes current local branch to remote with upstream at origin/[local-branch-name].