pr-with-params 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2ab35532543684c0467e8c85b4f05d6bb34c2f37a31f09d6d19f546b8f973ca0
4
+ data.tar.gz: 79e8ae8b681c506ebad08b38c7cf4ce624a89715cddbe37181f9c7aaa2e3fef5
5
+ SHA512:
6
+ metadata.gz: 29e4a1bb172ff62a1ae49ce0fbb4c92ee3860c183c1db8b56614fe535e19e3b08a16cfff76b178d5fd2240b772c901f0c1affbcbb0b23cefddadb26838cff675
7
+ data.tar.gz: 4c15b85e016f2cff82f0f2b8e7cde845063b25074f3ae331bfcc3a9d7250f058a635006fc7d6bdaf26f1ef9592f76faecdf84dd2f5294a71f5428423818d1a6d
@@ -0,0 +1,10 @@
1
+ Fixes #<issue-number>
2
+
3
+ ### Description (Checkout [this article](https://chris.beams.io/posts/git-commit/) for examples of good commit messages):
4
+
5
+ ### Testing Steps
6
+
7
+ ### Gotchas
8
+
9
+ ### Dependencies
10
+
@@ -0,0 +1,14 @@
1
+ Implements #<issue-number>
2
+
3
+ ### Description (Checkout [this article](https://chris.beams.io/posts/git-commit/) for examples of good commit messages):
4
+
5
+
6
+ ### Testing Steps
7
+
8
+ ### Gotchas
9
+
10
+ ### Dependencies
11
+
12
+ ### Release Plan
13
+
14
+
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ .DS_Store
data/.rubocop.yml ADDED
@@ -0,0 +1,10 @@
1
+ Style/StringLiterals:
2
+ Enabled: true
3
+ EnforcedStyle: double_quotes
4
+
5
+ Style/StringLiteralsInInterpolation:
6
+ Enabled: true
7
+ EnforcedStyle: double_quotes
8
+
9
+ Layout/LineLength:
10
+ Max: 120
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in pr-with-params.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+ gem "minitest", "~> 5.0"
10
+ gem "rubocop", "~> 0.80"
11
+ gem "launchy"
data/Gemfile.lock ADDED
@@ -0,0 +1,48 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ pr-with-params (0.1.3)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ addressable (2.8.0)
10
+ public_suffix (>= 2.0.2, < 5.0)
11
+ ast (2.4.2)
12
+ launchy (2.5.0)
13
+ addressable (~> 2.7)
14
+ minitest (5.16.2)
15
+ parallel (1.22.1)
16
+ parser (3.1.2.0)
17
+ ast (~> 2.4.1)
18
+ public_suffix (4.0.7)
19
+ rainbow (3.1.1)
20
+ rake (13.0.6)
21
+ regexp_parser (2.5.0)
22
+ rexml (3.2.5)
23
+ rubocop (0.93.1)
24
+ parallel (~> 1.10)
25
+ parser (>= 2.7.1.5)
26
+ rainbow (>= 2.2.2, < 4.0)
27
+ regexp_parser (>= 1.8)
28
+ rexml
29
+ rubocop-ast (>= 0.6.0)
30
+ ruby-progressbar (~> 1.7)
31
+ unicode-display_width (>= 1.4.0, < 2.0)
32
+ rubocop-ast (1.19.1)
33
+ parser (>= 3.1.1.0)
34
+ ruby-progressbar (1.11.0)
35
+ unicode-display_width (1.8.0)
36
+
37
+ PLATFORMS
38
+ arm64-darwin-21
39
+
40
+ DEPENDENCIES
41
+ launchy
42
+ minitest (~> 5.0)
43
+ pr-with-params!
44
+ rake (~> 13.0)
45
+ rubocop (~> 0.80)
46
+
47
+ BUNDLED WITH
48
+ 2.2.3
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Khalil Kum
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,38 @@
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.
3
+
4
+ ## Installation
5
+
6
+ Add this line to your application's Gemfile:
7
+
8
+ ```ruby
9
+ gem 'pr-with-params'
10
+ ```
11
+
12
+ And then execute:
13
+
14
+ $ bundle install
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install pr-with-params
19
+
20
+ ## Usage
21
+
22
+ Assuming you've committed your changes and your local branch is ready to be pushed, run:
23
+
24
+ ```
25
+ $ pr-with-params -t new_feature_template.md -l 'work in progress'
26
+ ```
27
+
28
+ For a full list of options, run `$ pr-with-params -h`
29
+
30
+ ## Development
31
+
32
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
33
+
34
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
35
+
36
+ ## Contributing
37
+
38
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/pr-with-params.
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList["test/**/*_test.rb"]
10
+ end
11
+
12
+ require "rubocop/rake_task"
13
+
14
+ RuboCop::RakeTask.new
15
+
16
+ task default: %i[test rubocop]
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "pr/with/params"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup' # support local testing/development
4
+ require_relative '../lib/pr/with/params'
5
+ require 'json'
6
+ require 'optparse'
7
+
8
+ options = { expand: 1 }
9
+
10
+ parser = OptionParser.new do |opt|
11
+ opt.banner = "Usage pr-with-params [options]"
12
+
13
+ opt.separator ''
14
+
15
+ opt.on('-h', '--help', 'Show this usage help menu') do |_h|
16
+ puts opt
17
+ exit
18
+ end
19
+
20
+ opt.separator ''
21
+
22
+ opt.on('--base-branch BRANCH', "Specify the base branch for your PR (e.g: 'develop'). Will use default branch otherwise.") do |pr_base_branch|
23
+ options[:base_branch] = pr_base_branch
24
+ end
25
+
26
+ opt.on('-t', '--template TEMPLATE', "Specify the filename of the target custom PR template (e.g: 'bug_squash_template.md'). Will use default template otherwise.") do |pr_template|
27
+ options[:template] = pr_template
28
+ end
29
+
30
+ opt.on('-d', '--description DESC', 'Specify a custom PR title') do |pr_description|
31
+ options[:title] = pr_description
32
+ end
33
+
34
+ opt.on('-l', '--labels LABELS', "Specify a list of labels (e.g: 'help+wanted,bug,urgent,work+in+progress').") do |pr_labels|
35
+ options[:labels] = pr_labels
36
+ end
37
+
38
+ opt.on('-a', '--assignees ASSIGNEES', "Specify a list of assignees (e.g: 'octocat,codedog').") do |pr_assignees|
39
+ options[:assignees] = pr_assignees
40
+ end
41
+ end
42
+
43
+ begin
44
+ parser.parse!
45
+
46
+ branch_name = `git rev-parse --abbrev-ref HEAD`
47
+ base_branch = options.delete(:base_branch) || `git remote show origin | grep "HEAD branch" | sed 's/.*: //'`
48
+ remote_git_uri = `git config --get remote.origin.url`.sub('git@github.com:', '').sub('.git', '').chomp
49
+
50
+ uri_host = 'www.github.com'
51
+ uri_path = "/#{remote_git_uri}/compare/#{base_branch.chomp}...#{branch_name.chomp}"
52
+
53
+ puts "current branch: \e[36m#{branch_name.chomp}\e[0m"
54
+ puts "base branch: \e[36m#{base_branch.chomp}\e[0m"
55
+ puts "repo path: \e[36m#{remote_git_uri}\e[0m"
56
+
57
+ push_message = "\nPushing your local branch to origin/#{branch_name.chomp}..."
58
+ puts "\e[32m#{push_message}\e[0m"
59
+ `sleep 1`
60
+ system("git push -u origin #{branch_name}")
61
+
62
+ open_url_message = "\nOpening pull request browser window..."
63
+ puts "\e[32m#{open_url_message}\e[0m"
64
+ `sleep 1`
65
+ PR::With::Params.open(host: uri_host, path: uri_path, query: options)
66
+ rescue StandardError => e
67
+ error_message = {
68
+ message: 'An error occurred while building or opening your custom pull request URL',
69
+ reason: e.message,
70
+ backtrace: e.backtrace.last(10)
71
+ }.to_json
72
+
73
+ STDERR.puts error_message
74
+ exit 1
75
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PR
4
+ module With
5
+ module Params
6
+ VERSION = "0.1.3"
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "params/version"
4
+ require 'uri'
5
+ require 'launchy'
6
+
7
+ module PR
8
+ module With
9
+ module Params
10
+ class Error < StandardError; end
11
+
12
+ def self.open(host:, path:, query:)
13
+ uri_query = URI.encode_www_form(query)
14
+ url_string = URI::HTTPS.build(host: host, path: path, query: uri_query).to_s
15
+ Launchy.open(url_string)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/pr/with/params/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "pr-with-params"
7
+ spec.version = PR::With::Params::VERSION
8
+ spec.authors = ["2k-joker"]
9
+ spec.email = ["kum.vanjunior@gmail.com"]
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."
12
+ spec.homepage = "https://github.com/2k-joker/pr-with-params"
13
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
14
+
15
+ spec.metadata["homepage_uri"] = spec.homepage
16
+
17
+ # Specify which files should be added to the gem when it is released.
18
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
20
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
21
+ end
22
+ spec.bindir = "exe"
23
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ["lib"]
25
+
26
+ # Uncomment to register a new dependency of your gem
27
+ # spec.add_dependency "example-gem", "~> 1.0"
28
+
29
+ # For more information and examples about making a new gem, checkout our
30
+ # guide at: https://bundler.io/guides/creating_gem.html
31
+ end
metadata ADDED
@@ -0,0 +1,61 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pr-with-params
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.3
5
+ platform: ruby
6
+ authors:
7
+ - 2k-joker
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-08-06 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ - kum.vanjunior@gmail.com
16
+ executables:
17
+ - pr-with-params
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - ".github/PULL_REQUEST_TEMPLATE/bug_fix_template.md"
22
+ - ".github/PULL_REQUEST_TEMPLATE/new_feature_template.md"
23
+ - ".gitignore"
24
+ - ".rubocop.yml"
25
+ - Gemfile
26
+ - Gemfile.lock
27
+ - LICENSE
28
+ - README.md
29
+ - Rakefile
30
+ - bin/console
31
+ - bin/setup
32
+ - exe/pr-with-params
33
+ - lib/pr/with/params.rb
34
+ - lib/pr/with/params/version.rb
35
+ - pr-with-params.gemspec
36
+ homepage: https://github.com/2k-joker/pr-with-params
37
+ licenses: []
38
+ metadata:
39
+ homepage_uri: https://github.com/2k-joker/pr-with-params
40
+ post_install_message:
41
+ rdoc_options: []
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: 2.3.0
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ requirements: []
55
+ rubygems_version: 3.2.3
56
+ signing_key:
57
+ specification_version: 4
58
+ summary: Pushes current local branch to remote with upstream to origin/[local-branch-name].
59
+ It also opens a new browser window at a URL with customized params, based on specified
60
+ options, which allows to open pull request with pre-populated fields.
61
+ test_files: []