git-review 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/git-review.rb +11 -16
  2. metadata +3 -3
data/lib/git-review.rb CHANGED
@@ -17,7 +17,7 @@ class GitReview
17
17
  puts ' list [--reverse] List all open requests.'
18
18
  puts ' show <number> [--full] Show details of a single request.'
19
19
  puts ' browse <number> Open a browser window and review a specified request.'
20
- # puts ' checkout <number> Checkout a specified request\'s changes to your local repository.'
20
+ puts ' checkout <number> Checkout a specified request\'s changes to your local repository.'
21
21
  puts ' accept <number> Accept a specified request by merging it into master.'
22
22
  puts ' decline <number> Decline and close a specified request.'
23
23
  puts ' create Create a new request.'
@@ -25,27 +25,22 @@ class GitReview
25
25
 
26
26
  # List all open requests.
27
27
  def list
28
- puts "Open requests for '#{source_repo}/#{source_branch}'"
29
- option = @args.shift
30
28
  open_requests = get_pull_info
31
- open_requests.reverse! if option == '--reverse'
32
- # TODO: Refactor to get rid of unnecessary variables and computation.
33
- count = 0
29
+ if open_requests.size == 0
30
+ puts "No open requests for '#{source_repo}/#{source_branch}'"
31
+ return
32
+ end
33
+ puts "Open requests for '#{source_repo}/#{source_branch}'"
34
34
  puts 'ID Date Comments Title'
35
+ open_requests.reverse! if @args.shift == '--reverse'
35
36
  open_requests.each do |pull|
37
+ next unless not_merged?(pull['head']['sha'])
36
38
  line = []
37
39
  line << format_text(pull['number'], 6)
38
40
  line << format_text(Date.parse(pull['created_at']).strftime('%d-%b-%y'), 10)
39
41
  line << format_text(pull['comments'], 10)
40
42
  line << format_text(pull['title'], 94)
41
- sha = pull['head']['sha']
42
- if not_merged?(sha)
43
- puts line.join ' '
44
- count += 1
45
- end
46
- end
47
- if count == 0
48
- puts ' -- No open requests. --'
43
+ puts line.join ' '
49
44
  end
50
45
  end
51
46
 
@@ -80,9 +75,9 @@ class GitReview
80
75
  end
81
76
 
82
77
  # Checkout a specified request's changes to your local repository.
83
- # TODO: Implement this.
84
78
  def checkout
85
- puts 'Under construction... ;-)'
79
+ return unless review_exists?
80
+ git "co origin/#{@review['head']['ref']}"
86
81
  end
87
82
 
88
83
  # Accept a specified request by merging it into master.
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: 11
4
+ hash: 9
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 0
10
- version: 0.5.0
9
+ - 1
10
+ version: 0.5.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Dominik Bamberger, Cristian Messel