flight_plan_cli 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 78181ba943356a2938c0b17c0ebcb72ee0aa5d04
4
- data.tar.gz: fe51626d77304f08f7b736b706a8cfbc7efd0a87
3
+ metadata.gz: d4b7888cb0ed509d5dc14e48c856f67c929c3a68
4
+ data.tar.gz: af5a01246e6979e28eda904000280d796ecd9f6b
5
5
  SHA512:
6
- metadata.gz: 8667298164e296c2dfc04126bce4b0fb5ef23a19ce031cf52e2c770d6915b81d6f5c4c472c1d52be1a376ed910aa487e1e7a53c62fe5e932bb9e1be93e067269
7
- data.tar.gz: d497fcceda6ddd0dbb3efad73a174c986fe16ea8e44c2bfd82936ac994c1153e4fb7b0406ea3e40ec411464b74adba408d3f0a9ec53e11821f41dacecf2a3f56
6
+ metadata.gz: 12efa16013e4409e369a63a21049edd4298c74914ea3e7bff8b90eb918b1507ac1db407f80ffbd8ac9dc72a996a1cd9a9ab35b64d4b9253e6637e1c881f01d53
7
+ data.tar.gz: c6e89e95945b59f862eae6c5f63db34405a88c450cd1b66c01a86031b207972f6ad716902e21d45a57e5cf58b9e467300ce91472f1efaa44016d15c462c87052
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.2
1
+ 0.2.3
@@ -32,7 +32,9 @@ module FlightPlanCli
32
32
  desc 'checkout ISSUE_NO', 'checkout a branch for ISSUE_NO'
33
33
  def checkout(issue_no)
34
34
  puts "Checking out branch for #{issue_no}"
35
- local_branch_for(issue_no) || remote_branch_for(issuei_no)
35
+ local_branch_for(issue_no) || remote_branch_for(issue_no)
36
+ rescue Rugged::CheckoutError => e
37
+ puts "Unable to checkout: #{e.message}".red
36
38
  end
37
39
 
38
40
  map co: :checkout
@@ -53,7 +55,7 @@ module FlightPlanCli
53
55
  end
54
56
 
55
57
  def local_branch_for(issue)
56
- issue_branches = local_branches.grep(/##{issue}[^0-9]/)
58
+ issue_branches = local_branches.map(&:name).grep(/##{issue}[^0-9]/)
57
59
  return false unless issue_branches.count == 1
58
60
 
59
61
  branch = issue_branches.first
@@ -62,23 +64,28 @@ module FlightPlanCli
62
64
  true
63
65
  end
64
66
 
67
+ def remote_branch_for(issue)
68
+ git.fetch('origin')
69
+ issue_branches = remote_branches.map(&:name).grep(/##{issue}[^0-9]/)
70
+ return false unless issue_branches.count == 1
71
+
72
+ remote_branch_name = issue_branches.first
73
+ branch = remote_branches.find { |rb| rb.name == remote_branch_name }
74
+ local_name = branch.name[branch.remote_name.size + 1..-1]
75
+
76
+ puts "Checking out and tracking remote branch '#{local_name}'".green
77
+ new_branch = git.branches.create(local_name, branch.name)
78
+ new_branch.upstream = branch
79
+ git.checkout(local_name)
80
+ true
81
+ end
82
+
65
83
  def local_branches
66
- @local_branches ||= git.branches.each(:local).map(&:name)
84
+ @local_branches ||= git.branches.each(:local)
67
85
  end
68
86
 
69
- def remote_branch_for(issue)
70
- git.fetch('origin')
71
- return
72
- git.branches.each(:remote) do |branch|
73
- local_name = branch.name[branch.remote_name.size+1..-1]
74
- next unless local_name.start_with? "feature/##{issue}-"
75
- puts "Checking out and tracking remote branch '#{local_name}'".green
76
- new_branch = git.branches.create(local_name, branch.name)
77
- new_branch.upstream = branch
78
- git.checkout(local_name)
79
- return true
80
- end
81
- false
87
+ def remote_branches
88
+ @remote_branches ||= git.branches.each(:remote)
82
89
  end
83
90
 
84
91
  def git
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flight_plan_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Cleary