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 +4 -4
- data/VERSION +1 -1
- data/lib/flight_plan_cli/initializer.rb +23 -16
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4b7888cb0ed509d5dc14e48c856f67c929c3a68
|
4
|
+
data.tar.gz: af5a01246e6979e28eda904000280d796ecd9f6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12efa16013e4409e369a63a21049edd4298c74914ea3e7bff8b90eb918b1507ac1db407f80ffbd8ac9dc72a996a1cd9a9ab35b64d4b9253e6637e1c881f01d53
|
7
|
+
data.tar.gz: c6e89e95945b59f862eae6c5f63db34405a88c450cd1b66c01a86031b207972f6ad716902e21d45a57e5cf58b9e467300ce91472f1efaa44016d15c462c87052
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.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(
|
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)
|
84
|
+
@local_branches ||= git.branches.each(:local)
|
67
85
|
end
|
68
86
|
|
69
|
-
def
|
70
|
-
git.
|
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
|