purr-pr 0.1.0 → 0.1.4
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 +2 -2
- data/bin/console +4 -11
- data/bin/purr +2 -3
- data/lib/{purr → purr_pr}/actions.rb +2 -2
- data/lib/purr_pr/config.rb +86 -0
- data/lib/{purr → purr_pr}/editor.rb +4 -4
- data/lib/{purr → purr_pr}/text_objects.rb +1 -1
- data/lib/{purr → purr_pr}/version.rb +2 -2
- data/lib/purr_pr.rb +49 -0
- data/purr_pr.gemspec +35 -0
- data/spec/purr_spec.rb +2 -6
- data/spec/spec_helper.rb +1 -4
- metadata +22 -21
- data/lib/purr.rb +0 -41
- data/purr.gemspec +0 -39
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 026f27316039a8102929a1346d6ccdd17e819bd8257799e418612438941d93f5
|
4
|
+
data.tar.gz: 17e9f3e088efc7e7577997880fb49e175ca4c7eca761ef84a6c0de6ec954f5a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 570c260277fb207740070722bf0b0f164c965e3902128c9c3f0ab2959d76d1f949de39820a145545adf6019104798213451599c78c03b22839ddef2e58a3fe6c
|
7
|
+
data.tar.gz: f1cb51100aa7cdc84ad51dd06257a9c61e2a5f6ddcc3fd13402f5db1c3929631a0fdf800c60b697ed229ae75d0587d5d9c4b5654ad5df7433485b0d33a77add6
|
data/Gemfile.lock
CHANGED
data/bin/console
CHANGED
@@ -1,15 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require
|
5
|
-
require
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'purr_pr'
|
6
6
|
|
7
|
-
|
8
|
-
|
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__)
|
7
|
+
require 'pry'
|
8
|
+
Pry.start
|
data/bin/purr
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'io/console'
|
4
4
|
|
5
|
-
|
5
|
+
class PurrPr
|
6
6
|
module Actions
|
7
7
|
def ask(message, default: nil, multiline: false, newline: true)
|
8
8
|
puts(message)
|
@@ -35,7 +35,7 @@ module Purr
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def interrupted?
|
38
|
-
|
38
|
+
!!@interrupted
|
39
39
|
end
|
40
40
|
|
41
41
|
private
|
@@ -0,0 +1,86 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'ostruct'
|
4
|
+
|
5
|
+
require_relative 'editor.rb'
|
6
|
+
|
7
|
+
class PurrPr
|
8
|
+
class Config
|
9
|
+
attr_reader :title, :body, :assignee
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
# the defaults if the setter is not called
|
13
|
+
@maintainer_edit = true
|
14
|
+
end
|
15
|
+
|
16
|
+
def title(&block)
|
17
|
+
@title = edit(:title, &block)
|
18
|
+
end
|
19
|
+
|
20
|
+
def body(&block)
|
21
|
+
@body = edit(:body, &block)
|
22
|
+
end
|
23
|
+
|
24
|
+
def assignee(assignee)
|
25
|
+
@assignee = assignee
|
26
|
+
end
|
27
|
+
|
28
|
+
def self_assign
|
29
|
+
assignee('@me')
|
30
|
+
end
|
31
|
+
|
32
|
+
def maintainer_edit(enabled)
|
33
|
+
@maintainer_edit = enabled
|
34
|
+
end
|
35
|
+
|
36
|
+
def no_maintainer_edit
|
37
|
+
maintainer_edit(false)
|
38
|
+
end
|
39
|
+
|
40
|
+
def base(base_branch)
|
41
|
+
@base = base_branch
|
42
|
+
end
|
43
|
+
|
44
|
+
def draft(enabled = true)
|
45
|
+
@draft = enabled
|
46
|
+
end
|
47
|
+
|
48
|
+
def labels(labels)
|
49
|
+
@labels = labels
|
50
|
+
end
|
51
|
+
|
52
|
+
def reviewers(reviewers)
|
53
|
+
@reviewers = reviewers
|
54
|
+
end
|
55
|
+
|
56
|
+
def values
|
57
|
+
OpenStruct.new(
|
58
|
+
title: @title,
|
59
|
+
body: @body,
|
60
|
+
assignee: @assignee,
|
61
|
+
base: @base,
|
62
|
+
draft: @draft,
|
63
|
+
reviewers: @reviewers,
|
64
|
+
labels: @labels,
|
65
|
+
maintainer_edit: @maintainer_edit
|
66
|
+
)
|
67
|
+
end
|
68
|
+
|
69
|
+
private
|
70
|
+
|
71
|
+
def edit(subject, &block)
|
72
|
+
editor = Editor.new(subject)
|
73
|
+
|
74
|
+
catch(:abort) { editor.evaluate(&block) }
|
75
|
+
|
76
|
+
interrupt if editor.interrupted?
|
77
|
+
|
78
|
+
editor.content
|
79
|
+
end
|
80
|
+
|
81
|
+
def interrupt
|
82
|
+
puts 'aborted'
|
83
|
+
exit
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -5,7 +5,7 @@ require 'securerandom'
|
|
5
5
|
require_relative 'text_objects'
|
6
6
|
require_relative 'actions'
|
7
7
|
|
8
|
-
|
8
|
+
class PurrPr
|
9
9
|
class Editor
|
10
10
|
include TextObjects
|
11
11
|
include Actions
|
@@ -67,9 +67,9 @@ module Purr
|
|
67
67
|
ask_yn(text, decline: -> { interrupt })
|
68
68
|
end
|
69
69
|
alias_method :confirmation, :confirm
|
70
|
-
end
|
71
70
|
|
72
|
-
|
73
|
-
|
71
|
+
def use_template(path = '.github/pull_request_template.md')
|
72
|
+
@content = read_file(path)
|
73
|
+
end
|
74
74
|
end
|
75
75
|
end
|
data/lib/purr_pr.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'purr_pr/version'
|
4
|
+
require_relative 'purr_pr/editor.rb'
|
5
|
+
require_relative 'purr_pr/config.rb'
|
6
|
+
|
7
|
+
class PurrPr
|
8
|
+
attr_reader :config_file_path, :config
|
9
|
+
|
10
|
+
DEFAULT_CONFIG_FILE_PATH = 'purr.rb'
|
11
|
+
|
12
|
+
def initialize(config_file_path = DEFAULT_CONFIG_FILE_PATH)
|
13
|
+
@config_file_path = config_file_path
|
14
|
+
@config = Config.new
|
15
|
+
end
|
16
|
+
|
17
|
+
def create
|
18
|
+
config.instance_eval(config_code)
|
19
|
+
|
20
|
+
command = 'gh pr create'
|
21
|
+
command += " --title '#{config.values.title}'" if config.values.title
|
22
|
+
command += " --body '#{config.values.body}'"
|
23
|
+
command += " --assignee #{config.values.assignee}" if config.values.assignee
|
24
|
+
command += " --base #{config.values.base}" if config.values.base
|
25
|
+
command += ' --draft' if config.values.draft
|
26
|
+
command += ' --no-maintainer-edit' unless config.values.maintainer_edit
|
27
|
+
|
28
|
+
config.values.labels.each do |label|
|
29
|
+
command += " --label #{label}"
|
30
|
+
end
|
31
|
+
|
32
|
+
config.values.reviewers.each do |reviewer|
|
33
|
+
command += " --reviewer #{reviewer}"
|
34
|
+
end
|
35
|
+
|
36
|
+
# The later arguments will override the earlier ones,
|
37
|
+
# e.g. after `gh pr create --title a --title b` the title will equal 'b',
|
38
|
+
# so explicit options will override the config
|
39
|
+
command += ARGV.join(' ').prepend(' ')
|
40
|
+
|
41
|
+
system(command)
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def config_code
|
47
|
+
File.read(config_file_path)
|
48
|
+
end
|
49
|
+
end
|
data/purr_pr.gemspec
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/purr_pr/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'purr-pr'
|
7
|
+
spec.version = PurrPr::VERSION
|
8
|
+
spec.author = 'Alexander Teslovskiy'
|
9
|
+
spec.email = 'artoriousso@gmail.com'
|
10
|
+
spec.summary = 'A CLI pull request formatter'
|
11
|
+
spec.description = 'Purr PR is a tool to automate pull request formatting via GitHub CLI'
|
12
|
+
spec.homepage = 'https://github.com/ARtoriouSs/purr-pr'
|
13
|
+
spec.license = 'MIT'
|
14
|
+
|
15
|
+
spec.metadata = {
|
16
|
+
'documentation_uri' => 'https://github.com/ARtoriouSs/purr-pr/blob/master/README.md',
|
17
|
+
'bug_tracker_uri' => 'https://github.com/ARtoriouSs/purr-pr/issues',
|
18
|
+
'source_code_uri' => 'https://github.com/ARtoriouSs/purr-pr',
|
19
|
+
'changelog_uri' => 'https://github.com/ARtoriouSs/purr-pr/blob/master/CHANGELOG.md',
|
20
|
+
'wiki_uri' => 'https://github.com/ARtoriouSs/purr-pr/wiki',
|
21
|
+
'homepage_uri' => 'https://github.com/ARtoriouSs/purr-pr'
|
22
|
+
}
|
23
|
+
|
24
|
+
spec.require_paths = ['lib']
|
25
|
+
spec.bindir = 'bin'
|
26
|
+
spec.executables << 'purr'
|
27
|
+
|
28
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |file| file.match(%r{^spec/}) }
|
29
|
+
spec.test_files = `git ls-files -- spec`.split("\n")
|
30
|
+
|
31
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
32
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
33
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
34
|
+
spec.add_development_dependency 'pry'
|
35
|
+
end
|
data/spec/purr_spec.rb
CHANGED
@@ -1,11 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
describe PurrPr do
|
4
4
|
it "has a version number" do
|
5
|
-
expect(
|
6
|
-
end
|
7
|
-
|
8
|
-
it "does something useful" do
|
9
|
-
expect(false).to eq(true)
|
5
|
+
expect(PurrPr::VERSION).not_to be nil
|
10
6
|
end
|
11
7
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,12 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "
|
3
|
+
require "purr_pr"
|
4
4
|
|
5
5
|
RSpec.configure do |config|
|
6
|
-
# Enable flags like --only-failures and --next-failure
|
7
6
|
config.example_status_persistence_file_path = ".rspec_status"
|
8
|
-
|
9
|
-
# Disable RSpec exposing methods globally on `Module` and `main`
|
10
7
|
config.disable_monkey_patching!
|
11
8
|
|
12
9
|
config.expect_with :rspec do |c|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: purr-pr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Teslovskiy
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-01-
|
11
|
+
date: 2022-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
description:
|
69
|
+
description: Purr PR is a tool to automate pull request formatting via GitHub CLI
|
70
70
|
email: artoriousso@gmail.com
|
71
71
|
executables:
|
72
72
|
- purr
|
@@ -86,25 +86,26 @@ files:
|
|
86
86
|
- bin/console
|
87
87
|
- bin/purr
|
88
88
|
- bin/setup
|
89
|
-
- lib/
|
90
|
-
- lib/
|
91
|
-
- lib/
|
92
|
-
- lib/
|
93
|
-
- lib/
|
94
|
-
-
|
89
|
+
- lib/purr_pr.rb
|
90
|
+
- lib/purr_pr/actions.rb
|
91
|
+
- lib/purr_pr/config.rb
|
92
|
+
- lib/purr_pr/editor.rb
|
93
|
+
- lib/purr_pr/text_objects.rb
|
94
|
+
- lib/purr_pr/version.rb
|
95
|
+
- purr_pr.gemspec
|
95
96
|
- spec/purr_spec.rb
|
96
97
|
- spec/spec_helper.rb
|
97
|
-
homepage: https://github.com/ARtoriouSs/purr
|
98
|
+
homepage: https://github.com/ARtoriouSs/purr-pr
|
98
99
|
licenses:
|
99
100
|
- MIT
|
100
101
|
metadata:
|
101
|
-
documentation_uri: https://github.com/ARtoriouSs/purr/blob/master/README.md
|
102
|
-
bug_tracker_uri: https://github.com/ARtoriouSs/purr/issues
|
103
|
-
source_code_uri: https://github.com/ARtoriouSs/purr
|
104
|
-
changelog_uri: https://github.com/ARtoriouSs/purr/blob/master/CHANGELOG.md
|
105
|
-
wiki_uri: https://github.com/ARtoriouSs/purr/wiki
|
106
|
-
homepage_uri: https://github.com/ARtoriouSs/purr
|
107
|
-
post_install_message:
|
102
|
+
documentation_uri: https://github.com/ARtoriouSs/purr-pr/blob/master/README.md
|
103
|
+
bug_tracker_uri: https://github.com/ARtoriouSs/purr-pr/issues
|
104
|
+
source_code_uri: https://github.com/ARtoriouSs/purr-pr
|
105
|
+
changelog_uri: https://github.com/ARtoriouSs/purr-pr/blob/master/CHANGELOG.md
|
106
|
+
wiki_uri: https://github.com/ARtoriouSs/purr-pr/wiki
|
107
|
+
homepage_uri: https://github.com/ARtoriouSs/purr-pr
|
108
|
+
post_install_message:
|
108
109
|
rdoc_options: []
|
109
110
|
require_paths:
|
110
111
|
- lib
|
@@ -119,10 +120,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
120
|
- !ruby/object:Gem::Version
|
120
121
|
version: '0'
|
121
122
|
requirements: []
|
122
|
-
rubygems_version: 3.
|
123
|
-
signing_key:
|
123
|
+
rubygems_version: 3.2.3
|
124
|
+
signing_key:
|
124
125
|
specification_version: 4
|
125
|
-
summary:
|
126
|
+
summary: A CLI pull request formatter
|
126
127
|
test_files:
|
127
128
|
- spec/purr_spec.rb
|
128
129
|
- spec/spec_helper.rb
|
data/lib/purr.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'purr/version'
|
4
|
-
require_relative 'purr/editor.rb'
|
5
|
-
|
6
|
-
require 'pry' # TODO
|
7
|
-
|
8
|
-
module Purr
|
9
|
-
def self.title(&block)
|
10
|
-
@title = edit(:title, &block)
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.body(&block)
|
14
|
-
@body = edit(:body, &block)
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.assignee(assignee)
|
18
|
-
@assignee = assignee
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.self_assign
|
22
|
-
assignee('@me')
|
23
|
-
end
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
def edit(subject, &block)
|
28
|
-
editor = Editor.new(subject)
|
29
|
-
|
30
|
-
catch(:abort) { editor.evaluate(&block) }
|
31
|
-
|
32
|
-
interrupt if editor.interrupted?
|
33
|
-
|
34
|
-
editor.content
|
35
|
-
end
|
36
|
-
|
37
|
-
def interrupt
|
38
|
-
puts 'aborted'
|
39
|
-
exit
|
40
|
-
end
|
41
|
-
end
|
data/purr.gemspec
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
lib = File.expand_path('../lib', __FILE__)
|
4
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
-
require 'purr/version'
|
6
|
-
|
7
|
-
require_relative "lib/purr/version"
|
8
|
-
|
9
|
-
Gem::Specification.new do |spec|
|
10
|
-
spec.name = 'purr-pr'
|
11
|
-
spec.version = Purr::VERSION
|
12
|
-
spec.author = 'Alexander Teslovskiy'
|
13
|
-
spec.email = 'artoriousso@gmail.com'
|
14
|
-
spec.summary = ''
|
15
|
-
spec.description = ''
|
16
|
-
spec.homepage = 'https://github.com/ARtoriouSs/purr'
|
17
|
-
spec.license = 'MIT'
|
18
|
-
|
19
|
-
spec.metadata = {
|
20
|
-
'documentation_uri' => 'https://github.com/ARtoriouSs/purr/blob/master/README.md',
|
21
|
-
'bug_tracker_uri' => 'https://github.com/ARtoriouSs/purr/issues',
|
22
|
-
'source_code_uri' => 'https://github.com/ARtoriouSs/purr',
|
23
|
-
'changelog_uri' => 'https://github.com/ARtoriouSs/purr/blob/master/CHANGELOG.md',
|
24
|
-
'wiki_uri' => 'https://github.com/ARtoriouSs/purr/wiki',
|
25
|
-
'homepage_uri' => 'https://github.com/ARtoriouSs/purr'
|
26
|
-
}
|
27
|
-
|
28
|
-
spec.require_paths = ['lib']
|
29
|
-
spec.bindir = 'bin'
|
30
|
-
|
31
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |file| file.match(%r{^spec/}) }
|
32
|
-
spec.test_files = `git ls-files -- spec`.split("\n")
|
33
|
-
spec.executables << 'purr'
|
34
|
-
|
35
|
-
spec.add_development_dependency 'bundler', '~> 2.0'
|
36
|
-
spec.add_development_dependency 'rake', '~> 13.0'
|
37
|
-
spec.add_development_dependency 'rspec', '~> 3.0'
|
38
|
-
spec.add_development_dependency 'pry'
|
39
|
-
end
|