firespring_dev_commands 2.1.5 → 2.1.6.pre.alpha.1

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: 3fb1d7a847389490b27a05b29cfa091a8f273edc0002d2e5ce770518562e105a
4
- data.tar.gz: a22c86bccfecddae1c3688ab2a0433fbfdb7a9129bb29d3d401932bd9e94c3e0
3
+ metadata.gz: 451ceb21b24126c1eb8ebd4635902c06daabd16ca85612f9ee0145ccefa49abf
4
+ data.tar.gz: bf53af68e42f2cc71404eca2f2f94171b3769526d113acce4178359e64ccd61e
5
5
  SHA512:
6
- metadata.gz: 024f67336c233aeaf3f9d80a85f265c07dabc4e84e82affaba1e21c03217961fec4828271874d7c1378f93b0109d70b055bc9a32ba23faf75f8b2491424abed8
7
- data.tar.gz: af5615634eaa912b11d33cc4825deb247586e67ea71567d2efaa310cc0c8db5b0fa425a9eaae89585b4a1574e31408f9c55625d7fff5faf27b165e3df67a3a27
6
+ metadata.gz: c6935ea8724be8a8951c87df3f95bce474b89c8c1b196983f8b7f065245c393dd3a09328a36b8daabc7bcd28f8c670d245e539087fa1df4b3b739c965f60b4c7
7
+ data.tar.gz: da345d11a73d39e46beedffbf7522f9770b15310a7cf9be4911d2576ab78d951d915912a20e377b5467f66bbae83ddf5c7a34cdd1556cce443aca9264e39a8c7
@@ -378,7 +378,7 @@ module Dev
378
378
  # Clones the repo_name into the dir
379
379
  # Optionally specify a repo_org
380
380
  # 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)
381
+ def clone_repo(dir:, repo_name:, repo_org: 'firespring', branch: nil, depth: nil)
382
382
  if Dir.exist?("#{dir}/.git")
383
383
  puts "#{dir} already cloned".light_green
384
384
  return
@@ -390,6 +390,7 @@ module Dev
390
390
 
391
391
  opts = {}
392
392
  opts[:branch] = branch unless branch.to_s.strip.empty?
393
+ opts[:depth] = depth unless depth.to_s.strip.empty?
393
394
  g = ::Git.clone(ssh_repo_url(repo_name, repo_org), dir, opts)
394
395
  g.fetch('origin', prune: true)
395
396
  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, :last_in_progress_history, :first_in_review_history, :last_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
- @last_in_progress_history = nil
20
- @first_in_review_history = nil
21
- @last_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
- @last_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 @last_in_progress_history
49
-
50
- @last_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
- @first_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 @first_in_review_history
63
-
64
- @first_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
- @last_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 @last_closed_history
77
-
78
- @last_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,13 +9,12 @@ 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
20
  self.http_debug = false
@@ -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'.freeze
9
+ VERSION = '2.1.6.pre.alpha.1'.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
4
+ version: 2.1.6.pre.alpha.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Firespring
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-06 00:00:00.000000000 Z
11
+ date: 2023-09-01 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
@@ -333,9 +331,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
333
331
  version: '3.1'
334
332
  required_rubygems_version: !ruby/object:Gem::Requirement
335
333
  requirements:
336
- - - ">="
334
+ - - ">"
337
335
  - !ruby/object:Gem::Version
338
- version: '0'
336
+ version: 1.3.1
339
337
  requirements: []
340
338
  rubygems_version: 3.4.10
341
339
  signing_key:
@@ -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