flight_plan_cli 0.3.1 → 0.3.2
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.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/flight_plan_cli.rb +3 -1
- data/lib/flight_plan_cli/commands/checkout.rb +29 -37
- data/lib/flight_plan_cli/commands/list.rb +1 -1
- data/lib/flight_plan_cli/config.rb +1 -4
- data/lib/flight_plan_cli/initializer.rb +1 -4
- metadata +5 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78abdf93216c32be174a21b8350173c19df18706
|
4
|
+
data.tar.gz: a9721ca5c475dd68cb11dd0526ae68ce69520a32
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 994f2bb6917b9066089da05c5507414e9323fa70634cc6e6cb746108af967b03fa1b787ebbc8d52371a5fee597c7589cb0a152fea7b6949b55f079a915e36326
|
7
|
+
data.tar.gz: 45f9ffa08b3eefbf43eaaebac7ebaebd6b8e3480b1aec9de2619e142e3049a3beabec40aee184ad7bc693370b5f55427dd4cb942fcc683aa6a943254e0c803e8
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.2
|
data/lib/flight_plan_cli.rb
CHANGED
@@ -3,23 +3,25 @@ module FlightPlanCli
|
|
3
3
|
class Checkout
|
4
4
|
include FlightPlanCli::Config
|
5
5
|
|
6
|
-
def initialize
|
6
|
+
def initialize(issue_no)
|
7
|
+
@issue_no = issue_no
|
8
|
+
@fetched = false
|
7
9
|
read_config
|
8
10
|
end
|
9
11
|
|
10
|
-
def process
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
rescue Rugged::CheckoutError => e
|
16
|
-
puts "Unable to checkout: #{e.message}".red
|
12
|
+
def process
|
13
|
+
local_branch_for_issue || remote_branch_for_issue || new_branch_for_issue
|
14
|
+
rescue Git::GitExecuteError => e
|
15
|
+
puts 'Unable to checkout'.red
|
16
|
+
puts e.message.yellow
|
17
17
|
end
|
18
18
|
|
19
19
|
private
|
20
20
|
|
21
|
-
|
22
|
-
|
21
|
+
attr_reader :issue_no
|
22
|
+
|
23
|
+
def local_branch_for_issue
|
24
|
+
issue_branches = local_branches.map(&:name).grep(/##{issue_no}[^0-9]/)
|
23
25
|
return false unless issue_branches.count == 1
|
24
26
|
|
25
27
|
branch = issue_branches.first
|
@@ -28,8 +30,8 @@ module FlightPlanCli
|
|
28
30
|
true
|
29
31
|
end
|
30
32
|
|
31
|
-
def
|
32
|
-
issue_branches = remote_branches.map(&:name).grep(/##{
|
33
|
+
def remote_branch_for_issue
|
34
|
+
issue_branches = remote_branches.map(&:name).grep(/##{issue_no}[^0-9]/)
|
33
35
|
return false unless issue_branches.count == 1
|
34
36
|
|
35
37
|
remote_branch_name = issue_branches.first
|
@@ -47,51 +49,41 @@ module FlightPlanCli
|
|
47
49
|
git.checkout(local_name)
|
48
50
|
end
|
49
51
|
|
50
|
-
def
|
51
|
-
|
52
|
+
def new_branch_for_issue
|
53
|
+
git.checkout('master')
|
54
|
+
git.pull
|
55
|
+
branches = client.board_tickets(remote_number: issue_no)
|
52
56
|
# TODO: update flight_plan to only return one issue when remote_numer is provided
|
53
|
-
branches = branches.select { |b| b['ticket']['remote_number'] ==
|
57
|
+
branches = branches.select { |b| b['ticket']['remote_number'] == issue_no }
|
54
58
|
return false unless branches.count == 1
|
55
59
|
|
56
60
|
branch_name = branch_name(branches.first)
|
57
|
-
|
58
61
|
puts "Creating new branch #{branch_name} from master".green
|
59
|
-
|
60
|
-
git.branches.create(branch_name, 'origin/master')
|
61
|
-
git.checkout(branch_name)
|
62
|
+
git.branch(branch_name).checkout
|
62
63
|
end
|
63
64
|
|
64
65
|
def branch_name(branch)
|
65
66
|
"feature/##{branch['ticket']['remote_number']}-" +
|
66
67
|
branch['ticket']['remote_title']
|
67
|
-
|
68
|
-
|
69
|
-
|
68
|
+
.gsub(/[^a-z0-9\s]/i, '')
|
69
|
+
.tr(' ', '-')
|
70
|
+
.downcase
|
70
71
|
end
|
71
72
|
|
72
73
|
def local_branches
|
73
|
-
|
74
|
+
git.branches.local
|
74
75
|
end
|
75
76
|
|
76
77
|
def remote_branches
|
77
|
-
|
78
|
-
|
79
|
-
fetch
|
80
|
-
git.branches.each(:remote)
|
81
|
-
end
|
78
|
+
fetch
|
79
|
+
git.branches.remote
|
82
80
|
end
|
83
81
|
|
84
82
|
def fetch
|
83
|
+
return if @fetched
|
85
84
|
puts 'Fetching...'.green
|
86
|
-
git.
|
87
|
-
|
88
|
-
|
89
|
-
def credentials
|
90
|
-
@ssh_agent ||= Rugged::Credentials::SshKey.new(
|
91
|
-
username: 'git',
|
92
|
-
publickey: File.expand_path(git_ssh_public_key),
|
93
|
-
privatekey: File.expand_path(git_ssh_private_key)
|
94
|
-
)
|
85
|
+
git.remote('origin').fetch
|
86
|
+
@fetched = true
|
95
87
|
end
|
96
88
|
end
|
97
89
|
end
|
@@ -58,7 +58,7 @@ module FlightPlanCli
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def print_ticket(ticket)
|
61
|
-
checked_out = git.
|
61
|
+
checked_out = git.current_branch =~ /##{ticket['remote_number']}[^0-9]/
|
62
62
|
line =
|
63
63
|
" #{ticket['remote_number']}".colorize(Color::ISSUE_NO) +
|
64
64
|
" #{ticket['remote_title']} ".colorize(Color::ISSUE)
|
@@ -7,7 +7,6 @@ module FlightPlanCli
|
|
7
7
|
|
8
8
|
attr_reader :board_id, :repo_id, :default_swimlane_ids
|
9
9
|
attr_reader :api_url, :api_key, :api_secret
|
10
|
-
attr_reader :git_ssh_public_key, :git_ssh_private_key
|
11
10
|
|
12
11
|
def read_config
|
13
12
|
@board_id = config['board_id']
|
@@ -17,8 +16,6 @@ module FlightPlanCli
|
|
17
16
|
@api_url = config['api_url']
|
18
17
|
@api_key = config['flight_plan_api_key']
|
19
18
|
@api_secret = config['flight_plan_api_secret']
|
20
|
-
@git_ssh_private_key = config['git_ssh_private_key'] || '~/.ssh/id_rsa'
|
21
|
-
@git_ssh_public_key = config['git_ssh_public_key'] || '~/.ssh/id_rsa.pub'
|
22
19
|
end
|
23
20
|
|
24
21
|
def client
|
@@ -32,7 +29,7 @@ module FlightPlanCli
|
|
32
29
|
end
|
33
30
|
|
34
31
|
def git
|
35
|
-
@git ||=
|
32
|
+
@git ||= Git.open(Dir.pwd)
|
36
33
|
end
|
37
34
|
|
38
35
|
def config
|
@@ -1,6 +1,3 @@
|
|
1
|
-
require 'thor'
|
2
|
-
require 'colorize'
|
3
|
-
require 'rugged'
|
4
1
|
|
5
2
|
module FlightPlanCli
|
6
3
|
class ApiUnauthorized < StandardError; end
|
@@ -21,7 +18,7 @@ module FlightPlanCli
|
|
21
18
|
|
22
19
|
desc 'checkout ISSUE_NO', 'checkout a branch for ISSUE_NO'
|
23
20
|
def checkout(issue_no)
|
24
|
-
Commands::Checkout.new
|
21
|
+
Commands::Checkout.new(issue_no).process
|
25
22
|
end
|
26
23
|
|
27
24
|
map co: :checkout
|
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.3.
|
4
|
+
version: 0.3.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-02-
|
11
|
+
date: 2018-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -123,19 +123,19 @@ dependencies:
|
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: 0.7.3
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
126
|
+
name: git
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
129
|
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
131
|
+
version: 1.3.0
|
132
132
|
type: :runtime
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version:
|
138
|
+
version: 1.3.0
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: httparty
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -150,20 +150,6 @@ dependencies:
|
|
150
150
|
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: 0.13.1
|
153
|
-
- !ruby/object:Gem::Dependency
|
154
|
-
name: rugged
|
155
|
-
requirement: !ruby/object:Gem::Requirement
|
156
|
-
requirements:
|
157
|
-
- - "~>"
|
158
|
-
- !ruby/object:Gem::Version
|
159
|
-
version: 0.26.0
|
160
|
-
type: :runtime
|
161
|
-
prerelease: false
|
162
|
-
version_requirements: !ruby/object:Gem::Requirement
|
163
|
-
requirements:
|
164
|
-
- - "~>"
|
165
|
-
- !ruby/object:Gem::Version
|
166
|
-
version: 0.26.0
|
167
153
|
- !ruby/object:Gem::Dependency
|
168
154
|
name: thor
|
169
155
|
requirement: !ruby/object:Gem::Requirement
|