pr-with-params 1.0.1 → 1.1.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: c94c3c4bcc5b4378c7959037b305211a923762986d00bb1428c138dbfb21fef2
4
- data.tar.gz: '06238e1b450291ff2b1e2d99e3e49f9f06b81c10e15733782fbaf24adb5c81bf'
3
+ metadata.gz: 205374a47996232c17343492935e3fb4a66ced497e2c0dbf2bbfce278e67a9de
4
+ data.tar.gz: 3d5a35b0957a4c9b101756164d39a2bfdf85cb98b1e9d30795ba21a814f06046
5
5
  SHA512:
6
- metadata.gz: 0c39afef5c5af877c513abd50f41c86c05bff19976037b23247f89f941252e7114ae54ae6e3af97e7bda41a0de11419e00f227331231bf3c4bed693bd3b38ffa
7
- data.tar.gz: 0242737b9147102086ec22848cb8027160241ff6c7948d237a22c75522e7b095a425771ccedde1b1fb16e1ccd4c7a8ed9aa79575decc0ca4f16b49833761e90c
6
+ metadata.gz: 8efbfa3dcb16a892718c9e60b0a6093512b05c4226b7ecd990ba7aa46b99368ad7c9b944a02949a704fa583a56173ef21b9c5c269bd3f36fc899452202f3434f
7
+ data.tar.gz: 4b21a5705d4e3bfa8046a020656ffc25d92c4466652e213074bcd0fbb08b092d53fe9939905dfebeee6ea3e862a0efe0404c7ce19b8ebf0203833f919f1d122e
data/.rubocop.yml CHANGED
@@ -1,6 +1,5 @@
1
1
  Style/StringLiterals:
2
- Enabled: true
3
- EnforcedStyle: double_quotes
2
+ Enabled: false
4
3
 
5
4
  Style/StringLiteralsInInterpolation:
6
5
  Enabled: true
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pr-with-params (1.0.1)
4
+ pr-with-params (1.1.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/exe/pr-with-params CHANGED
@@ -39,7 +39,7 @@ parser = OptionParser.new do |opt|
39
39
  options[:template] = pr_template
40
40
  end
41
41
 
42
- opt.on('-d', '--description DESC', 'Specify a custom PR title') do |pr_description|
42
+ opt.on('-d', '--description DESC', 'Specify a custom PR title. Will use the first branch commit message otherwise.') do |pr_description|
43
43
  options[:title] = pr_description
44
44
  end
45
45
 
@@ -60,8 +60,11 @@ begin
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
63
- remote_git_uri = `git config --get remote.origin.url`.sub('git@github.com:', '').sub('.git', '').chomp
64
63
 
64
+ default_title = `git show-branch --no-name $(git log #{base_branch}..#{branch_name} --pretty=format:"%h" | tail -1)`.chomp
65
+ options[:title] ||= default_title
66
+
67
+ remote_git_uri = `git config --get remote.origin.url`.sub('git@github.com:', '').sub('.git', '').chomp
65
68
  uri_host = 'www.github.com'
66
69
  uri_path = "/#{remote_git_uri}/compare/#{base_branch}...#{branch_name}"
67
70
 
@@ -72,7 +75,7 @@ begin
72
75
  push_message = "\nPushing your local branch to origin/#{branch_name}..."
73
76
  puts "\e[32m#{push_message}\e[0m"
74
77
  `sleep 1`
75
- system("git push -u origin #{branch_name}")
78
+ system("git push -u origin #{branch_name}", exception: true)
76
79
 
77
80
  open_url_message = "\nOpening pull request browser window..."
78
81
  puts "\e[32m#{open_url_message}\e[0m"
@@ -85,6 +88,6 @@ rescue StandardError => e
85
88
  backtrace: e.backtrace&.last(10)
86
89
  }.to_json
87
90
 
88
- STDERR.puts "\e[31mERROR\e[0m: " + error_message + "\n"
91
+ warn "\e[31mERROR\e[0m: " + error_message + "\n"
89
92
  exit 1
90
93
  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 = "1.0.1"
6
+ VERSION = "1.1.0"
7
7
  end
8
8
  end
9
9
  end
@@ -20,7 +20,7 @@ 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
+ file_path.empty? ? {} : ConfigParser.new(config_file_path: file_path, scope: scope).parse!
24
24
  rescue StandardError => e
25
25
  error_message = {
26
26
  message: "Error parsing config file. Using defaults",
@@ -28,8 +28,8 @@ module PR
28
28
  backtrace: e.backtrace&.last(10)
29
29
  }.to_json
30
30
 
31
- STDERR.puts "\e[35mWARNING\e[0m: " + error_message + "\n"
32
-
31
+ warn "\e[35mWARNING\e[0m: " + error_message + "\n"
32
+
33
33
  {}
34
34
  end
35
35
  end
@@ -10,6 +10,7 @@ Gem::Specification.new do |spec|
10
10
 
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
+ 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: 1.0.1
4
+ version: 1.1.0
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-09 00:00:00.000000000 Z
11
+ date: 2022-08-28 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: