pr-with-params 0.2.0 → 1.0.3
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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +6 -3
- data/exe/pr-with-params +3 -3
- data/lib/pr/with/params/config_parser.rb +1 -1
- data/lib/pr/with/params/version.rb +1 -1
- data/lib/pr/with/params.rb +3 -1
- data/pr-with-params.gemspec +2 -1
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 445be6f9d1bb4ce51a180ab2461e571f9493fe99a0449513368ebec0af97a452
|
4
|
+
data.tar.gz: f1f45b9f921973258461cdb61b61f058bf9ad7e60e3fe79043bff02804189e60
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2b60aa172d6def35082fee5ac9826a6e155eaae786b1a2aa8a2eacde81448417a42883672f08b5defaaac41be40c725fba0d0084860b8b96df6d1b703a403d0
|
7
|
+
data.tar.gz: 4d651b5b57042e4d25daadabeb4088863cabf38d3106b0d12b10226973bfc0eb736b52223744fe8218cecb37963631ca6bf1d71bd5d5e06073fe27d39a67733c
|
data/Gemfile.lock
CHANGED
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
|
1
|
+
# PR::With::Params [](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
|
-
*
|
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
|
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
|
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?
|
data/lib/pr/with/params.rb
CHANGED
@@ -20,7 +20,9 @@ module PR
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def parse_config(file_path, scope)
|
23
|
-
|
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",
|
data/pr-with-params.gemspec
CHANGED
@@ -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
|
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.
|
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-
|
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
|
60
|
-
It also opens a new browser window at a URL with customized params,
|
61
|
-
options, which
|
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: []
|