firespring_dev_commands 2.1.5.pre.alpha.4 → 2.1.6.pre.alpha.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
  SHA256:
3
- metadata.gz: 4b0ed9fd9f98ba8519047e26cdd8a2c9f9d17a36ab4fc7a5892a314443205e6d
4
- data.tar.gz: 8522ba7b6923d0098453ac9f38b37d42d13685a046ae1e4ccf81928af87ce8cf
3
+ metadata.gz: 17a02c0b5521ca1da3efb1b8374529732d7dde86060a9864f1d75be1ba070f6f
4
+ data.tar.gz: 9264d32211c1d1da7726215e8bf2c4f5df187f915ed9c38c29cdf336675b7e8b
5
5
  SHA512:
6
- metadata.gz: f86272afe09c769bf177cdd2707d0fdd6f550386aa2884f6f5705c9a5055b42f3298cc0fba75a0c05e9f15f76bf9ecda26e839034364e99f6432bea76c43455e
7
- data.tar.gz: 39a5fe0b5822deedde861270278346376bbf1c855e1945fa48dcc0d9ad0f5585bc9e609dac6c7d649519a2dc438bfb4597e399b6a81296c43f1019c74b000217
6
+ metadata.gz: 436338662d1889eec74a3c5fac8ca50427fa0f58ec2a6a256f7689015217bc8738618e26b14260d3648e650d93bfa4ce64d9fc49ec974204815fb49d2ec09a6b
7
+ data.tar.gz: 30158eb11227b227d711011bd77db61b1dc8bac6a8fda0760a89e21b8d60434a3f443162499313312d285ccf8c3cac751a5ad106f80c1bfa0e9139d973662028
@@ -41,7 +41,7 @@ module Dev
41
41
  # If the user answers 'y' then the block is executed.
42
42
  # If the user answers 'n' then the block is skipped.
43
43
  def with_confirmation(message, default = 'y', color_message: true)
44
- message = "\n #{message}? "
44
+ message = "\n #{message}" << '? '.light_green
45
45
  message = message.light_green if color_message
46
46
  print message
47
47
  print '('.light_green << 'y'.light_yellow << '/'.light_green << 'n'.light_yellow << ') '.light_green
@@ -203,7 +203,7 @@ module Dev
203
203
 
204
204
  # Checks out the given branch in the given repo
205
205
  # Defaults to the current directory
206
- def checkout(branch, dir: default_project_dir)
206
+ def checkout(branch, dir: default_project_dir, raise_errors: false)
207
207
  raise 'branch is required' if branch.to_s.strip.empty?
208
208
  return unless File.exist?(dir)
209
209
 
@@ -224,12 +224,14 @@ module Dev
224
224
  indent g.pull('origin', actual_branch)
225
225
  true
226
226
  rescue ::Git::GitExecuteError => e
227
+ raise e if raise_errors
228
+
227
229
  print_errors(e.message)
228
230
  false
229
231
  end
230
232
 
231
233
  # Create the given branch in the given repo
232
- def create_branch(branch, dir: default_project_dir)
234
+ def create_branch(branch, dir: default_project_dir, raise_errors: false)
233
235
  raise 'branch is required' if branch.to_s.strip.empty?
234
236
  raise "refusing to create protected branch '#{branch}'" if %w(master develop).any?(branch.to_s.strip)
235
237
  return unless File.exist?(dir)
@@ -240,7 +242,7 @@ module Dev
240
242
  g = ::Git.open(dir)
241
243
  g.fetch('origin', prune: true)
242
244
 
243
- puts "Fetching the latest changes for base branch #{staging_branch}"
245
+ puts "Fetching the latest changes for base branch \"#{staging_branch}\""
244
246
  g.checkout(staging_branch)
245
247
  g.pull('origin', staging_branch)
246
248
 
@@ -251,6 +253,19 @@ module Dev
251
253
  g.config("branch.#{branch}.merge", "refs/heads/#{branch}")
252
254
  puts
253
255
  rescue ::Git::GitExecuteError => e
256
+ raise e if raise_errors
257
+
258
+ print_errors(e.message)
259
+ false
260
+ end
261
+
262
+ def add(*paths, dir: default_project_dir, raise_errors: false)
263
+ g = ::Git.open(dir)
264
+ indent g.add(paths)
265
+ true
266
+ rescue ::Git::GitExecuteError => e
267
+ raise e if raise_errors
268
+
254
269
  print_errors(e.message)
255
270
  false
256
271
  end
@@ -277,7 +292,7 @@ module Dev
277
292
  end
278
293
 
279
294
  # Merge the given branch into the given repo
280
- def merge(branch, dir: default_project_dir)
295
+ def merge(branch, dir: default_project_dir, raise_errors: false)
281
296
  raise 'branch is required' if branch.to_s.strip.empty?
282
297
  return unless File.exist?(dir)
283
298
 
@@ -296,6 +311,8 @@ module Dev
296
311
  indent g.merge(branch)
297
312
  true
298
313
  rescue ::Git::GitExecuteError => e
314
+ raise e if raise_errors
315
+
299
316
  print_errors(e.message)
