flight_plan_cli 0.2.1 → 0.2.2
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 +47 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78181ba943356a2938c0b17c0ebcb72ee0aa5d04
|
4
|
+
data.tar.gz: fe51626d77304f08f7b736b706a8cfbc7efd0a87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8667298164e296c2dfc04126bce4b0fb5ef23a19ce031cf52e2c770d6915b81d6f5c4c472c1d52be1a376ed910aa487e1e7a53c62fe5e932bb9e1be93e067269
|
7
|
+
data.tar.gz: d497fcceda6ddd0dbb3efad73a174c986fe16ea8e44c2bfd82936ac994c1153e4fb7b0406ea3e40ec411464b74adba408d3f0a9ec53e11821f41dacecf2a3f56
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.2
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'thor'
|
2
2
|
require 'colorize'
|
3
|
+
require 'rugged'
|
3
4
|
|
4
5
|
module FlightPlanCli
|
5
6
|
class ApiUnauthorized < StandardError; end
|
@@ -28,6 +29,14 @@ module FlightPlanCli
|
|
28
29
|
puts "Network error. #{e.message}".red
|
29
30
|
end
|
30
31
|
|
32
|
+
desc 'checkout ISSUE_NO', 'checkout a branch for ISSUE_NO'
|
33
|
+
def checkout(issue_no)
|
34
|
+
puts "Checking out branch for #{issue_no}"
|
35
|
+
local_branch_for(issue_no) || remote_branch_for(issuei_no)
|
36
|
+
end
|
37
|
+
|
38
|
+
map co: :checkout
|
39
|
+
|
31
40
|
private
|
32
41
|
|
33
42
|
attr_reader :board_id, :repo_id, :default_swimlane_ids
|
@@ -43,6 +52,44 @@ module FlightPlanCli
|
|
43
52
|
@api_secret = ENV['FLIGHT_PLAN_API_SECRET']
|
44
53
|
end
|
45
54
|
|
55
|
+
def local_branch_for(issue)
|
56
|
+
issue_branches = local_branches.grep(/##{issue}[^0-9]/)
|
57
|
+
return false unless issue_branches.count == 1
|
58
|
+
|
59
|
+
branch = issue_branches.first
|
60
|
+
puts "Checking out local branch '#{branch}'".green
|
61
|
+
git.checkout(branch)
|
62
|
+
true
|
63
|
+
end
|
64
|
+
|
65
|
+
def local_branches
|
66
|
+
@local_branches ||= git.branches.each(:local).map(&:name)
|
67
|
+
end
|
68
|
+
|
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
|
82
|
+
end
|
83
|
+
|
84
|
+
def git
|
85
|
+
@git ||= Rugged::Repository.new(Dir.pwd)
|
86
|
+
end
|
87
|
+
|
88
|
+
def fetch
|
89
|
+
puts 'fetching...'
|
90
|
+
git.remotes.each(&:fetch)
|
91
|
+
end
|
92
|
+
|
46
93
|
def print_swimlane(swimlane)
|
47
94
|
puts "#{swimlane['name']} (#{swimlane['tickets'].count})".green
|
48
95
|
swimlane['tickets'].each do |ticket|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flight_plan_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Cleary
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|