github 0.1.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +37 -0
- data/Manifest +33 -12
- data/README.md +187 -0
- data/Rakefile +44 -0
- data/bin/gh +8 -0
- data/bin/github +4 -1
- data/github.gemspec +29 -34
- data/lib/commands/commands.rb +249 -0
- data/lib/commands/helpers.rb +486 -0
- data/lib/commands/issues.rb +17 -0
- data/lib/commands/network.rb +110 -0
- data/lib/github.rb +117 -29
- data/lib/github/command.rb +69 -14
- data/lib/github/extensions.rb +39 -0
- data/lib/github/ui.rb +19 -0
- data/setup.rb +1551 -0
- data/spec/command_spec.rb +82 -0
- data/spec/commands/command_browse_spec.rb +36 -0
- data/spec/commands/command_clone_spec.rb +87 -0
- data/spec/commands/command_create-from-local_spec.rb +7 -0
- data/spec/commands/command_fetch_spec.rb +56 -0
- data/spec/commands/command_fork_spec.rb +44 -0
- data/spec/commands/command_helper.rb +170 -0
- data/spec/commands/command_home_spec.rb +20 -0
- data/spec/commands/command_info_spec.rb +23 -0
- data/spec/commands/command_issues_spec.rb +97 -0
- data/spec/commands/command_network_spec.rb +30 -0
- data/spec/commands/command_pull-request_spec.rb +51 -0
- data/spec/commands/command_pull_spec.rb +82 -0
- data/spec/commands/command_search_spec.rb +34 -0
- data/spec/commands/command_track_spec.rb +82 -0
- data/spec/commands_spec.rb +49 -0
- data/spec/extensions_spec.rb +36 -0
- data/spec/github_spec.rb +85 -0
- data/spec/helper_spec.rb +368 -0
- data/spec/spec_helper.rb +160 -4
- data/spec/windoze_spec.rb +38 -0
- metadata +114 -47
- data/README +0 -49
- data/commands/commands.rb +0 -54
- data/commands/helpers.rb +0 -79
- data/spec/helpers/owner_spec.rb +0 -12
- data/spec/helpers/project_spec.rb +0 -12
- data/spec/helpers/public_url_for_spec.rb +0 -12
- data/spec/helpers/repo_for_spec.rb +0 -12
- data/spec/helpers/user_and_repo_from_spec.rb +0 -15
- data/spec/helpers/user_for_spec.rb +0 -12
data/History.txt
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
== 0.4.0
|
2
|
+
|
3
|
+
Releasing to GemCutter!
|
4
|
+
|
5
|
+
Maintenance taken over by Dr Nic Williams.
|
6
|
+
Post issues/bugs to http://github.com/defunkt/github-gem/issues
|
7
|
+
|
8
|
+
New Commands:
|
9
|
+
* gh issues web [user] - opens the Issues page
|
10
|
+
|
11
|
+
Miscellaneous:
|
12
|
+
* no longer using old /network/members API call (which is 500ing at the moment)
|
13
|
+
|
14
|
+
== 0.3.10
|
15
|
+
|
16
|
+
* gh clone --search query -- now includes project descriptions
|
17
|
+
* bugfix
|
18
|
+
* added highline dependency
|
19
|
+
|
20
|
+
== 0.3.9
|
21
|
+
|
22
|
+
* gh clone --search query -- to search for a repo and then clone it
|
23
|
+
* fixed all the specs and started covering some commands that did not already have specs
|
24
|
+
|
25
|
+
== 0.3.X
|
26
|
+
|
27
|
+
* Some stuff done by some people
|
28
|
+
|
29
|
+
== 0.1.4
|
30
|
+
|
31
|
+
* Added usage notes to commands. [topfunky]
|
32
|
+
* Added config option to set github.user and github.repo. [topfunky]
|
33
|
+
* Uses current user to automatically use SSH when cloning own projects.
|
34
|
+
|
35
|
+
== 0.1.3
|
36
|
+
|
37
|
+
* Original version
|
data/Manifest
CHANGED
@@ -1,17 +1,38 @@
|
|
1
|
+
History.txt
|
2
|
+
LICENSE
|
3
|
+
Manifest
|
4
|
+
README.md
|
5
|
+
Rakefile
|
6
|
+
bin/gh
|
1
7
|
bin/github
|
2
|
-
commands/commands.rb
|
3
|
-
commands/helpers.rb
|
8
|
+
lib/commands/commands.rb
|
9
|
+
lib/commands/helpers.rb
|
10
|
+
lib/commands/issues.rb
|
11
|
+
lib/commands/network.rb
|
12
|
+
lib/github.rb
|
4
13
|
lib/github/command.rb
|
14
|
+
lib/github/extensions.rb
|
5
15
|
lib/github/helper.rb
|
6
|
-
lib/github.rb
|
7
|
-
|
8
|
-
README
|
16
|
+
lib/github/ui.rb
|
17
|
+
setup.rb
|
9
18
|
spec/command_spec.rb
|
10
|
-
spec/
|
11
|
-
spec/
|
12
|
-
spec/
|
13
|
-
spec/
|
14
|
-
spec/
|
15
|
-
spec/
|
19
|
+
spec/commands/command_browse_spec.rb
|
20
|
+
spec/commands/command_clone_spec.rb
|
21
|
+
spec/commands/command_create-from-local_spec.rb
|
22
|
+
spec/commands/command_fetch_spec.rb
|
23
|
+
spec/commands/command_fork_spec.rb
|
24
|
+
spec/commands/command_helper.rb
|
25
|
+
spec/commands/command_home_spec.rb
|
26
|
+
spec/commands/command_info_spec.rb
|
27
|
+
spec/commands/command_issues_spec.rb
|
28
|
+
spec/commands/command_network_spec.rb
|
29
|
+
spec/commands/command_pull-request_spec.rb
|
30
|
+
spec/commands/command_pull_spec.rb
|
31
|
+
spec/commands/command_search_spec.rb
|
32
|
+
spec/commands/command_track_spec.rb
|
33
|
+
spec/commands_spec.rb
|
34
|
+
spec/extensions_spec.rb
|
35
|
+
spec/github_spec.rb
|
36
|
+
spec/helper_spec.rb
|
16
37
|
spec/spec_helper.rb
|
17
|
-
|
38
|
+
spec/windoze_spec.rb
|
data/README.md
ADDED
@@ -0,0 +1,187 @@
|
|
1
|
+
# The GitHub Gem
|
2
|
+
|
3
|
+
This gem works hand-in-hand with GitHub's API to help you out.
|
4
|
+
|
5
|
+
Catch us in the #github room on freenode if you want to get involved. Or just fork and send a pull request.
|
6
|
+
|
7
|
+
## Getting started
|
8
|
+
|
9
|
+
$ gem source add http://gemcutter.org
|
10
|
+
$ gem install github
|
11
|
+
|
12
|
+
Run it:
|
13
|
+
|
14
|
+
$ github <command> <args>
|
15
|
+
$ gh <command> <args>
|
16
|
+
|
17
|
+
## Pulling Upstream Changes
|
18
|
+
|
19
|
+
Let's say you just forked `github-gem` on GitHub from defunkt.
|
20
|
+
|
21
|
+
$ gh clone YOU/github-gem
|
22
|
+
$ cd github-gem
|
23
|
+
$ gh pull defunkt
|
24
|
+
|
25
|
+
This will setup a remote and branch for defunkt's repository at master.
|
26
|
+
In this case, a 'defunkt/master' branch.
|
27
|
+
|
28
|
+
If defunkt makes some changes you want, simply `github pull defunkt`. This will
|
29
|
+
leave you in the 'defunkt/master' branch after pulling changes from defunkt's
|
30
|
+
remote. After confirming that defunkt's changes were what you wanted, run `git
|
31
|
+
checkout master` and then `git merge defunkt/master` to merge defunkt's changes
|
32
|
+
into your own master branch. In summary:
|
33
|
+
|
34
|
+
$ gh pull defunkt
|
35
|
+
$ gh checkout master
|
36
|
+
$ gh merge defunkt/master
|
37
|
+
|
38
|
+
If you've already reviewed defunkt's changes and just want to merge them into your
|
39
|
+
master branch, use the `merge` flag:
|
40
|
+
|
41
|
+
$ gh pull --merge defunkt
|
42
|
+
|
43
|
+
## Fetching and Evaluating Downstream Changes
|
44
|
+
|
45
|
+
If you are the maintainer of a project, you will often need to fetch commits
|
46
|
+
from other developers, evaluate and/or test them, then merge them into the
|
47
|
+
project.
|
48
|
+
|
49
|
+
Let's say you are 'defunkt' and 'mojombo' has forked your 'github-gem' repo,
|
50
|
+
made some changes and issues you a pull request for his 'master' branch.
|
51
|
+
|
52
|
+
From the root of the project, you can do:
|
53
|
+
|
54
|
+
$ gh fetch mojombo master
|
55
|
+
|
56
|
+
This will leave you in the 'mojombo/master' branch after fetching his commits.
|
57
|
+
Your local 'mojombo/master' branch is now at the exact same place as mojombo's
|
58
|
+
'master' branch. You can now run tests or evaluate the code for awesomeness.
|
59
|
+
|
60
|
+
If mojombo's changes are good, you'll want to merge your 'master' (or another
|
61
|
+
branch) into those changes so you can retest post-integration:
|
62
|
+
|
63
|
+
$ gh merge master
|
64
|
+
|
65
|
+
Test/analyze again and if everything is ok:
|
66
|
+
|
67
|
+
$ gh checkout master
|
68
|
+
$ gh merge mojombo/master
|
69
|
+
|
70
|
+
The latter command will be a fast-forward merge since you already did the
|
71
|
+
real merge previously.
|
72
|
+
|
73
|
+
## Network Patch Queue
|
74
|
+
|
75
|
+
The github gem can also show you all of the commits that exist on any fork of your
|
76
|
+
project (your network) that you don't have in your branch yet. In order to see
|
77
|
+
the list of the projects that have commits you do not, you can run:
|
78
|
+
|
79
|
+
$ gh network list
|
80
|
+
|
81
|
+
Which will show you all the forks that have changes. If you want to see what those
|
82
|
+
changes are, you can run:
|
83
|
+
|
84
|
+
$ gh network commits
|
85
|
+
|
86
|
+
which will show you something like this:
|
87
|
+
|
88
|
+
9582b9 (jchris/gist) kevin@sb.org Add gist binary 4 months ago
|
89
|
+
c1a6f9 (jchris/gist~1) kevin@sb.org Tweak Rakefile spec tasks to be a bi 4 months ago
|
90
|
+
d3c332 (jchris/gist~2) kevin@sb.org Pull out two helpers into the shared 4 months ago
|
91
|
+
8f65ab (jchris/gist~3) kevin@sb.org Extract command/helper spec assistan 4 months ago
|
92
|
+
389dbf (jchris/gist~4) kevin@sb.org Rename ui_spec to command_spec 4 months ago
|
93
|
+
670a1a (jchris/gist~5) kevin@sb.org Hoist the specs into a per-binary sp 4 months ago
|
94
|
+
6aa18e (jchris/gist~6) kevin@sb.org Hoist commands/helpers into a per-co 4 months ago
|
95
|
+
ee013a (luislavena/master) luislavena@gmail.com Replaced STDOUT by $stdout in specs. 2 weeks ago
|
96
|
+
d543c4 (luislavena/master~3) luislavena@gmail.com Exclude package folder. 8 weeks ago
|
97
|
+
a8c3eb (luislavena/master~5) luislavena@gmail.com Fixed specs for open under Windows. 5 months ago
|
98
|
+
33d003 (riquedafreak/master) enrique.osuna@gmail. Make sure it exists on the remote an 5 weeks ago
|
99
|
+
157155 (riquedafreak/master~1) enrique.osuna@gmail. Updated specs. 5 weeks ago
|
100
|
+
f44e99 (riquedafreak/master~3) enrique.osuna@gmail. Only work with a clean branch. 3 months ago
|
101
|
+
|
102
|
+
These are all the commits that you don't have in your current branch that have been
|
103
|
+
pushed to other forks of your project. If you want to incorporate them, you can use:
|
104
|
+
|
105
|
+
$ gh cherry-pick ee013a
|
106
|
+
|
107
|
+
for example to apply that single patch to your branch. You can also merge a branch,
|
108
|
+
if you want all the changes introduced in another branch:
|
109
|
+
|
110
|
+
$ gh merge jchris/gist
|
111
|
+
|
112
|
+
The next time you run the 'github network commits' command, you won't see any of the
|
113
|
+
patches you have cherry-picked or merged (or rebased). If you want to ignore a
|
114
|
+
commit, you can simply run:
|
115
|
+
|
116
|
+
$ gh ignore a8c3eb
|
117
|
+
|
118
|
+
Then you won't ever see that commit again. Or, if you want to ignore a range of commits,
|
119
|
+
you can use the normal Git revision selection shorthands - for example, if you want
|
120
|
+
to ignore all 7 jchris/gist commits there, you can run:
|
121
|
+
|
122
|
+
$ gh ignore ..jchris/gist
|
123
|
+
|
124
|
+
You can also filter the output, if you want to see some subset. You can filter by project,
|
125
|
+
author and date range, or (one of the cooler things) you can filter by whether the patch
|
126
|
+
applies cleanly to your branch head or not. For instance, I can do this:
|
127
|
+
|
128
|
+
$ ./bin/github network commits --applies
|
129
|
+
|
130
|
+
ca15af (jchris/master~1) jchris@grabb.it fixed github gemspecs broken referen 8 weeks ago
|
131
|
+
ee013a (luislavena/master) luislavena@gmail.com Replaced STDOUT by $stdout in specs. 2 weeks ago
|
132
|
+
157155 (riquedafreak/master~1) enrique.osuna@gmail. Updated specs. 5 weeks ago
|
133
|
+
f44e99 (riquedafreak/master~3) enrique.osuna@gmail. Only work with a clean branch. 3 months ago
|
134
|
+
|
135
|
+
$ ./bin/github network commits --applies --project=riq
|
136
|
+
|
137
|
+
157155 (riquedafreak/master~1) enrique.osuna@gmail. Updated specs. 5 weeks ago
|
138
|
+
f44e99 (riquedafreak/master~3) enrique.osuna@gmail. Only work with a clean branch. 3 months ago
|
139
|
+
|
140
|
+
Pretty freaking sweet. Also, you can supply the --shas option to just get a list of
|
141
|
+
the shas instead of the pretty printout here, so you can pipe that into other
|
142
|
+
scripts (like 'github ignore' for instance).
|
143
|
+
|
144
|
+
|
145
|
+
## Issues
|
146
|
+
|
147
|
+
If you'd like to see a summary of the open issues on your project:
|
148
|
+
|
149
|
+
$ gh issues open
|
150
|
+
|
151
|
+
-----
|
152
|
+
Issue #135 (2 votes): Remove Node#collect_namespaces
|
153
|
+
* URL: http://github.com/tenderlove/nokogiri/issues/#issue/135
|
154
|
+
* Opened 3 days ago by tenderlove
|
155
|
+
* Last updated about 1 hour ago
|
156
|
+
|
157
|
+
I think we should remove Node#collect_namespaces. Since namespace names are not unique, I don't know that this method is very useful.
|
158
|
+
-----
|
159
|
+
Issue #51 (0 votes): FFI: support varargs in error/exception callbacks
|
160
|
+
* URL: http://github.com/tenderlove/nokogiri/issues/#issue/51
|
161
|
+
* Opened 4 months ago by flavorjones
|
162
|
+
* Last updated about 1 month ago
|
163
|
+
* Labels: ffi, mdalessio
|
164
|
+
|
165
|
+
we should open JIRA tickets for vararg support in FFI callbacks
|
166
|
+
|
167
|
+
then we should format the libxml error messages properly in the error/exception callbacks
|
168
|
+
-----
|
169
|
+
|
170
|
+
If you want to additionally filter by time:
|
171
|
+
|
172
|
+
$ gh issues open --after=2009-09-14
|
173
|
+
|
174
|
+
Or filter by label:
|
175
|
+
|
176
|
+
$ gh issues open --label=ffi
|
177
|
+
|
178
|
+
## Contributors
|
179
|
+
|
180
|
+
* defunkt
|
181
|
+
* maddox
|
182
|
+
* halorgium
|
183
|
+
* kballard
|
184
|
+
* mojombo
|
185
|
+
* schacon
|
186
|
+
* drnic
|
187
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'echoe'
|
6
|
+
|
7
|
+
Echoe.new('github', '0.4.0') do |p|
|
8
|
+
p.rubyforge_name = 'github'
|
9
|
+
p.summary = "The official `github` command line helper for simplifying your GitHub experience."
|
10
|
+
p.description = "The official `github` command line helper for simplifying your GitHub experience."
|
11
|
+
p.url = "http://github.com/"
|
12
|
+
p.author = ['Chris Wanstrath', 'Kevin Ballard', 'Scott Chacon']
|
13
|
+
p.email = "chris@ozmm.org"
|
14
|
+
p.dependencies = [
|
15
|
+
"text-format >=1.0.0",
|
16
|
+
"highline ~>1.5.1"
|
17
|
+
]
|
18
|
+
end
|
19
|
+
|
20
|
+
rescue LoadError => boom
|
21
|
+
puts "You are missing a dependency required for meta-operations on this gem."
|
22
|
+
puts "#{boom.to_s.capitalize}."
|
23
|
+
end
|
24
|
+
|
25
|
+
# add spec tasks, if you have rspec installed
|
26
|
+
begin
|
27
|
+
require 'spec/rake/spectask'
|
28
|
+
|
29
|
+
Spec::Rake::SpecTask.new("spec") do |t|
|
30
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
31
|
+
t.spec_opts = ['--color']
|
32
|
+
end
|
33
|
+
|
34
|
+
task :test do
|
35
|
+
Rake::Task['spec'].invoke
|
36
|
+
end
|
37
|
+
|
38
|
+
Spec::Rake::SpecTask.new("rcov_spec") do |t|
|
39
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
40
|
+
t.spec_opts = ['--color']
|
41
|
+
t.rcov = true
|
42
|
+
t.rcov_opts = ['--exclude', '^spec,/gems/']
|
43
|
+
end
|
44
|
+
end
|
data/bin/gh
ADDED
data/bin/github
CHANGED
data/github.gemspec
CHANGED
@@ -1,42 +1,37 @@
|
|
1
|
-
|
2
|
-
# Gem::Specification for Github-0.1.1
|
3
|
-
# Originally generated by Echoe
|
1
|
+
# -*- encoding: utf-8 -*-
|
4
2
|
|
5
3
|
Gem::Specification.new do |s|
|
6
4
|
s.name = %q{github}
|
7
|
-
s.version = "0.
|
8
|
-
|
9
|
-
s.
|
5
|
+
s.version = "0.4.0"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Chris Wanstrath, Kevin Ballard, Scott Chacon"]
|
9
|
+
s.date = %q{2009-11-06}
|
10
|
+
s.description = %q{The official `github` command line helper for simplifying your GitHub experience.}
|
10
11
|
s.email = %q{chris@ozmm.org}
|
12
|
+
s.executables = ["gh", "github"]
|
13
|
+
s.extra_rdoc_files = ["LICENSE", "README.md", "bin/gh", "bin/github", "lib/commands/commands.rb", "lib/commands/helpers.rb", "lib/commands/issues.rb", "lib/commands/network.rb", "lib/github.rb", "lib/github/command.rb", "lib/github/extensions.rb", "lib/github/helper.rb", "lib/github/ui.rb"]
|
14
|
+
s.files = ["History.txt", "LICENSE", "Manifest", "README.md", "Rakefile", "bin/gh", "bin/github", "lib/commands/commands.rb", "lib/commands/helpers.rb", "lib/commands/issues.rb", "lib/commands/network.rb", "lib/github.rb", "lib/github/command.rb", "lib/github/extensions.rb", "lib/github/helper.rb", "lib/github/ui.rb", "setup.rb", "spec/command_spec.rb", "spec/commands/command_browse_spec.rb", "spec/commands/command_clone_spec.rb", "spec/commands/command_create-from-local_spec.rb", "spec/commands/command_fetch_spec.rb", "spec/commands/command_fork_spec.rb", "spec/commands/command_helper.rb", "spec/commands/command_home_spec.rb", "spec/commands/command_info_spec.rb", "spec/commands/command_issues_spec.rb", "spec/commands/command_network_spec.rb", "spec/commands/command_pull-request_spec.rb", "spec/commands/command_pull_spec.rb", "spec/commands/command_search_spec.rb", "spec/commands/command_track_spec.rb", "spec/commands_spec.rb", "spec/extensions_spec.rb", "spec/github_spec.rb", "spec/helper_spec.rb", "spec/spec_helper.rb", "spec/windoze_spec.rb", "github.gemspec"]
|
11
15
|
s.homepage = %q{http://github.com/}
|
16
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Github", "--main", "README.md"]
|
17
|
+
s.require_paths = ["lib"]
|
12
18
|
s.rubyforge_project = %q{github}
|
13
|
-
s.
|
14
|
-
s.
|
15
|
-
s.has_rdoc = true
|
16
|
-
s.authors = ["Chris Wanstrath"]
|
17
|
-
s.files = ["bin/github", "commands/commands.rb", "commands/helpers.rb", "lib/github/command.rb", "lib/github/helper.rb", "lib/github.rb", "LICENSE", "README", "spec/command_spec.rb", "spec/helpers/owner_spec.rb", "spec/helpers/project_spec.rb", "spec/helpers/public_url_for_spec.rb", "spec/helpers/repo_for_spec.rb", "spec/helpers/user_and_repo_from_spec.rb", "spec/helpers/user_for_spec.rb", "spec/spec_helper.rb", "Manifest", "github.gemspec"]
|
18
|
-
s.executables = ["github"]
|
19
|
-
end
|
19
|
+
s.rubygems_version = %q{1.3.5}
|
20
|
+
s.summary = %q{The official `github` command line helper for simplifying your GitHub experience.}
|
20
21
|
|
22
|
+
if s.respond_to? :specification_version then
|
23
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
24
|
+
s.specification_version = 3
|
21
25
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
# p.url = "http://github.com/"
|
35
|
-
# p.author = 'Chris Wanstrath'
|
36
|
-
# p.email = "chris@ozmm.org"
|
37
|
-
# end
|
38
|
-
#
|
39
|
-
# rescue LoadError => boom
|
40
|
-
# puts "You are missing a dependency required for meta-operations on this gem."
|
41
|
-
# puts "#{boom.to_s.capitalize}."
|
42
|
-
# end
|
26
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
27
|
+
s.add_runtime_dependency(%q<text-format>, [">= 1.0.0"])
|
28
|
+
s.add_runtime_dependency(%q<highline>, ["~> 1.5.1"])
|
29
|
+
else
|
30
|
+
s.add_dependency(%q<text-format>, [">= 1.0.0"])
|
31
|
+
s.add_dependency(%q<highline>, ["~> 1.5.1"])
|
32
|
+
end
|
33
|
+
else
|
34
|
+
s.add_dependency(%q<text-format>, [">= 1.0.0"])
|
35
|
+
s.add_dependency(%q<highline>, ["~> 1.5.1"])
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,249 @@
|
|
1
|
+
desc "Open this repo's master branch in a web browser."
|
2
|
+
command :home do |user|
|
3
|
+
if helper.project
|
4
|
+
helper.open helper.homepage_for(user || helper.owner, 'master')
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
desc "Automatically set configuration info, or pass args to specify."
|
9
|
+
usage "github config [my_username] [my_repo_name]"
|
10
|
+
command :config do |user, repo|
|
11
|
+
user ||= ENV['USER']
|
12
|
+
repo ||= File.basename(FileUtils.pwd)
|
13
|
+
git "config --global github.user #{user}"
|
14
|
+
git "config github.repo #{repo}"
|
15
|
+
puts "Configured with github.user #{user}, github.repo #{repo}"
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "Open this repo in a web browser."
|
19
|
+
usage "github browse [user] [branch]"
|
20
|
+
command :browse do |user, branch|
|
21
|
+
if helper.project
|
22
|
+
# if one arg given, treat it as a branch name
|
23
|
+
# unless it maches user/branch, then split it
|
24
|
+
# if two args given, treat as user branch
|
25
|
+
# if no args given, use defaults
|
26
|
+
user, branch = user.split("/", 2) if branch.nil? unless user.nil?
|
27
|
+
branch = user and user = nil if branch.nil?
|
28
|
+
user ||= helper.branch_user
|
29
|
+
branch ||= helper.branch_name
|
30
|
+
helper.open helper.homepage_for(user, branch)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
desc 'Open the given user/project in a web browser'
|
35
|
+
usage 'github open [user/project]'
|
36
|
+
command :open do |arg|
|
37
|
+
helper.open "http://github.com/#{arg}"
|
38
|
+
end
|
39
|
+
|
40
|
+
desc "Info about this project."
|
41
|
+
command :info do
|
42
|
+
puts "== Info for #{helper.project}"
|
43
|
+
puts "You are #{helper.owner}"
|
44
|
+
puts "Currently tracking:"
|
45
|
+
helper.tracking.sort { |(a,),(b,)| a == helper.origin ? -1 : b == helper.origin ? 1 : a.to_s <=> b.to_s }.each do |(name,user_or_url)|
|
46
|
+
puts " - #{user_or_url} (as #{name})"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
desc "Track another user's repository."
|
51
|
+
usage "github track remote [user]"
|
52
|
+
usage "github track remote [user/repo]"
|
53
|
+
usage "github track [user]"
|
54
|
+
usage "github track [user/repo]"
|
55
|
+
flags :private => "Use git@github.com: instead of git://github.com/."
|
56
|
+
flags :ssh => 'Equivalent to --private'
|
57
|
+
command :track do |remote, user|
|
58
|
+
# track remote user
|
59
|
+
# track remote user/repo
|
60
|
+
# track user
|
61
|
+
# track user/repo
|
62
|
+
user, remote = remote, nil if user.nil?
|
63
|
+
die "Specify a user to track" if user.nil?
|
64
|
+
user, repo = user.split("/", 2)
|
65
|
+
die "Already tracking #{user}" if helper.tracking?(user)
|
66
|
+
repo = @helper.project if repo.nil?
|
67
|
+
repo.chomp!(".git")
|
68
|
+
remote ||= user
|
69
|
+
|
70
|
+
if options[:private] || options[:ssh]
|
71
|
+
git "remote add #{remote} #{helper.private_url_for_user_and_repo(user, repo)}"
|
72
|
+
else
|
73
|
+
git "remote add #{remote} #{helper.public_url_for_user_and_repo(user, repo)}"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
desc "Fetch all refs from a user"
|
78
|
+
command :fetch_all do |user|
|
79
|
+
GitHub.invoke(:track, user) unless helper.tracking?(user)
|
80
|
+
git "fetch #{user}"
|
81
|
+
end
|
82
|
+
|
83
|
+
desc "Fetch from a remote to a local branch."
|
84
|
+
command :fetch do |user, branch|
|
85
|
+
die "Specify a user to pull from" if user.nil?
|
86
|
+
user, branch = user.split("/", 2) if branch.nil?
|
87
|
+
branch ||= 'master'
|
88
|
+
GitHub.invoke(:track, user) unless helper.tracking?(user)
|
89
|
+
|
90
|
+
die "Unknown branch (#{branch}) specified" unless helper.remote_branch?(user, branch)
|
91
|
+
die "Unable to switch branches, your current branch has uncommitted changes" if helper.branch_dirty?
|
92
|
+
|
93
|
+
puts "Fetching #{user}/#{branch}"
|
94
|
+
git "fetch #{user} #{branch}:refs/remotes/#{user}/#{branch}"
|
95
|
+
git "update-ref refs/heads/#{user}/#{branch} refs/remotes/#{user}/#{branch}"
|
96
|
+
git_exec "checkout #{user}/#{branch}"
|
97
|
+
end
|
98
|
+
|
99
|
+
desc "Pull from a remote."
|
100
|
+
usage "github pull [user] [branch]"
|
101
|
+
flags :merge => "Automatically merge remote's changes into your master."
|
102
|
+
command :pull do |user, branch|
|
103
|
+
die "Specify a user to pull from" if user.nil?
|
104
|
+
user, branch = user.split("/", 2) if branch.nil?
|
105
|
+
|
106
|
+
if !helper.network_members(user, {}).include?(user)
|
107
|
+
git_exec "#{helper.argv.join(' ')}".strip
|
108
|
+
return
|
109
|
+
end
|
110
|
+
|
111
|
+
branch ||= 'master'
|
112
|
+
GitHub.invoke(:track, user) unless helper.tracking?(user)
|
113
|
+
|
114
|
+
die "Unable to switch branches, your current branch has uncommitted changes" if helper.branch_dirty?
|
115
|
+
|
116
|
+
if options[:merge]
|
117
|
+
git_exec "pull #{user} #{branch}"
|
118
|
+
else
|
119
|
+
puts "Switching to #{user}-#{branch}"
|
120
|
+
git "fetch #{user}"
|
121
|
+
git_exec "checkout -b #{user}/#{branch} #{user}/#{branch}"
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
desc "Clone a repo. Uses ssh if current user is "
|
126
|
+
usage "github clone [user] [repo] [dir]"
|
127
|
+
flags :ssh => "Clone using the git@github.com style url."
|
128
|
+
flags :search => "Search for [user|repo] and clone selected repository"
|
129
|
+
command :clone do |user, repo, dir|
|
130
|
+
die "Specify a user to pull from" if user.nil?
|
131
|
+
if options[:search]
|
132
|
+
query = [user, repo, dir].compact.join(" ")
|
133
|
+
data = JSON.parse(open("http://github.com/api/v1/json/search/#{URI.escape query}").read)
|
134
|
+
if (repos = data['repositories']) && !repos.nil? && repos.length > 0
|
135
|
+
repo_list = repos.map do |r|
|
136
|
+
{ "name" => "#{r['username']}/#{r['name']}", "description" => r['description'] }
|
137
|
+
end
|
138
|
+
formatted_list = helper.format_list(repo_list).split("\n")
|
139
|
+
if user_repo = GitHub::UI.display_select_list(formatted_list)
|
140
|
+
user, repo = user_repo.strip.split('/', 2)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
die "Perhaps try another search" unless user && repo
|
144
|
+
end
|
145
|
+
|
146
|
+
if user.include?('/') && !user.include?('@') && !user.include?(':')
|
147
|
+
die "Expected user/repo dir, given extra argument" if dir
|
148
|
+
(user, repo), dir = [user.split('/', 2), repo]
|
149
|
+
end
|
150
|
+
|
151
|
+
if repo
|
152
|
+
if options[:ssh] || current_user?(user)
|
153
|
+
git_exec "clone git@github.com:#{user}/#{repo}.git" + (dir ? " #{dir}" : "")
|
154
|
+
else
|
155
|
+
git_exec "clone git://github.com/#{user}/#{repo}.git" + (dir ? " #{dir}" : "")
|
156
|
+
end
|
157
|
+
else
|
158
|
+
git_exec "#{helper.argv.join(' ')}".strip
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
desc "Generate the text for a pull request."
|
163
|
+
usage "github pull-request [user] [branch]"
|
164
|
+
command :'pull-request' do |user, branch|
|
165
|
+
if helper.project
|
166
|
+
die "Specify a user for the pull request" if user.nil?
|
167
|
+
user, branch = user.split('/', 2) if branch.nil?
|
168
|
+
branch ||= 'master'
|
169
|
+
GitHub.invoke(:track, user) unless helper.tracking?(user)
|
170
|
+
|
171
|
+
git_exec "request-pull #{user}/#{branch} #{helper.origin}"
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
desc "Create a new, empty GitHub repository"
|
176
|
+
usage "github create [repo]"
|
177
|
+
flags :markdown => 'Create README.markdown'
|
178
|
+
flags :mdown => 'Create README.mdown'
|
179
|
+
flags :textile => 'Create README.textile'
|
180
|
+
flags :rdoc => 'Create README.rdoc'
|
181
|
+
flags :rst => 'Create README.rst'
|
182
|
+
flags :private => 'Create private repository'
|
183
|
+
command :create do |repo|
|
184
|
+
sh "curl -F 'repository[name]=#{repo}' -F 'repository[public]=#{!options[:private]}' -F 'login=#{github_user}' -F 'token=#{github_token}' http://github.com/repositories"
|
185
|
+
mkdir repo
|
186
|
+
cd repo
|
187
|
+
git "init"
|
188
|
+
extension = options.keys.first
|
189
|
+
touch extension ? "README.#{extension}" : "README"
|
190
|
+
git "add *"
|
191
|
+
git "commit -m 'First commit!'"
|
192
|
+
git "remote add origin git@github.com:#{github_user}/#{repo}.git"
|
193
|
+
git_exec "push origin master"
|
194
|
+
end
|
195
|
+
|
196
|
+
desc "Forks a GitHub repository"
|
197
|
+
usage "github fork"
|
198
|
+
usage "github fork [user]/[repo]"
|
199
|
+
command :fork do |user, repo|
|
200
|
+
if repo.nil?
|
201
|
+
if user
|
202
|
+
user, repo = user.split('/')
|
203
|
+
else
|
204
|
+
unless helper.remotes.empty?
|
205
|
+
is_repo = true
|
206
|
+
user = helper.owner
|
207
|
+
repo = helper.project
|
208
|
+
else
|
209
|
+
die "Specify a user/project to fork, or run from within a repo"
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
sh "curl -F 'login=#{github_user}' -F 'token=#{github_token}' http://github.com/#{user}/#{repo}/fork"
|
215
|
+
|
216
|
+
url = "git@github.com:#{github_user}/#{repo}.git"
|
217
|
+
if is_repo
|
218
|
+
git "config remote.origin.url #{url}"
|
219
|
+
puts "#{user}/#{repo} forked"
|
220
|
+
else
|
221
|
+
puts "Giving GitHub a moment to create the fork..."
|
222
|
+
sleep 3
|
223
|
+
git_exec "clone #{url}"
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
desc "Create a new GitHub repository from the current local repository"
|
228
|
+
flags :private => 'Create private repository'
|
229
|
+
command :'create-from-local' do
|
230
|
+
cwd = sh "pwd"
|
231
|
+
repo = File.basename(cwd)
|
232
|
+
is_repo = !git("status").match(/fatal/)
|
233
|
+
raise "Not a git repository. Use gh create instead" unless is_repo
|
234
|
+
sh "curl -F 'repository[name]=#{repo}' -F 'repository[public]=#{!options[:private].inspect} -F 'login=#{github_user}' -F 'token=#{github_token}' http://github.com/repositories"
|
235
|
+
git "remote add origin git@github.com:#{github_user}/#{repo}.git"
|
236
|
+
git_exec "push origin master"
|
237
|
+
end
|
238
|
+
|
239
|
+
desc "Search GitHub for the given repository name."
|
240
|
+
usage "github search [query]"
|
241
|
+
command :search do |query|
|
242
|
+
die "Usage: github search [query]" if query.nil?
|
243
|
+
data = JSON.parse(open("http://github.com/api/v1/json/search/#{URI.escape query}").read)
|
244
|
+
if (repos = data['repositories']) && !repos.nil? && repos.length > 0
|
245
|
+
puts repos.map { |r| "#{r['username']}/#{r['name']}"}.sort.uniq
|
246
|
+
else
|
247
|
+
puts "No results found"
|
248
|
+
end
|
249
|
+
end
|