300
317
  false
301
318
  end
@@ -320,7 +337,7 @@ module Dev
320
337
  end
321
338
 
322
339
  # Pull the given repo
323
- def pull(dir: default_project_dir)
340
+ def pull(dir: default_project_dir, raise_errors: false)
324
341
  return unless File.exist?(dir)
325
342
 
326
343
  g = ::Git.open(dir)
@@ -331,6 +348,8 @@ module Dev
331
348
  indent g.pull('origin', branch)
332
349
  true
333
350
  rescue ::Git::GitExecuteError => e
351
+ raise e if raise_errors
352
+
334
353
  print_errors(e.message)
335
354
  false
336
355
  end
@@ -355,7 +374,7 @@ module Dev
355
374
  end
356
375
 
357
376
  # Push the given repo
358
- def push(dir: default_project_dir)
377
+ def push(dir: default_project_dir, raise_errors: false)
359
378
  return unless File.exist?(dir)
360
379
 
361
380
  g = ::Git.open(dir)
@@ -366,6 +385,8 @@ module Dev
366
385
  indent g.push('origin', branch)
367
386
  true
368
387
  rescue ::Git::GitExecuteError => e
388
+ raise e if raise_errors
389
+
369
390
  print_errors(e.message)
370
391
  false
371
392
  end
@@ -378,7 +399,7 @@ module Dev
378
399
  # Clones the repo_name into the dir
379
400
  # Optionally specify a repo_org
380
401
  # Optionally specify a branch to check out (defaults to the repository default branch)
381
- def clone_repo(dir:, repo_name:, repo_org: 'firespring', branch: nil)
402
+ def clone_repo(dir:, repo_name:, repo_org: 'firespring', branch: nil, depth: nil)
382
403
  if Dir.exist?("#{dir}/.git")
383
404
  puts "#{dir} already cloned".light_green
384
405
  return
@@ -390,6 +411,7 @@ module Dev
390
411
 
391
412
  opts = {}
392
413
  opts[:branch] = branch unless branch.to_s.strip.empty?
414
+ opts[:depth] = depth unless depth.to_s.strip.empty?
393
415
  g = ::Git.clone(ssh_repo_url(repo_name, repo_org), dir, opts)
394
416
  g.fetch('origin', prune: true)
395
417
  end
@@ -3,9 +3,9 @@ module Dev
3
3
  # Contains information and methods representing a Jira issue
4
4
  class Issue
5
5
  # Issue subtypes which do not map to a story type
6
- NON_STORY_TYPES = ['epic', 'review', 'sub-task', 'code review sub-task', 'pre-deploy sub-task', 'deploy sub-task', 'devops sub-task'].freeze
6
+ NON_STORY_TYPES = ['review', 'sub-task', 'code review sub-task', 'pre-deploy sub-task', 'deploy sub-task', 'devops sub-task'].freeze
7
7
 
8
- attr_accessor :data, :project, :id, :title, :points, :assignee, :resolved_date, :histories, :in_progress_history, :in_review_history, :closed_history
8
+ attr_accessor :data, :project, :id, :title, :points, :assignee, :resolved_date
9
9
 
10
10
  def initialize(data)
11
11
  @data = data
@@ -15,71 +15,10 @@ module Dev
15
15
  @points = calculate_points(data)
16
16
  @assignee = Jira::User.lookup(data.assignee&.accountId)
17
17
  @resolved_date = data.resolutiondate
18
- @histories = Jira::Histories.populate(data)
19
- @in_progress_history = nil
20
- @in_review_history = nil
21
- @closed_history = nil
22
- end
23
-
24
- def cycle_time
25
- # Calculate the difference and convert to days
26
- ((last_closed_history.created - last_in_progress_history.created) / 60 / 60 / 24).round(2)
27
- end
28
-
29
- def in_progress_cycle_time
30
- # Calculate the difference and convert to days
31
- ((first_in_review_history.created - last_in_progress_history.created) / 60 / 60 / 24).round(2)
32
- end
33
-
34
- def in_review_cycle_time
35
- # Calculate the difference and convert to days
36
- ((last_closed_history.created - first_in_review_history.created) / 60 / 60 / 24).round(2)
37
- end
38
-
39
- private def last_in_progress_history
40
- raise 'you must expand the changelog field to calculate cycle time' if histories.nil?
41
-
42
- # Find the first instance in the histoy where the status moved to "In Progress"
43
- @in_progress_history ||= histories.select do |history|
44
- history.items.find do |item|
45
- item['fieldId'] == 'status' && item['fromString'] == 'Open' && item['toString'] == 'In Progress'
46
- end
47
- end.max_by(&:created)
48
- raise 'unable to find "In Progress" history entry needed to calculate cycle time' unless @in_progress_history
49
-
50
- @in_progress_history
51
- end
52
-
53
- private def first_in_review_history
54
- raise 'you must expand the changelog field to calculate cycle time' if histories.nil?
55
-
56
- # Find the first instance in the histoy where the status moved to "In Review"
57
- @in_review_history ||= histories.select do |history|
58
- history.items.find do |item|
59
- item['fieldId'] == 'status' && item['toString'] == 'In Review'
60
- end
61
- end.min_by(&:created)
62
- raise 'unable to find "In Review" history entry needed to calculate cycle time' unless @in_review_history
63
-
64
- @in_review_history
65
- end
66
-
67
- private def last_closed_history
68
- raise 'you must expand the changelog field to calculate cycle time' if histories.nil?
69
-
70
- # Find the last instance in the histoy where the status moved to "Closed"
71
- @closed_history ||= histories.select do |history|
72
- history.items.find do |item|
73
- item['fieldId'] == 'status' && item['toString'] == 'Closed'
74
- end
75
- end.max_by(&:created)
76
- raise 'unable to find "Closed" history entry needed to calculate cycle time' unless @closed_history
77
-
78
- @closed_history
79
18
  end
