pullrequest 0.1.0
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 +7 -0
- data/.gitignore +9 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/exe/pullrequest +36 -0
- data/lib/pullrequest.rb +3 -0
- data/lib/pullrequest/bitbucket.rb +85 -0
- data/lib/pullrequest/shell.rb +7 -0
- data/lib/pullrequest/thor.rb +35 -0
- data/lib/pullrequest/version.rb +3 -0
- data/pullrequest.gemspec +26 -0
- metadata +115 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 51a50bd60f262b845aba22d34f1e3cbcccfb315d
|
|
4
|
+
data.tar.gz: 6a4c6da5da6a65c26c8120e806663c55d94f8316
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 48f6154a1b06a34dd1068732f767caacfd1c65b2f06498862d4d8e614616a3323250b450b8e346553527b0d4653c504c9a0ed190cd835b01aa13d8b81c726523
|
|
7
|
+
data.tar.gz: f26f73b224862a45fd68c8ac62fb32afb5f2c5589543b53e9818336e7a9650be876a27ebd299c074dd70ef3e41f759b5af9cd4c9191e1118e20f06b535f703a3
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015 Zubin Henner
|
|
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
|
|
13
|
+
all 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
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Pullrequest
|
|
2
|
+
|
|
3
|
+
CLI for submitting Bitbucket pull requests
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
$ gem install pullrequest
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
$ pullrequest submit
|
|
12
|
+
|
|
13
|
+
You will be prompted to enter details for your pull request.
|
|
14
|
+
The command will be shown before asking confirmation to execute it.
|
|
15
|
+
|
|
16
|
+
## TODO
|
|
17
|
+
|
|
18
|
+
* Add `pullrequest` to path
|
|
19
|
+
* Add review option at confirmation (start again with previous answers as defaults).
|
|
20
|
+
* Optionally cache Bitbucket credentials.
|
|
21
|
+
* Add GitHub support.
|
|
22
|
+
|
|
23
|
+
## Contributing
|
|
24
|
+
|
|
25
|
+
1. Fork it ( https://github.com/zubin/pullrequest/fork )
|
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
29
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "pullrequest"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/exe/pullrequest
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
lib = File.expand_path('../../lib', __FILE__)
|
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
|
+
|
|
6
|
+
require 'pullrequest'
|
|
7
|
+
require 'pullrequest/thor'
|
|
8
|
+
|
|
9
|
+
module Pullrequest
|
|
10
|
+
class CLI < Thor
|
|
11
|
+
include Pullrequest::Shell
|
|
12
|
+
|
|
13
|
+
no_commands do
|
|
14
|
+
def command
|
|
15
|
+
@command ||= repo_class.new(self).command
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def repo_class
|
|
19
|
+
Bitbucket
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
desc "submit", "Submits pull request"
|
|
24
|
+
def submit
|
|
25
|
+
command
|
|
26
|
+
if yes? "Print command?"
|
|
27
|
+
$stdout.puts command
|
|
28
|
+
end
|
|
29
|
+
if yes? "Proceed?"
|
|
30
|
+
execute command
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
Pullrequest::CLI.start(ARGV)
|
data/lib/pullrequest.rb
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
require 'thor'
|
|
3
|
+
|
|
4
|
+
module Pullrequest
|
|
5
|
+
class Bitbucket
|
|
6
|
+
attr_reader :context
|
|
7
|
+
|
|
8
|
+
def initialize(context)
|
|
9
|
+
@context = context
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def command
|
|
13
|
+
data # ask these questions first
|
|
14
|
+
[
|
|
15
|
+
"curl",
|
|
16
|
+
"-X POST",
|
|
17
|
+
"-H 'Content-Type: application/json'",
|
|
18
|
+
"-u #{username}:#{password}",
|
|
19
|
+
"https://bitbucket.org/api/2.0/repositories/#{dest_repo}/pullrequests",
|
|
20
|
+
"-d '#{data.to_json}'",
|
|
21
|
+
].join(' ')
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
private
|
|
25
|
+
|
|
26
|
+
def ask(*args)
|
|
27
|
+
context.ask *args
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def current_branch
|
|
31
|
+
`git rev-parse --abbrev-ref HEAD`.chomp
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def current_repo
|
|
35
|
+
`git remote -v`[/bitbucket.org\:([^\.]+)\.git/, 1]
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def data
|
|
39
|
+
@data ||= {
|
|
40
|
+
title: ask("Title of pull request", required: true),
|
|
41
|
+
description: ask("Description of pull request"),
|
|
42
|
+
source: {
|
|
43
|
+
repository: {full_name: source_repo},
|
|
44
|
+
branch: {name: source_branch},
|
|
45
|
+
},
|
|
46
|
+
destination: {
|
|
47
|
+
repository: {full_name: dest_repo},
|
|
48
|
+
branch: {name: dest_branch},
|
|
49
|
+
},
|
|
50
|
+
reviewers: reviewer_usernames.map { |username| {username: username} },
|
|
51
|
+
close_source_branch: true,
|
|
52
|
+
}
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def dest_branch
|
|
56
|
+
ask("Destination branch", default: 'master', required: true)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def dest_repo
|
|
60
|
+
ask("Destination Bitbucket repo (account_name/report_name)", default: current_repo, required: true)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def password
|
|
64
|
+
ask("Your Bitbucket password", echo: false, required: true).tap do
|
|
65
|
+
$stdout.puts # force newline
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def source_branch
|
|
70
|
+
ask("Source branch (your local branch)", default: current_branch, required: true)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def source_repo
|
|
74
|
+
current_repo
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def reviewer_usernames
|
|
78
|
+
ask("Reviewers (enter comma-separated usernames)", default: "<none>").split(',').map(&:strip).reject { |u| u == '' }
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def username
|
|
82
|
+
ask "Your Bitbucket username", required: true
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require 'thor'
|
|
2
|
+
|
|
3
|
+
# Added 'required' option and stricter yes/no.
|
|
4
|
+
Thor::Shell::Basic.class_eval do
|
|
5
|
+
alias :ask_original :ask
|
|
6
|
+
def ask(statement, *args)
|
|
7
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
|
8
|
+
color = args.first
|
|
9
|
+
statement << " [#{options[:required] ? 'required' : 'optional'}]\n>"
|
|
10
|
+
begin
|
|
11
|
+
response = ask_original(statement, color, options)
|
|
12
|
+
if options[:required] && response == ''
|
|
13
|
+
raise Thor::RequiredArgumentMissingError
|
|
14
|
+
end
|
|
15
|
+
response
|
|
16
|
+
rescue Thor::RequiredArgumentMissingError
|
|
17
|
+
say "Error: required", :red
|
|
18
|
+
retry
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def no?(statement, color = nil)
|
|
23
|
+
ask_bool('n', statement, color)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def yes?(statement, color = nil)
|
|
27
|
+
ask_bool('y', statement, color)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
private
|
|
31
|
+
|
|
32
|
+
def ask_bool(y_or_n, statement, color)
|
|
33
|
+
ask_original(statement, color, add_to_history: false, limited_to: %w[yes no y n])[0] == y_or_n
|
|
34
|
+
end
|
|
35
|
+
end
|
data/pullrequest.gemspec
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'pullrequest/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "pullrequest"
|
|
8
|
+
spec.version = Pullrequest::VERSION
|
|
9
|
+
spec.authors = ["Zubin Henner"]
|
|
10
|
+
spec.email = ["zubin@rubidium.com.au"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{CLI for submitting Bitbucket pull requests}
|
|
13
|
+
spec.homepage = "https://github.com/zubin/pullrequest"
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
|
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
17
|
+
spec.bindir = "exe"
|
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
19
|
+
spec.require_paths = ["lib"]
|
|
20
|
+
|
|
21
|
+
spec.add_dependency 'thor'
|
|
22
|
+
spec.add_dependency 'json'
|
|
23
|
+
|
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.9'
|
|
25
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
|
26
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: pullrequest
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Zubin Henner
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2015-05-03 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: thor
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: json
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: bundler
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '1.9'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '1.9'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rake
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '10.0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '10.0'
|
|
69
|
+
description:
|
|
70
|
+
email:
|
|
71
|
+
- zubin@rubidium.com.au
|
|
72
|
+
executables:
|
|
73
|
+
- pullrequest
|
|
74
|
+
extensions: []
|
|
75
|
+
extra_rdoc_files: []
|
|
76
|
+
files:
|
|
77
|
+
- ".gitignore"
|
|
78
|
+
- Gemfile
|
|
79
|
+
- LICENSE.txt
|
|
80
|
+
- README.md
|
|
81
|
+
- Rakefile
|
|
82
|
+
- bin/console
|
|
83
|
+
- bin/setup
|
|
84
|
+
- exe/pullrequest
|
|
85
|
+
- lib/pullrequest.rb
|
|
86
|
+
- lib/pullrequest/bitbucket.rb
|
|
87
|
+
- lib/pullrequest/shell.rb
|
|
88
|
+
- lib/pullrequest/thor.rb
|
|
89
|
+
- lib/pullrequest/version.rb
|
|
90
|
+
- pullrequest.gemspec
|
|
91
|
+
homepage: https://github.com/zubin/pullrequest
|
|
92
|
+
licenses:
|
|
93
|
+
- MIT
|
|
94
|
+
metadata: {}
|
|
95
|
+
post_install_message:
|
|
96
|
+
rdoc_options: []
|
|
97
|
+
require_paths:
|
|
98
|
+
- lib
|
|
99
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - ">="
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '0'
|
|
104
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
|
+
requirements:
|
|
106
|
+
- - ">="
|
|
107
|
+
- !ruby/object:Gem::Version
|
|
108
|
+
version: '0'
|
|
109
|
+
requirements: []
|
|
110
|
+
rubyforge_project:
|
|
111
|
+
rubygems_version: 2.4.5
|
|
112
|
+
signing_key:
|
|
113
|
+
specification_version: 4
|
|
114
|
+
summary: CLI for submitting Bitbucket pull requests
|
|
115
|
+
test_files: []
|