git-story-workflow 0.1.3 → 0.2.0
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/git-story-workflow.gemspec +3 -3
- data/lib/git/story/app.rb +68 -25
- data/lib/git/story/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b22aeccbb93e24c1ed444a5d846b739d35bf015bf09abfb7d5030ef88c740de
|
4
|
+
data.tar.gz: 445b375ad12702e5d4ffd5179014e0e360e70088bfc703bbf6c72256a583e16c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87ed8b1af5ae2754fbe5a4be9bcf0f5261da02601ffdcbf5892a2d29dab3da64c9704d9a1539a99cd007d8fb82d8945519e83c4d29bd11521b544bb3c4f60e86
|
7
|
+
data.tar.gz: f43aa63dee9673b3edf0ad8fd0caae1c25326f271b0842e50566e67cf358c61c758916db8d88307ba4f8016ed35b89a66af210f3c9b52d6d549f6c0443767611
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/git-story-workflow.gemspec
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: git-story-workflow 0.
|
2
|
+
# stub: git-story-workflow 0.2.0 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "git-story-workflow".freeze
|
6
|
-
s.version = "0.
|
6
|
+
s.version = "0.2.0"
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
9
9
|
s.require_paths = ["lib".freeze]
|
10
10
|
s.authors = ["Florian Frank".freeze]
|
11
|
-
s.date = "2017-12-
|
11
|
+
s.date = "2017-12-15"
|
12
12
|
s.description = "Gem abstracting a git workflow\u2026".freeze
|
13
13
|
s.email = "flori@ping.de".freeze
|
14
14
|
s.executables = ["git-story".freeze]
|
data/lib/git/story/app.rb
CHANGED
@@ -59,8 +59,15 @@ class Git::Story::App
|
|
59
59
|
|
60
60
|
command doc: 'output the current story branch if it is checked out'
|
61
61
|
def current(check: true)
|
62
|
-
check
|
63
|
-
|
62
|
+
if check
|
63
|
+
if cb = current_branch_checked?
|
64
|
+
cb
|
65
|
+
else
|
66
|
+
error 'Switch to a story branch first for this operation!'
|
67
|
+
end
|
68
|
+
else
|
69
|
+
current_branch
|
70
|
+
end
|
64
71
|
end
|
65
72
|
|
66
73
|
def provide_name(story_id = nil)
|
@@ -116,6 +123,36 @@ class Git::Story::App
|
|
116
123
|
"Getting #{url.inspect} => #{e.class}: #{e}".red
|
117
124
|
end
|
118
125
|
|
126
|
+
command doc: '[STORY_ID] fetch status of current story'
|
127
|
+
def status(story_id = current(check: true)&.[](/_(\d+)\z/, 1)&.to_i)
|
128
|
+
if story = fetch_story(story_id)
|
129
|
+
jj story
|
130
|
+
color_state =
|
131
|
+
case cs = story.current_state
|
132
|
+
when 'unscheduled', 'planned', 'unstarted'
|
133
|
+
cs
|
134
|
+
when 'rejected'
|
135
|
+
cs.white.on_red
|
136
|
+
when 'accepted'
|
137
|
+
cs.green
|
138
|
+
else
|
139
|
+
cs.yellow
|
140
|
+
end
|
141
|
+
<<~end
|
142
|
+
Id: #{story.id}
|
143
|
+
Name: #{story.name.inspect.bold}
|
144
|
+
Type: #{story.story_type}
|
145
|
+
Estimate: #{story.estimate.to_s.yellow.bold}
|
146
|
+
State: #{color_state}
|
147
|
+
Branch: #{current_branch_checked?&.color('#ff5f00')}
|
148
|
+
Pivotal: #{story.url}
|
149
|
+
Labels: #{story.labels.map(&:name) * ?,}
|
150
|
+
end
|
151
|
+
end
|
152
|
+
rescue => e
|
153
|
+
"Getting pivotal story status => #{e.class}: #{e}".red
|
154
|
+
end
|
155
|
+
|
119
156
|
command doc: '[AUTHOR] list all stories'
|
120
157
|
def list(author = nil, mark_red: current(check: false))
|
121
158
|
stories.map { |b|
|
@@ -252,9 +289,11 @@ class Git::Story::App
|
|
252
289
|
end
|
253
290
|
|
254
291
|
def fetch_story_name(story_id)
|
255
|
-
|
256
|
-
|
257
|
-
|
292
|
+
fetch_story(story_id)&.name
|
293
|
+
end
|
294
|
+
|
295
|
+
def fetch_story(story_id)
|
296
|
+
pivotal_get("projects/#{pivotal_project}/stories/#{story_id}").full?
|
258
297
|
end
|
259
298
|
|
260
299
|
def pivotal_get(path)
|
@@ -278,36 +317,40 @@ class Git::Story::App
|
|
278
317
|
sh 'git fetch --tags'
|
279
318
|
end
|
280
319
|
|
320
|
+
def apply_story_accessors(ref)
|
321
|
+
branch =~ BRANCH_NAME_REGEX or return
|
322
|
+
branch.extend StoryAccessors
|
323
|
+
branch.story_base_name = ref[0]
|
324
|
+
branch.story_name = $1
|
325
|
+
branch.story_id = $2.to_i
|
326
|
+
branch.story_created_at = ref[1]
|
327
|
+
branch.story_author = ref[2]
|
328
|
+
branch
|
329
|
+
end
|
330
|
+
|
281
331
|
def stories
|
282
332
|
sh 'git remote prune origin', error: false
|
283
333
|
refs = capture("git for-each-ref --format='%(refname);%(committerdate);%(authorname) %(authoremail)'")
|
284
334
|
refs = refs.lines.map { |l|
|
285
|
-
|
286
|
-
next unless
|
287
|
-
|
288
|
-
next unless
|
289
|
-
|
290
|
-
|
291
|
-
}.compact.map do |
|
292
|
-
|
293
|
-
|
294
|
-
b.extend StoryAccessors
|
295
|
-
b.story_base_name = r[0]
|
296
|
-
b.story_name = $1
|
297
|
-
b.story_id = $2.to_i
|
298
|
-
b.story_created_at = r[1]
|
299
|
-
b.story_author = r[2]
|
300
|
-
b
|
301
|
-
end
|
335
|
+
ref = l.chomp.split(?;)
|
336
|
+
next unless ref[0] =~ %r(/origin/)
|
337
|
+
ref[0] = File.basename(ref[0])
|
338
|
+
next unless ref[0] =~ BRANCH_NAME_REGEX
|
339
|
+
ref[1] = Time.parse(ref[1])
|
340
|
+
ref
|
341
|
+
}.compact.map do |ref|
|
342
|
+
apply_story_accessors ref
|
343
|
+
end.compact
|
302
344
|
end
|
303
345
|
|
304
346
|
def current_branch
|
305
347
|
capture("git rev-parse --abbrev-ref HEAD").strip
|
306
348
|
end
|
307
349
|
|
308
|
-
def
|
309
|
-
current_branch =~ BRANCH_NAME_REGEX
|
310
|
-
|
350
|
+
def current_branch_checked?
|
351
|
+
if (cb = current_branch) =~ BRANCH_NAME_REGEX
|
352
|
+
cb
|
353
|
+
end
|
311
354
|
end
|
312
355
|
|
313
356
|
def format_tag_time(tag)
|
data/lib/git/story/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git-story-workflow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Frank
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-12-
|
11
|
+
date: 2017-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gem_hadar
|