80
19
 
81
20
  # Returns the value of the jira points field or 0 if the field is not found
82
- private def calculate_points(data)
21
+ def calculate_points(data)
83
22
  return data.send(Dev::Jira.config.points_field_name).to_i if Dev::Jira.config.points_field_name && data.respond_to?(Dev::Jira.config.points_field_name)
84
23
 
85
24
  0
@@ -9,16 +9,15 @@ module Dev
9
9
  # "user_lookup_list" should be an array of Jira::User objects representing the usernames, ids, etc for all jira users
10
10
  # This is a bit clumsy but currently the jira api only returns the user id with issues
11
11
  # and there is no way to query this information from Jira directly.
12
- Config = Struct.new(:username, :token, :url, :points_field_name, :expand, :user_lookup_list, :read_timeout, :http_debug) do
12
+ Config = Struct.new(:username, :token, :url, :points_field_name, :user_lookup_list, :read_timeout, :http_debug) do
13
13
  def initialize
14
14
  self.username = nil
15
15
  self.token = nil
16
16
  self.url = nil
17
17
  self.points_field_name = nil
18
- self.expand = []
19
18
  self.user_lookup_list = []
20
19
  self.read_timeout = 120
21
- self.http_debug = true
20
+ self.http_debug = false
22
21
  end
23
22
  end
24
23
 
@@ -63,16 +62,15 @@ module Dev
63
62
  def issues(jql, &)
64
63
  start_at = 0
65
64
  max_results = 100
66
- expand = self.class.config.expand
67
65
 
68
66
  # Query Jira and yield all issues it returns
69
- issues = @client.Issue.jql(jql, start_at:, max_results:, expand:)
67
+ issues = @client.Issue.jql(jql, start_at:, max_results:)
70
68
  issues.map { |data| Issue.new(data) }.each(&)
71
69
 
72
70
  # If we returned the max_results then there may be more - add the max results to where we start at and query again
73
71
  while issues.length >= max_results
74
72
  start_at += max_results
75
- issues = @client.Issue.jql(jql, start_at:, max_results:, expand:)
73
+ issues = @client.Issue.jql(jql, start_at:, max_results:)
76
74
  issues.map { |data| Issue.new(data) }.each(&)
77
75
  end
78
76
  end
@@ -6,6 +6,6 @@ module Dev
6
6
  # Use 'v.v.v.pre.alpha.v' for pre-release vesions
7
7
  # Use 'v.v.v.beta.v for beta versions
8
8
  # Use semantic versioning for any releases (https://semver.org/)
9
- VERSION = '2.1.5.pre.alpha.4'.freeze
9
+ VERSION = '2.1.6.pre.alpha.2'.freeze
10
10
  end
11
11
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: firespring_dev_commands
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.5.pre.alpha.4
4
+ version: 2.1.6.pre.alpha.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Firespring
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-31 00:00:00.000000000 Z
11
+ date: 2023-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -284,8 +284,6 @@ files:
284
284
  - lib/firespring_dev_commands/git.rb
285
285
  - lib/firespring_dev_commands/git/info.rb
286
286
  - lib/firespring_dev_commands/jira.rb
287
- - lib/firespring_dev_commands/jira/histories.rb
288
- - lib/firespring_dev_commands/jira/history.rb
289
287
  - lib/firespring_dev_commands/jira/issue.rb
290
288
  - lib/firespring_dev_commands/jira/project.rb
291
289
  - lib/firespring_dev_commands/jira/user.rb
@@ -1,11 +0,0 @@
1
- module Dev
2
- class Jira
3
- class Histories
4
- def self.populate(data)
5
- return nil unless data.attrs.key?('changelog')
6
-
7
- data.changelog['histories'].map { |it| Jira::History.new(it) }
8
- end
9
- end
10
- end
11
- end
@@ -1,17 +0,0 @@
1
- require 'date'
2
-
3
- module Dev
4
- class Jira
5
- class History
6
- attr_accessor :date, :id, :author, :created, :items
7
-
8
- def initialize(data)
9
- @data = data
10
- @id = data['id']
11
- @author = data['author']
12
- @items = data['items']
13
- @created = Time.parse(data['created'])
14
- end
15
- end
16
- end
17
- end