git-review 0.7.6 → 0.7.9
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-review.rb +47 -9
- metadata +18 -4
data/lib/git-review.rb
CHANGED
@@ -17,7 +17,7 @@ class GitReview
|
|
17
17
|
# still think of them as pending, as it doesn't know about local changes.
|
18
18
|
next if merged?(pending_request['head']['sha'])
|
19
19
|
line = format_text(pending_request['number'], 8)
|
20
|
-
date_string =
|
20
|
+
date_string = format_time(pending_request['updated_at'])
|
21
21
|
line += format_text(date_string, 11)
|
22
22
|
line += format_text(pending_request['comments'], 10)
|
23
23
|
line += format_text(pending_request['title'], 91)
|
@@ -32,14 +32,14 @@ class GitReview
|
|
32
32
|
puts output.compact
|
33
33
|
end
|
34
34
|
|
35
|
-
# Show details
|
35
|
+
# Show details for a single request.
|
36
36
|
def show
|
37
37
|
return unless request_exists?
|
38
38
|
option = @args.shift == '--full' ? '' : '--stat '
|
39
39
|
sha = @pending_request['head']['sha']
|
40
40
|
puts "ID : #{@pending_request['number']}"
|
41
41
|
puts "Label : #{@pending_request['head']['label']}"
|
42
|
-
puts "Updated : #{
|
42
|
+
puts "Updated : #{format_time(@pending_request['updated_at'])}"
|
43
43
|
puts "Comments : #{@pending_request['comments']}"
|
44
44
|
puts
|
45
45
|
puts @pending_request['title']
|
@@ -49,6 +49,37 @@ class GitReview
|
|
49
49
|
puts git_call("diff --color=always #{option}HEAD...#{sha}")
|
50
50
|
end
|
51
51
|
|
52
|
+
# Show current discussion for a single request.
|
53
|
+
def discussion
|
54
|
+
return unless request_exists?
|
55
|
+
request = Octokit.pull_request(source_repo, @pending_request['number'])
|
56
|
+
discussion = request['discussion'][1..-1]
|
57
|
+
result = discussion.collect do |entry|
|
58
|
+
# For now we only show comments and commits.
|
59
|
+
if ["IssueComment", "Commit"].include?(entry['type'])
|
60
|
+
output = "'#{entry["user"]["login"]}' "
|
61
|
+
case entry['type']
|
62
|
+
# Comments:
|
63
|
+
when "IssueComment"
|
64
|
+
output << "added a comment on #{format_time(entry['created_at'])}"
|
65
|
+
unless entry['created_at'] == entry['updated_at']
|
66
|
+
output << " (updated on #{format_time(entry['updated_at'])})"
|
67
|
+
end
|
68
|
+
output << ":\n#{''.rjust(output.length + 1, "-")}\n#{entry["body"]}"
|
69
|
+
# Commits:
|
70
|
+
when "Commit"
|
71
|
+
output << "authored a commit on #{format_time(entry['authored_date'])}"
|
72
|
+
unless entry['authored_date'] == entry['committed_date']
|
73
|
+
output << " (committed on #{format_time(entry['committed_date'])})"
|
74
|
+
end
|
75
|
+
output << ":\n#{''.rjust(output.length + 1, "-")}\n#{entry["message"]}"
|
76
|
+
end
|
77
|
+
output << "\n\n"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
puts result.compact unless result.empty?
|
81
|
+
end
|
82
|
+
|
52
83
|
# Open a browser window and review a specified request.
|
53
84
|
def browse
|
54
85
|
Launchy.open(@pending_request['html_url']) if request_exists?
|
@@ -57,12 +88,13 @@ class GitReview
|
|
57
88
|
# Checkout a specified request's changes to your local repository.
|
58
89
|
def checkout
|
59
90
|
return unless request_exists?
|
91
|
+
create_local_branch = @args.shift == '--branch' ? '' : 'origin/'
|
60
92
|
puts 'Checking out changes to your local repository.'
|
61
93
|
puts 'To get back to your original state, just run:'
|
62
94
|
puts
|
63
95
|
puts ' git checkout master'
|
64
96
|
puts
|
65
|
-
git_call "checkout
|
97
|
+
git_call "checkout #{create_local_branch}#{@pending_request['head']['ref']}"
|
66
98
|
end
|
67
99
|
|
68
100
|
# Accept a specified request by merging it into master.
|
@@ -184,11 +216,12 @@ class GitReview
|
|
184
216
|
puts
|
185
217
|
puts 'Available commands:'
|
186
218
|
puts ' list [--reverse] List all pending requests.'
|
187
|
-
puts ' show <
|
188
|
-
puts '
|
189
|
-
puts '
|
190
|
-
puts '
|
191
|
-
puts '
|
219
|
+
puts ' show <ID> [--full] Show details for a single request.'
|
220
|
+
puts ' discussion <number> Shows ongoing discussions for a single request.'
|
221
|
+
puts ' browse <ID> Open a browser window and review a specified request.'
|
222
|
+
puts ' checkout <ID> [--branch] Checkout a specified request\'s changes to your local repository.'
|
223
|
+
puts ' merge <ID> Accept a specified request by merging it into master.'
|
224
|
+
puts ' close <ID> Close a specified request.'
|
192
225
|
puts ' prepare Creates a new local branch for a request.'
|
193
226
|
puts ' create Create a new request.'
|
194
227
|
end
|
@@ -243,6 +276,11 @@ class GitReview
|
|
243
276
|
info.to_s.gsub("\n", ' ')[0, size-1].ljust(size)
|
244
277
|
end
|
245
278
|
|
279
|
+
# Display helper to unify time output.
|
280
|
+
def format_time(time_string)
|
281
|
+
Time.parse(time_string).strftime('%d-%b-%y')
|
282
|
+
end
|
283
|
+
|
246
284
|
# Returns a string that specifies the source repo.
|
247
285
|
def source_repo
|
248
286
|
"#{@user}/#{@repo}"
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git-review
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 7
|
9
|
-
-
|
10
|
-
version: 0.7.
|
9
|
+
- 9
|
10
|
+
version: 0.7.9
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Dominik Bamberger, Cristian Messel
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-12-
|
18
|
+
date: 2011-12-16 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -48,6 +48,20 @@ dependencies:
|
|
48
48
|
version: 0.5.1
|
49
49
|
type: :runtime
|
50
50
|
version_requirements: *id002
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
name: yajl-ruby
|
53
|
+
prerelease: false
|
54
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 3
|
60
|
+
segments:
|
61
|
+
- 0
|
62
|
+
version: "0"
|
63
|
+
type: :runtime
|
64
|
+
version_requirements: *id003
|
51
65
|
description: Manage review workflow for projects hosted on GitHub (using pull requests).
|
52
66
|
email: bamberger.dominik@gmail.com
|
53
67
|
executables:
|