purr-pr 0.1.6 → 0.1.7
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/lib/purr_pr/config.rb +10 -10
- data/lib/purr_pr/editor.rb +13 -2
- data/lib/purr_pr/shell_helpers.rb +13 -0
- data/lib/purr_pr/version.rb +1 -1
- data/lib/purr_pr.rb +10 -1
- data/purr_pr.gemspec +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c4bbf318a7b60cfa3cd5c57416dd3f66764b99928e78330a7d04f69b7c095ca
|
4
|
+
data.tar.gz: 8040ce5923ece5149ab563b12b223fad7f3d705d80e37a7c9a71ff82237faa96
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e2cc29dd764cecbf87bca385874511dd1c0eb677b2bf77a2fb7ee4e415d28f70a6fb98123fa16647d54bde0d94c43a0d59a2004cf8d8abd534404b9c6a1cd7a
|
7
|
+
data.tar.gz: 5dbeeec11460198a30528260c2e6964d9919669fa8084196b029f9ddbd3fb8e2eb12de87740bf1230db83b3a033610bd9399d0fe1807f107a2f7da256a3ff8ec
|
data/Gemfile.lock
CHANGED
data/lib/purr_pr/config.rb
CHANGED
@@ -9,18 +9,18 @@ class PurrPr
|
|
9
9
|
attr_reader :title, :body, :assignee
|
10
10
|
|
11
11
|
def initialize
|
12
|
-
#
|
12
|
+
# defaults - if setter is not called
|
13
13
|
@maintainer_edit = true
|
14
14
|
@reviewers = []
|
15
15
|
@labels = []
|
16
16
|
end
|
17
17
|
|
18
|
-
def title(&block)
|
19
|
-
@title = edit(:title, &block)
|
18
|
+
def title(text = '', &block)
|
19
|
+
@title = edit(:title, content: text, &block)
|
20
20
|
end
|
21
21
|
|
22
|
-
def body(&block)
|
23
|
-
@body = edit(:body, &block)
|
22
|
+
def body(text = '', &block)
|
23
|
+
@body = edit(:body, content: text, &block)
|
24
24
|
end
|
25
25
|
|
26
26
|
def assignee(assignee)
|
@@ -48,7 +48,7 @@ class PurrPr
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def labels(labels)
|
51
|
-
@labels
|
51
|
+
@labels += labels
|
52
52
|
end
|
53
53
|
|
54
54
|
def label(label)
|
@@ -56,7 +56,7 @@ class PurrPr
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def reviewers(reviewers)
|
59
|
-
@reviewers
|
59
|
+
@reviewers += reviewers
|
60
60
|
end
|
61
61
|
|
62
62
|
def reviewer(reviewer)
|
@@ -78,10 +78,10 @@ class PurrPr
|
|
78
78
|
|
79
79
|
private
|
80
80
|
|
81
|
-
def edit(subject, &block)
|
82
|
-
editor = Editor.new(subject)
|
81
|
+
def edit(subject, content: '', &block)
|
82
|
+
editor = Editor.new(subject, content: content)
|
83
83
|
|
84
|
-
catch(:abort) { editor.evaluate(&block) }
|
84
|
+
catch(:abort) { editor.evaluate(&block) } if block_given?
|
85
85
|
|
86
86
|
interrupt if editor.interrupted?
|
87
87
|
|
data/lib/purr_pr/editor.rb
CHANGED
@@ -5,16 +5,19 @@ require 'tempfile'
|
|
5
5
|
|
6
6
|
require_relative 'text_objects'
|
7
7
|
require_relative 'actions'
|
8
|
+
require_relative 'shell_helpers'
|
8
9
|
|
9
10
|
class PurrPr
|
10
11
|
class Editor
|
11
12
|
include TextObjects
|
12
13
|
include Actions
|
14
|
+
include ShellHelpers
|
13
15
|
|
14
16
|
attr_reader :content, :subject
|
15
17
|
|
16
|
-
def initialize(subject
|
17
|
-
@
|
18
|
+
def initialize(subject, content: '')
|
19
|
+
@subject = subject.to_s
|
20
|
+
@content = content
|
18
21
|
end
|
19
22
|
|
20
23
|
def evaluate(&block)
|
@@ -38,6 +41,14 @@ class PurrPr
|
|
38
41
|
@content.gsub!(text, with)
|
39
42
|
end
|
40
43
|
|
44
|
+
def delete(text)
|
45
|
+
replace(text, with: '')
|
46
|
+
end
|
47
|
+
|
48
|
+
def clear
|
49
|
+
@content = ''
|
50
|
+
end
|
51
|
+
|
41
52
|
def edit(format: :md)
|
42
53
|
name = subject + SecureRandom.hex(8)
|
43
54
|
format = ".#{format}" unless format.nil?
|
data/lib/purr_pr/version.rb
CHANGED
data/lib/purr_pr.rb
CHANGED
@@ -4,6 +4,8 @@ require_relative 'purr_pr/version'
|
|
4
4
|
require_relative 'purr_pr/editor.rb'
|
5
5
|
require_relative 'purr_pr/config.rb'
|
6
6
|
|
7
|
+
require 'tempfile'
|
8
|
+
|
7
9
|
class PurrPr
|
8
10
|
attr_reader :config_file_path, :config
|
9
11
|
|
@@ -17,9 +19,14 @@ class PurrPr
|
|
17
19
|
def create
|
18
20
|
config.instance_eval(config_code)
|
19
21
|
|
22
|
+
# use file for body to avoid quotes issues
|
23
|
+
body_file = Tempfile.new
|
24
|
+
body_file.write(config.values.body)
|
25
|
+
body_file.rewind
|
26
|
+
|
20
27
|
command = 'gh pr create'
|
21
28
|
command += " --title '#{config.values.title}'" if config.values.title
|
22
|
-
command += " --body '#{
|
29
|
+
command += " --body-file '#{body_file.path}'"
|
23
30
|
command += " --assignee #{config.values.assignee}" if config.values.assignee
|
24
31
|
command += " --base #{config.values.base}" if config.values.base
|
25
32
|
command += ' --draft' if config.values.draft
|
@@ -39,6 +46,8 @@ class PurrPr
|
|
39
46
|
command += ARGV.join(' ').prepend(' ')
|
40
47
|
|
41
48
|
system(command)
|
49
|
+
ensure
|
50
|
+
body_file.close
|
42
51
|
end
|
43
52
|
|
44
53
|
private
|
data/purr_pr.gemspec
CHANGED
@@ -31,5 +31,5 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
32
32
|
spec.add_development_dependency 'rake', '~> 13.0'
|
33
33
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
34
|
-
spec.add_development_dependency 'pry'
|
34
|
+
spec.add_development_dependency 'pry', '~> 0.14.1'
|
35
35
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Teslovskiy
|
@@ -56,16 +56,16 @@ dependencies:
|
|
56
56
|
name: pry
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 0.14.1
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 0.14.1
|
69
69
|
description: Purr PR is a tool to automate pull request formatting via GitHub CLI
|
70
70
|
email: artoriousso@gmail.com
|
71
71
|
executables:
|
@@ -90,6 +90,7 @@ files:
|
|
90
90
|
- lib/purr_pr/actions.rb
|
91
91
|
- lib/purr_pr/config.rb
|
92
92
|
- lib/purr_pr/editor.rb
|
93
|
+
- lib/purr_pr/shell_helpers.rb
|
93
94
|
- lib/purr_pr/text_objects.rb
|
94
95
|
- lib/purr_pr/version.rb
|
95
96
|
- purr_pr.gemspec
|