Class: Git::Pr
- Inherits:
-
Object
show all
- Defined in:
- lib/git/pr.rb,
lib/git/pr/github.rb,
lib/git/pr/version.rb,
lib/git/pr/cli_options.rb,
lib/git/pr/git_properties.rb
Defined Under Namespace
Classes: CliOptions, GitHub, GitProperties
Constant Summary
collapse
- VERSION =
'0.0.4'
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(args) ⇒ Pr
Returns a new instance of Pr.
12
13
14
15
|
# File 'lib/git/pr.rb', line 12
def initialize(args)
@args = args
@github = GitHub.new(GitProperties.new)
end
|
Class Method Details
.run(args) ⇒ Object
8
9
10
|
# File 'lib/git/pr.rb', line 8
def self.run(args)
new(args).run
end
|
Instance Method Details
#list ⇒ Object
28
29
30
31
|
# File 'lib/git/pr.rb', line 28
def list
prs = @github.list_pull_requests(@options.profile, @options.mine)
puts formatted(prs)
end
|
#run ⇒ Object
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/git/pr.rb', line 17
def run
@options = CliOptions.parse(@args)
if self.respond_to?(@options.subcommand)
self.send(@options.subcommand)
else
be_helpful
end
rescue CliOptions::Invalid => e
be_helpful(e.message)
end
|
#submit ⇒ Object
33
34
35
36
37
38
39
|
# File 'lib/git/pr.rb', line 33
def submit
pr = @github.submit_pull_request(@options.title, @options.message)
puts "Opened new pull request to merge #{pr.head.ref} into #{pr.base.repo.full_name}/#{pr.base.ref}"
rescue GitHub::Failed => e
$stderr.puts "Failed to open new pull request: #{e.message}"
exit 1
end
|
#version ⇒ Object
41
42
43
|
# File 'lib/git/pr.rb', line 41
def version
puts Git::Pr::VERSION
end
|