pr-with-params 0.2.0 → 1.0.3

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: eba5280a74bea8222e60654a6798ac5cdf60b659a9e085903e0a74a374a900a8
4
- data.tar.gz: 78acb1fcda0cd7043fd25e51169365ed66c3ce36616209c8856a569bdf6e76cd
3
+ metadata.gz: 445be6f9d1bb4ce51a180ab2461e571f9493fe99a0449513368ebec0af97a452
4
+ data.tar.gz: f1f45b9f921973258461cdb61b61f058bf9ad7e60e3fe79043bff02804189e60
5
5
  SHA512:
6
- metadata.gz: efd0f0b2bc418846d6eb9ca8e37b8c15c03feb77be602e65e811432592108eb22841e8509506050f82f8a1deba547c89eae86ca58d375f38ad0b588d894a621d
7
- data.tar.gz: bc35fade6fcf7ddda8ffd4e6ccdaf12e2075060806d326c770b300ccf86a179055a8fe262ad529fc094ae4873156fd72ad7a412877417ded357fa6d7e520d118
6
+ metadata.gz: d2b60aa172d6def35082fee5ac9826a6e155eaae786b1a2aa8a2eacde81448417a42883672f08b5defaaac41be40c725fba0d0084860b8b96df6d1b703a403d0
7
+ data.tar.gz: 4d651b5b57042e4d25daadabeb4088863cabf38d3106b0d12b10226973bfc0eb736b52223744fe8218cecb37963631ca6bf1d71bd5d5e06073fe27d39a67733c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pr-with-params (0.2.0)
4
+ pr-with-params (1.0.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
- # PR::With::Params
2
- A lightweight gem that pushes current local branch to remote with upstream to origin/[local-branch-name]. It also opens a new browser window at a URL with customized params, based on specified options, which allows to open pull request with pre-populated fields.
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.
3
+
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)
3
5
 
4
6
  ## Installation
5
7
 
@@ -43,7 +45,8 @@ bug_fix:
43
45
  ```
44
46
 
45
47
  * To run with config file, use `$ pr-with-params --conf='path/to/file.yml' --scope=bug_fix`. If `--scope` option is not specified, only `:default` scope will apply.
46
- * All your defaults go in the `:default` scope
48
+ * If you specify a config file (`--conf`) and also pass options by flag (e.g `--base-branch=develop`), the flag value will override the config value.
49
+ * All your defaults go in the `:default` scope.
47
50
  * Only fields defined in another scope will override the defaults. In the example above, the final list of configs will be:
48
51
 
49
52
  ```ruby
data/exe/pr-with-params CHANGED
@@ -56,7 +56,7 @@ begin
56
56
  parser.parse!
57
57
 
58
58
  config_options = PR::With::Params.parse_config(config_file_path, config_scope)
59
- options.merge!(config_options)
59
+ options = config_options.merge(options)
60
60
 
61
61
  branch_name = `git rev-parse --abbrev-ref HEAD`.chomp
62
62
  base_branch = options.delete(:base_branch) || `git remote show origin | grep "HEAD branch" | sed 's/.*: //'`.chomp
@@ -72,7 +72,7 @@ begin
72
72
  push_message = "\nPushing your local branch to origin/#{branch_name}..."
73
73
  puts "\e[32m#{push_message}\e[0m"
74
74
  `sleep 1`
75
- system("git push -u origin #{branch_name}")
75
+ system("git push -u origin #{branch_name}", exception: true)
76
76
 
77
77
  open_url_message = "\nOpening pull request browser window..."
78
78
  puts "\e[32m#{open_url_message}\e[0m"
@@ -85,6 +85,6 @@ rescue StandardError => e
85
85
  backtrace: e.backtrace&.last(10)
86
86
  }.to_json
87
87
 
88
- STDERR.puts "\e[31mERROR\e[0m: " + error_message + "\n"
88
+ STDERR.puts "\n" + "\e[31mERROR:\e[0m " + error_message + "\n"
89
89
  exit 1
90
90
  end
@@ -36,8 +36,8 @@ module PR
36
36
  end
37
37
 
38
38
  def validate_file_type!
39
- raise ArgumentError.new('Config file path is invalid or file does not exist.') unless file_exists?
40
39
  raise TypeError.new('Config file type must be YAML (.yaml or .yml)') unless yaml_file?
40
+ raise ArgumentError.new("Config file path is invalid or file does not exist: #{config_file_path}") unless file_exists?
41
41
  end
42
42
 
43
43
  def yaml_file?
@@ -3,7 +3,7 @@
3
3
  module PR
4
4
  module With
5
5
  module Params
6
- VERSION = "0.2.0"
6
+ VERSION = "1.0.3"
7
7
  end
8
8
  end
9
9
  end
@@ -20,7 +20,9 @@ module PR
20
20
  end
21
21
 
22
22
  def parse_config(file_path, scope)
23
- config_options = ConfigParser.new(config_file_path: file_path, scope: scope).parse!
23
+ return {} if file_path.empty?
24
+
25
+ ConfigParser.new(config_file_path: file_path, scope: scope).parse!
24
26
  rescue StandardError => e
25
27
  error_message = {
26
28
  message: "Error parsing config file. Using defaults",
@@ -8,8 +8,9 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ["2k-joker"]
9
9
  spec.email = ["kum.vanjunior@gmail.com"]
10
10
 
11
- spec.summary = "Pushes current local branch to remote with upstream to origin/[local-branch-name]. It also opens a new browser window at a URL with customized params, based on specified options, which allows to open pull request with pre-populated fields."
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
+ spec.licenses = ["MIT"]
13
14
  spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
14
15
 
15
16
  spec.metadata["homepage_uri"] = spec.homepage
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pr-with-params
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 1.0.3
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-08-08 00:00:00.000000000 Z
11
+ date: 2022-08-11 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -35,7 +35,8 @@ files:
35
35
  - lib/pr/with/params/version.rb
36
36
  - pr-with-params.gemspec
37
37
  homepage: https://github.com/2k-joker/pr-with-params
38
- licenses: []
38
+ licenses:
39
+ - MIT
39
40
  metadata:
40
41
  homepage_uri: https://github.com/2k-joker/pr-with-params
41
42
  post_install_message:
@@ -56,7 +57,8 @@ requirements: []
56
57
  rubygems_version: 3.2.3
57
58
  signing_key:
58
59
  specification_version: 4
59
- summary: Pushes current local branch to remote with upstream to origin/[local-branch-name].
60
- It also opens a new browser window at a URL with customized params, based on specified
61
- options, which allows to open pull request with pre-populated fields.
60
+ summary: Pushes current local branch to remote with upstream at origin/[local-branch-name].
61
+ It also opens a new pull request browser window at a URL with customized query params,
62
+ based on specified options, which pre-populates certain fields in the pull request.
63
+ This is especially useful when supporting multiple PR templates within a code base.
62
64
  test_files: []