git-story-workflow 0.0.1 → 0.0.2

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: 46807494af7a6be5225943b1039b703e780e17a5
4
- data.tar.gz: 5127db01c16bbc1da8eaae977a1daa697a0ad8d7
3
+ metadata.gz: bf07f9f4c2ba53aa0f34cfd6bd62b50c35f03cdf
4
+ data.tar.gz: b1e14858e8fb8006ed03f52dce06580132335d90
5
5
  SHA512:
6
- metadata.gz: f05b445a33d9259f375c3b092e256f27ef2ee16ec4c634beb580ef0163281536f32223517f7e85937856817e235edfb5fdc82f7fb4ff132052683545a3327510
7
- data.tar.gz: 821da3ebd77d2426467121f112eca6e21a9f1d8488b587476c95179aa56891ac7bb35020d2285b68fa26bacbfbaf59058bc91fdff75487be868e9d1348fafa69
6
+ metadata.gz: 7e86b06c49a7154dd16d444788023df00ec7c63af4d517b7da3e5d30584366fdc4ee8d038716e5ee6468fb3d98d48bea1371e65af01d50a4d090071ec671313f
7
+ data.tar.gz: 02fced5abd048bd96743f7c1605d17ed1f3d068ce3e5d6e3eb4b288aea483f8fd2b05f5cd7fe0fa2b0b7f251c5c75813c8f9e19f6ced63fb67ac59428fd04b91
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -1,9 +1,9 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: git-story-workflow 0.0.1 ruby lib
2
+ # stub: git-story-workflow 0.0.2 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "git-story-workflow".freeze
6
- s.version = "0.0.1"
6
+ s.version = "0.0.2"
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]
@@ -20,9 +20,10 @@ class Git::Story::App
20
20
  attr_accessor :story_id
21
21
  end
22
22
 
23
- def initialize(argv = ARGV)
23
+ def initialize(argv = ARGV, debug: ENV['DEBUG'].to_i == 1)
24
24
  @argv = argv
25
25
  @command = @argv.shift&.to_sym
26
+ @debug = debug
26
27
  end
27
28
 
28
29
  def run
@@ -84,7 +85,9 @@ class Git::Story::App
84
85
  command doc: 'list all production deploy tags'
85
86
  def deploy_tags
86
87
  fetch_tags
87
- `git tag | grep ^#{complex_config.story.deploy_tag_prefix} | sort`.lines.map(&:chomp)
88
+ capture(
89
+ "git tag | grep ^#{complex_config.story.deploy_tag_prefix} | sort"
90
+ ).lines.map(&:chomp)
88
91
  end
89
92
 
90
93
  command doc: 'output the times of all production deploys'
@@ -107,21 +110,21 @@ class Git::Story::App
107
110
  def deploy_log
108
111
  fetch_tags
109
112
  opts = '--pretty=tformat:"%C(yellow)%h%Creset %C(green)%ci%Creset %s (%Cred%an <%ae>%Creset)"'
110
- `git log #{opts} #{deploy_tags.last}..`
113
+ capture("git log #{opts} #{deploy_tags.last}..")
111
114
  end
112
115
 
113
116
  command doc: 'output diff since last production deploy tag'
114
- def deploy_diff
117
+ def deploy_diff(ref = nil)
115
118
  fetch_tags
116
119
  opts = '-u'
117
- `git diff --color #{opts} #{deploy_tags.last}`
120
+ capture("git diff --color #{opts} #{ref} #{deploy_tags.last}")
118
121
  end
119
122
 
120
- command doc: 'outpit migration diff since last production deploy tag'
121
- def deploy_migrate_diff
123
+ command doc: 'output migration diff since last production deploy tag'
124
+ def deploy_migrate_diff(ref = nil)
122
125
  fetch_tags
123
126
  opts = '-u'
124
- `git diff --color #{opts} #{deploy_tags.last} -- db/migrate`
127
+ capture("git diff --color #{opts} #{deploy_tags.last} #{ref} -- db/migrate")
125
128
  end
126
129
 
127
130
  command doc: '[STORYID] create a story for story STORYID'
@@ -196,7 +199,7 @@ class Git::Story::App
196
199
  def pivotal_get(path)
197
200
  path = path.sub(/\A\/*/, '')
198
201
  url = "https://www.pivotaltracker.com/services/v5/#{path}"
199
- $DEBUG and warn "Fetching #{url.inspect}"
202
+ @debug and STDERR.puts "Fetching #{url.inspect}"
200
203
  open(url,
201
204
  'X-TrackerToken' => pivotal_token,
202
205
  'Content-Type' => 'application/xml',
@@ -215,7 +218,7 @@ class Git::Story::App
215
218
 
216
219
  def stories
217
220
  sh 'git remote prune origin', error: false
218
- `git branch -r | grep -e '^ *origin/'`.lines.map do |l|
221
+ capture("git branch -r | grep -e '^ *origin/'").lines.map do |l|
219
222
  b = l.strip
220
223
  b_base = File.basename(b)
221
224
  if b_base =~ BRANCH_NAME_REGEX
@@ -229,7 +232,7 @@ class Git::Story::App
229
232
  end
230
233
 
231
234
  def current_branch
232
- `git rev-parse --abbrev-ref HEAD`.strip
235
+ capture("git rev-parse --abbrev-ref HEAD").strip
233
236
  end
234
237
 
235
238
  def check_current
@@ -4,6 +4,7 @@ module Git::Story::Utils
4
4
  include FileUtils::Verbose
5
5
 
6
6
  def sh(*a, error: true)
7
+ @debug and STDERR.puts("Executing #{a * ' '}")
7
8
  system(*a)
8
9
  if error && !$?.success?
9
10
  STDERR.puts ("Failed with rc #{$?.exitstatus}: " + a.join(' ')).red
@@ -11,6 +12,13 @@ module Git::Story::Utils
11
12
  end
12
13
  end
13
14
 
15
+ def capture(command)
16
+ @debug and STDERR.puts("Executing #{command.inspect}")
17
+ result = `#{command}`
18
+ @debug and STDERR.puts("Result\n#{result}")
19
+ result
20
+ end
21
+
14
22
  def ask(prompt: '? ', **options, &block)
15
23
  response = options[:preset]
16
24
  unless response
@@ -1,6 +1,6 @@
1
1
  module Git::Story
2
2
  # Git::Story version
3
- VERSION = '0.0.1'
3
+ VERSION = '0.0.2'
4
4
  VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-story-workflow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank