pull 0.0.2

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.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in pull.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Gabe Berke-Williams
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,44 @@
1
+ # Pull
2
+
3
+ Creates Github pull requests from the command line.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'pull'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install pull
18
+
19
+ ## Usage
20
+
21
+ The gem assumes that you have a Github remote named "origin".
22
+
23
+ # This breaks if your branch isn't on Github.
24
+ $ git push origin your-branch
25
+ $ pull
26
+ Making a pull request for your-branch!
27
+
28
+ https://github.com/USER/REPO/pull/1
29
+
30
+ Voila.
31
+
32
+ ## Thanks
33
+
34
+ Thanks to Nick Quaranto ([qrush](https://github.com/qrush)) for writing the
35
+ first version of this script and leaving a version of it in every project he
36
+ touched.
37
+
38
+ ## Contributing
39
+
40
+ 1. Fork it
41
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
42
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
43
+ 4. Push to the branch (`git push origin my-new-feature`)
44
+ 5. Create new Pull Request
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'json'
4
+ require 'net/https'
5
+
6
+ def api_uri
7
+ # This uses the deprecated V2 API because that lets you use your token instead
8
+ # of entering your password all the time.
9
+ remote_url = `git remote show -n origin`.split("\n").grep(/Push/).first.split.grep(/github/)[0]
10
+ user_and_repo = remote_url.split(':')[1].sub(/\.git$/, '')
11
+ URI.parse("https://github.com/api/v2/json/pulls/#{user_and_repo}")
12
+ end
13
+
14
+ def current_branch
15
+ `git symbolic-ref HEAD`.strip.sub("refs/heads/", "")
16
+ end
17
+
18
+ def current_user
19
+ `git config github.user`.strip
20
+ end
21
+
22
+ def current_token
23
+ `git config github.token`.strip
24
+ end
25
+
26
+ def ensure_github_token_is_set
27
+ if current_token.empty?
28
+ puts "Please set github.token: git config --global github.token <TOKEN>"
29
+ exit 1
30
+ end
31
+ end
32
+
33
+ ensure_github_token_is_set
34
+
35
+ puts "Making a pull request for #{current_branch}!"
36
+ puts
37
+
38
+ def try_to_create_pull_request
39
+ post = Net::HTTP::Post.new(api_uri.request_uri)
40
+ post.basic_auth("#{current_user}/token", current_token)
41
+ post.set_form_data("pull[base]" => "master",
42
+ "pull[head]" => current_branch,
43
+ "pull[title]" => current_branch)
44
+
45
+ http = Net::HTTP.new(api_uri.host, api_uri.port)
46
+ http.use_ssl = true
47
+ response = http.request(post)
48
+ response.body
49
+ end
50
+
51
+ json = JSON.parse(try_to_create_pull_request)
52
+
53
+ if json.key?('error')
54
+ puts "ERROR:"
55
+ puts [json['error']].flatten.join("\n")
56
+ exit 1
57
+ else
58
+ pull_url = json['pull']['html_url']
59
+ puts pull_url
60
+ end
@@ -0,0 +1,4 @@
1
+ require "pull/version"
2
+
3
+ module Pull
4
+ end
@@ -0,0 +1,3 @@
1
+ module Pull
2
+ VERSION = "0.0.2"
3
+ end
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/pull/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Gabe Berke-Williams"]
6
+ gem.email = ["gabe@thoughtbot.com"]
7
+ gem.description = %q{Easily create Github pull requests from the command line.}
8
+ gem.summary = %q{Easily create Github pull requests from the command line.}
9
+ gem.homepage = "https://github.com/gabebw/pull"
10
+
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.name = "pull"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Pull::VERSION
17
+
18
+ gem.add_dependency("json")
19
+ end
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pull
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Gabe Berke-Williams
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-02-10 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: json
16
+ requirement: &2164282480 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *2164282480
25
+ description: Easily create Github pull requests from the command line.
26
+ email:
27
+ - gabe@thoughtbot.com
28
+ executables:
29
+ - pull
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - .gitignore
34
+ - Gemfile
35
+ - LICENSE
36
+ - README.md
37
+ - Rakefile
38
+ - bin/pull
39
+ - lib/pull.rb
40
+ - lib/pull/version.rb
41
+ - pull.gemspec
42
+ homepage: https://github.com/gabebw/pull
43
+ licenses: []
44
+ post_install_message:
45
+ rdoc_options: []
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ! '>='
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ requirements: []
61
+ rubyforge_project:
62
+ rubygems_version: 1.8.11
63
+ signing_key:
64
+ specification_version: 3
65
+ summary: Easily create Github pull requests from the command line.
66
+ test_files: []
67
+ has_rdoc: