apadmi_grout 2.7.0 → 2.9.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c359c320e340ceb70fd0b212f657bb858958fa8fb5ef6037dca5891fc50a90f6
4
- data.tar.gz: f4d9eaf0b6fec2ede3829844314fbafc25c4f2a378185e4656f562f58e08b09f
3
+ metadata.gz: fa7ac0cd2f88e84cd7dfbde2c5d303d7387e83ba83e0cc8e1d8f503599b61e01
4
+ data.tar.gz: 21e9a197f5e22264462e01394e1c1b87bb289cbc3a7f20a65c7e50b254e1754c
5
5
  SHA512:
6
- metadata.gz: 669edb4b69e604ba1a4cde88bb8b46bf073c26765dcb3f819dc55f2fcc118008fde3bfac3e0c343e85a338fcbdeda2f1f57246c2db065565921f40e209dcaf3e
7
- data.tar.gz: 81eef18800723d403d6ecf016b87486253d06b4b1f15725189752afea71a6dce4dd7b79d62a945a5382f3486be3709089b9d04c6608c9df2632059d36e31b958
6
+ metadata.gz: cf9f60b7ecc1a71bc307147afdd178ac8761a4a4938c6382d51fd449297750a8d7f918a3a7eaa614631be8b989d722bbedbbdbfe89231a1803a2b868b7b3f26c
7
+ data.tar.gz: b68eac0ceac55699401b7679278f6958c0b595c4cab8999281c4bd4f0bcf10bf90dc0af31627ff7455e4dfe5eb9b7f89f21036d8abbcb0e877c058d2ba8402a8
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Core Changelog
2
2
 
3
+ ## [2.9.0] - 2025-05-28
4
+ * Add git util for getting the last tag of a given pattern which is on an ancestor commit of HEAD
5
+
6
+ ## [2.8.0] - 2025-05-22
7
+ * Add ability to disable use of the undocumented JIRA apis
8
+
3
9
  ## [2.7.0] - 2024-09-24
4
10
  * Add utility for checking for unmerged release branches before deployments
5
11
 
@@ -39,7 +39,7 @@ module Apadmi
39
39
  options = nil
40
40
  )
41
41
  custom_flag_messages ||= Apadmi::Grout::FlagMessages.default(status)
42
- options ||= Apadmi::Grout::JiraFindTicketsOptions.new(include_no_sprint_tickets: false)
42
+ options ||= Apadmi::Grout::JiraFindTicketsOptions.new(include_no_sprint_tickets: false, inspect_prs: true)
43
43
 
44
44
  issues = @jira_board_service.search_unblocked_issues(
45
45
  component, status, [], options
@@ -55,11 +55,7 @@ module Apadmi
55
55
  @git_utils.merge_changelog(issue_keys)
56
56
  )
57
57
 
58
- final_list = issues.filter do |issue|
59
- # Decide whether to include this ticket based on PRs
60
- status = process_prs(issue, custom_flag_messages)
61
- decide_should_include(issue, status, changelog_ids)
62
- end
58
+ final_list = filter_on_prs(changelog_ids, custom_flag_messages, issues, options)
63
59
 
64
60
  @logger.message("Final list: #{final_list.map(&:key).join(", ")}")
65
61
  final_list
@@ -67,6 +63,18 @@ module Apadmi
67
63
 
68
64
  private
69
65
 
66
+ def filter_on_prs(changelog_ids, custom_flag_messages, issues, options)
67
+ if options.inspect_prs
68
+ issues.filter do |issue|
69
+ # Decide whether to include this ticket based on PRs
70
+ status = process_prs(issue, custom_flag_messages)
71
+ decide_should_include(issue, status, changelog_ids)
72
+ end
73
+ else
74
+ issues
75
+ end
76
+ end
77
+
70
78
  # @param issue [Apadmi::Grout::Issue]
71
79
  # @param pr_status [Int] status of whether or not we can move
72
80
  # @param changelog_ids [Array<String>] the ticket ids pulled from git
@@ -7,11 +7,12 @@ module Apadmi
7
7
 
8
8
  # Jira specific find tickets options
9
9
  class JiraFindTicketsOptions < FindTicketsOptions
10
- attr_reader :include_no_sprint_tickets
10
+ attr_reader :include_no_sprint_tickets, :inspect_prs
11
11
 
12
12
  # @param include_no_sprint_tickets [String] whether or not to include tickets with no sprint assigned
13
- def initialize(include_no_sprint_tickets: false)
13
+ def initialize(include_no_sprint_tickets: false, inspect_prs: true)
14
14
  @include_no_sprint_tickets = include_no_sprint_tickets
15
+ @inspect_prs = inspect_prs
15
16
  end
16
17
 
17
18
  def ==(other)
@@ -19,7 +20,7 @@ module Apadmi
19
20
  end
20
21
 
21
22
  def state
22
- [@include_no_sprint_tickets]
23
+ [@include_no_sprint_tickets, @inspect_prs]
23
24
  end
24
25
  end
25
26
 
@@ -68,16 +68,50 @@ module Apadmi
68
68
  @@default.commit_hash
69
69
  end
70
70
 
71
+ # Returns the hash of the last git tag which is an ancestor commit of the current HEAD and matches the given pattern
72
+ # @param pattern [String]
73
+ def self.last_ancestor_tag_hash(pattern)
74
+ @@default.last_ancestor_tag_hash(pattern)
75
+ end
76
+
77
+ def last_ancestor_tag_hash(pattern)
78
+ tag_name = last_ancestor_tag(pattern)
79
+ stdout, stderr, status = Open3.capture3("git #{@repo_path_arg} rev-list -n 1 #{tag_name}")
80
+ raise "Failed to find a tag: #{tag_name}: #{stderr}" unless status.success?
81
+
82
+ stdout.strip
83
+ end
84
+
85
+ # Returns the name of the last git tag which is an ancestor commit of the current HEAD and matches the given pattern
86
+ # @param pattern [String]
87
+ def last_ancestor_tag(pattern)
88
+ stdout, stderr, status = Open3.capture3("git #{@repo_path_arg} describe --tags --match '#{pattern}' --abbrev=0")
89
+ raise "Failed to find a tag matching pattern: #{pattern}: #{stderr}" unless status.success?
90
+
91
+ stdout.strip
92
+ end
93
+
71
94
  # Gets the number of commits accessible from HEAD treating the history as a graph.
72
95
  # See more details here: https://git-scm.com/docs/git-rev-list
73
96
  # @return [String] The number of commits
74
97
  def number_of_commits
98
+ raise "Repo is a shallow clone so this method will always return 1" if is_shallow_clone
99
+
75
100
  stdout, stderr, status = Open3.capture3("git #{@repo_path_arg} rev-list HEAD --count")
76
101
  raise "Failed to get commit number: #{stderr}" unless status.success?
77
102
 
78
103
  stdout.strip
79
104
  end
80
105
 
106
+ # Helper function to check if a repo is a shallow clone
107
+ # @return [Boolean] If the repo is a shallow clone
108
+ def is_shallow_clone
109
+ stdout, stderr, status = Open3.capture3("git #{@repo_path_arg} rev-parse --is-shallow-repository")
110
+ raise "Failed to check if repo is shallow clone: #{stderr}" unless status.success?
111
+
112
+ stdout.strip.downcase == "true"
113
+ end
114
+
81
115
  # Gets the number of commits accessible from HEAD treating the history as a graph.
82
116
  # See more details here: https://git-scm.com/docs/git-rev-list
83
117
  # @return [String] The number of commits
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Apadmi
4
4
  module Grout
5
- VERSION = "2.7.0"
5
+ VERSION = "2.9.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apadmi_grout
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.0
4
+ version: 2.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Apadmi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-09-27 00:00:00.000000000 Z
11
+ date: 2025-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday