git-forks 0.0.1 → 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.
- data/lib/git-forks.rb +58 -15
- metadata +17 -1
data/lib/git-forks.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
+
# JSON is used to cache GitHub API response data.
|
2
|
+
require 'json'
|
3
|
+
# Launchy is used in 'browse' to open a browser.
|
4
|
+
require 'launchy'
|
1
5
|
# Octokit is used to access GitHub's API.
|
2
6
|
require 'octokit'
|
3
7
|
# Time is used to parse time strings from git back into Time objects.
|
4
8
|
require 'time'
|
5
|
-
# JSON is used to cache GitHub API response data.
|
6
|
-
require 'json'
|
7
9
|
|
8
10
|
class GitForks
|
9
11
|
|
@@ -95,7 +97,7 @@ class GitForks
|
|
95
97
|
puts l('Owner', 25) + l('Branches', 12) + 'Updated'
|
96
98
|
puts l('------', 25) + l('--------', 12) + '-------'
|
97
99
|
puts output.compact
|
98
|
-
puts
|
100
|
+
puts '-' * 80
|
99
101
|
end
|
100
102
|
end
|
101
103
|
|
@@ -114,18 +116,57 @@ class GitForks
|
|
114
116
|
def show
|
115
117
|
owner = @args.shift
|
116
118
|
option = @args.shift
|
117
|
-
if
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
puts "
|
119
|
+
if owner
|
120
|
+
if f = fork(owner)
|
121
|
+
puts '-' * 80
|
122
|
+
puts "Owner : #{f['owner']['login']}"
|
123
|
+
puts "Repo : #{@repo}"
|
124
|
+
puts "Created : #{strftime(f['created_at'])}"
|
125
|
+
puts "Updated : #{strftime(f['updated_at'])}"
|
126
|
+
puts "Branches : #{f['branches'].size}"
|
127
|
+
f['branches'].each do |b|
|
128
|
+
puts " #{b['commit']['sha']} #{b['name']}"
|
129
|
+
end
|
130
|
+
puts '-' * 80
|
131
|
+
else
|
132
|
+
puts "No such fork: '#{owner}/#{@repo}'. Maybe you need to run git-forks update?"
|
133
|
+
puts
|
134
|
+
list
|
135
|
+
end
|
136
|
+
else
|
137
|
+
puts "<owner> argument missing"
|
138
|
+
puts
|
139
|
+
usage
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
def browse
|
144
|
+
owner = @args.shift
|
145
|
+
if owner
|
146
|
+
owner, ref = owner.split(':')
|
147
|
+
|
148
|
+
if f = fork(owner)
|
149
|
+
url = f['html_url']
|
150
|
+
|
151
|
+
if ref
|
152
|
+
if ref.match(/[A-Za-z0-9]{40}/)
|
153
|
+
url << "/commits/#{ref}"
|
154
|
+
else
|
155
|
+
url << "/tree/#{ref}"
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
return Launchy.open(url)
|
160
|
+
elsif owner == "network"
|
161
|
+
else
|
162
|
+
puts "No such fork: '#{owner}/#{@repo}'. Maybe you need to run git-forks update?"
|
163
|
+
puts
|
164
|
+
list
|
125
165
|
end
|
126
|
-
puts
|
127
166
|
else
|
128
|
-
puts "
|
167
|
+
puts "<owner> argument missing"
|
168
|
+
puts
|
169
|
+
usage
|
129
170
|
end
|
130
171
|
end
|
131
172
|
|
@@ -135,9 +176,11 @@ class GitForks
|
|
135
176
|
puts 'Get GitHub project forks information.'
|
136
177
|
puts
|
137
178
|
puts 'Available commands:'
|
138
|
-
puts ' update Retrieve fork info from GitHub API v3.'
|
139
179
|
puts ' list [--reverse] List all forks.'
|
140
180
|
puts ' show <owner> Show details for a single fork.'
|
181
|
+
puts ' update Retrieve fork info from GitHub API v3.'
|
182
|
+
puts ' browse <owner>[:<ref>] Show fork in web browser.'
|
183
|
+
puts ' <ref> denotes a Git Tree or a Git Commit.'
|
141
184
|
puts
|
142
185
|
puts 'Git configurations:'
|
143
186
|
puts ' github.forks.branchpattern Only grab branches matching this Ruby Regexp.'
|
@@ -213,7 +256,7 @@ class GitForks
|
|
213
256
|
|
214
257
|
def help
|
215
258
|
puts "No command: #{@command}"
|
216
|
-
puts "Try:
|
259
|
+
puts "Try: browse, list, show, update"
|
217
260
|
puts "or call with '-h' for usage information"
|
218
261
|
end
|
219
262
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git-forks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -27,6 +27,22 @@ dependencies:
|
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: launchy
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
30
46
|
- !ruby/object:Gem::Dependency
|
31
47
|
name: octokit
|
32
48
|
requirement: !ruby/object:Gem::Requirement
|