github_tools 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +21 -0
- data/Rakefile +2 -0
- data/bin/github_tools +7 -0
- data/github_tools.gemspec +26 -0
- data/lib/github_tools.rb +14 -0
- data/lib/github_tools/cli.rb +28 -0
- data/lib/github_tools/configuration.rb +38 -0
- data/lib/github_tools/version.rb +3 -0
- metadata +113 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: eaefc9c98f2b814a312ade25a04c99065f0fd221
|
4
|
+
data.tar.gz: 47e95b5b52e0fe12456710aff01d8721c80d6c9d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8949c4974ffb2771b525b54b1cb070deaade5817aa406e3b2eecefb273f972ddd9e46eb45f021c96638526c11ca82db830dfcab0fce3b2620e3ae23ce16be62f
|
7
|
+
data.tar.gz: d4a4903984dd979cc7e6d7dc5dbb9d3e763d36dde718f2f4df1d9e757d28425646af9a1987d792bfba1acc2eef621579fe1bac9ad90bf55119bd26b632a3a61d
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
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
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Ivan Tse
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# GithubTools
|
2
|
+
|
3
|
+
A collection of GitHub command line commands for a better workflow. GithubTools is a command line that bundles a variety of functionality that better integrates GitHub with Git.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Install via RubyGems:
|
8
|
+
|
9
|
+
gem install github_tools
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
TODO: Write usage instructions here
|
14
|
+
|
15
|
+
## Contributing
|
16
|
+
|
17
|
+
1. Fork it ( https://github.com/ivantsepp/github_tools/fork )
|
18
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
19
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
20
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
21
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/github_tools
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 'github_tools/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "github_tools"
|
8
|
+
spec.version = GithubTools::VERSION
|
9
|
+
spec.authors = ["Ivan Tse"]
|
10
|
+
spec.email = ["ivan.tse1@gmail.com"]
|
11
|
+
spec.summary = %q{A collection of GitHub command line commands for a better workflow}
|
12
|
+
spec.description = %q{GithubTools is a command line that bundles a variety of functionality that better integrates GitHub with Git.}
|
13
|
+
spec.homepage = "https://github.com/ivantsepp/github_tools"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency('octokit', "~> 3.0")
|
22
|
+
spec.add_runtime_dependency('thor', "~> 0.19")
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
25
|
+
spec.add_development_dependency "rake"
|
26
|
+
end
|
data/lib/github_tools.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'octokit'
|
2
|
+
require 'thor'
|
3
|
+
|
4
|
+
require 'github_tools/version'
|
5
|
+
require 'github_tools/configuration'
|
6
|
+
require 'github_tools/cli'
|
7
|
+
|
8
|
+
module GithubTools
|
9
|
+
extend self
|
10
|
+
|
11
|
+
def client
|
12
|
+
client = Octokit::Client.new(:access_token => Configuration.token)
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module GithubTools
|
2
|
+
class CLI < Thor
|
3
|
+
include Thor::Actions
|
4
|
+
|
5
|
+
desc "open <pull_request_id>", "Opens the files for the corresponding pull request with your editor."
|
6
|
+
long_desc <<-LONGDESC
|
7
|
+
Open files with changes pertaining to a pull request. A side effect of this action is that
|
8
|
+
you will be in the latest SHA of that pull request.
|
9
|
+
LONGDESC
|
10
|
+
def open_pull_request(id)
|
11
|
+
status = silent_run 'git status --porcelain 2>/dev/null'
|
12
|
+
raise Thor::Error.new('You have uncommitted changes') unless status.empty?
|
13
|
+
ENV['EDITOR'] = ask("Enter your text editor command:\n") if ENV['EDITOR'].nil?
|
14
|
+
|
15
|
+
pull_files = GithubTools.client.pull_files(Configuration.remote, id)
|
16
|
+
filenames = pull_files.collect(&:filename)
|
17
|
+
silent_run "git fetch origin pull/#{id}/head:"
|
18
|
+
run 'git checkout FETCH_HEAD', :verbose => false
|
19
|
+
silent_run "#{ENV['EDITOR']} #{filenames.join(' ')}"
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def silent_run(cmd)
|
25
|
+
run(cmd, :verbose => false, :capture => true)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module GithubTools
|
2
|
+
module Configuration
|
3
|
+
extend self
|
4
|
+
|
5
|
+
def token
|
6
|
+
token = `git config githubtools.token`.strip
|
7
|
+
token = create_token if token.empty?
|
8
|
+
token
|
9
|
+
end
|
10
|
+
|
11
|
+
def create_token
|
12
|
+
print 'Username:'
|
13
|
+
username = gets.strip
|
14
|
+
print 'Password (never saved):'
|
15
|
+
password = STDIN.noecho(&:gets).strip
|
16
|
+
client = Octokit::Client.new(:login => username, :password => password)
|
17
|
+
response = client.create_authorization(
|
18
|
+
:scopes => [:repo],
|
19
|
+
:note => 'github_tools',
|
20
|
+
:note_url =>'https://github.com/ivantsepp/github_tools')
|
21
|
+
token = response[:token]
|
22
|
+
save_token(token)
|
23
|
+
token
|
24
|
+
end
|
25
|
+
|
26
|
+
def save_token(token)
|
27
|
+
`git config --global githubtools.token #{token}`
|
28
|
+
end
|
29
|
+
|
30
|
+
def remote
|
31
|
+
url = `git config --get remote.origin.url`.strip
|
32
|
+
url = 'ssh://' + url if url.include?('@')
|
33
|
+
url.gsub!('.git', '')
|
34
|
+
Octokit::Repository.from_url(url)
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: github_tools
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ivan Tse
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: octokit
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: thor
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.19'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.19'
|
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.6'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.6'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: GithubTools is a command line that bundles a variety of functionality
|
70
|
+
that better integrates GitHub with Git.
|
71
|
+
email:
|
72
|
+
- ivan.tse1@gmail.com
|
73
|
+
executables:
|
74
|
+
- github_tools
|
75
|
+
extensions: []
|
76
|
+
extra_rdoc_files: []
|
77
|
+
files:
|
78
|
+
- ".gitignore"
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/github_tools
|
84
|
+
- github_tools.gemspec
|
85
|
+
- lib/github_tools.rb
|
86
|
+
- lib/github_tools/cli.rb
|
87
|
+
- lib/github_tools/configuration.rb
|
88
|
+
- lib/github_tools/version.rb
|
89
|
+
homepage: https://github.com/ivantsepp/github_tools
|
90
|
+
licenses:
|
91
|
+
- MIT
|
92
|
+
metadata: {}
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options: []
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
requirements: []
|
108
|
+
rubyforge_project:
|
109
|
+
rubygems_version: 2.2.2
|
110
|
+
signing_key:
|
111
|
+
specification_version: 4
|
112
|
+
summary: A collection of GitHub command line commands for a better workflow
|
113
|
+
test_files: []
|