apadmi_grout 1.1.0 → 1.2.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 +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/apadmi/grout/di.rb +3 -2
- data/lib/apadmi/grout/jira/actions/find_tickets_to_move_action.rb +47 -12
- data/lib/apadmi/grout/jira/models/flag_messages.rb +2 -1
- data/lib/apadmi/grout/release_notes/actions/issues_from_changelog_action.rb +0 -2
- data/lib/apadmi/grout/utils/git_utils.rb +10 -0
- data/lib/apadmi/grout/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a8f0b024bb98a0372b85755e14bc753370328418273d6e0d07aba74f664bb9a
|
4
|
+
data.tar.gz: '04286d3e985378d78f1dec57c220f1a4a5ec35d90ccf4a407d3dde66f75f9a6d'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c9d6d5fce5da1ffaa1ab71a7f54e4bba85a3f4fda470b0613049a2169ca9466d180b655c3129561e9046fe3d0a4041b85c2cf25d70dfd8ac7f521b70a6d5113
|
7
|
+
data.tar.gz: 13b59090e27577e87f7a52ef9dbcc085db1af1b0575a20e98642669155b0652e0e91976a4943f027e33c25d325fe0aa205afa481d761b7a944f5aebf3bf4138a
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# Core Changelog
|
2
2
|
|
3
|
+
## [1.2.0] - 2022-05-17
|
4
|
+
* Filter out issues missing from git changelogs when finding tickets to move.
|
5
|
+
|
3
6
|
## [1.1.0] - 2022-05-12
|
4
7
|
* Support allowing tickets that aren't assigned to a sprint to be moved.
|
5
8
|
* Created utilities for getting the git root and number of commits
|
data/lib/apadmi/grout/di.rb
CHANGED
@@ -15,10 +15,11 @@ module Apadmi
|
|
15
15
|
def initialize(username, token, base_url, context_path, project, logger)
|
16
16
|
@jira_wrapper = Apadmi::Grout::JiraWrapper.new(username, token, base_url, context_path, project)
|
17
17
|
|
18
|
+
git_utils = Apadmi::Grout::GitUtils
|
18
19
|
@move_jira_tickets_action = Apadmi::Grout::MoveJiraTicketsAction.new(@jira_wrapper, logger)
|
19
|
-
@find_tickets_to_move_action = Apadmi::Grout::FindTicketsToMoveAction.new(@jira_wrapper, logger)
|
20
|
-
@generate_release_notes_action = Apadmi::Grout::GenerateReleaseNotesAction.new(base_url)
|
21
20
|
@issues_from_changelog_action = Apadmi::Grout::IssuesFromChangelogAction.new(@jira_wrapper, logger)
|
21
|
+
@find_tickets_to_move_action = Apadmi::Grout::FindTicketsToMoveAction.new(@jira_wrapper, git_utils, issues_from_changelog_action, logger)
|
22
|
+
@generate_release_notes_action = Apadmi::Grout::GenerateReleaseNotesAction.new(base_url)
|
22
23
|
end
|
23
24
|
end
|
24
25
|
end
|
@@ -2,14 +2,26 @@
|
|
2
2
|
|
3
3
|
module Apadmi
|
4
4
|
module Grout
|
5
|
+
module PrStatus
|
6
|
+
MERGED = 1
|
7
|
+
UNMERGED_BUT_INCLUDED = 2
|
8
|
+
UN_INCLUDED = 3
|
9
|
+
end
|
10
|
+
|
11
|
+
# ATTENTION: Any changes to the logic here should be reflected in the docs (find-tickets.md)
|
12
|
+
|
5
13
|
# Finds and returns a list of all the issues that are ready to be moved
|
6
14
|
# Any tickets found that have the given status but *don't* appear ready to be moved will
|
7
15
|
# be flagged.
|
8
16
|
class FindTicketsToMoveAction
|
9
17
|
# @param [Apadmi::Grout::JiraWrapper]
|
18
|
+
# @param [Apadmi::Grout::GitUtils]
|
19
|
+
# @param [Apadmi::Grout::IssuesFromChangelogAction]
|
10
20
|
# @param [Apadmi::Grout::DefaultLogger] // or your own logger!
|
11
|
-
def initialize(jira_wrapper, logger)
|
21
|
+
def initialize(jira_wrapper, git_utils, issues_from_chnglg, logger)
|
12
22
|
@jira_wrapper = jira_wrapper
|
23
|
+
@git_utils = git_utils
|
24
|
+
@issues_from_changelog_action = issues_from_chnglg
|
13
25
|
@logger = logger
|
14
26
|
end
|
15
27
|
|
@@ -30,50 +42,73 @@ module Apadmi
|
|
30
42
|
options ||= Apadmi::Grout::FindTicketsOptions.new(include_no_sprint_tickets: false)
|
31
43
|
|
32
44
|
issues = @jira_wrapper.search_unblocked_issues(
|
33
|
-
component,
|
34
|
-
status,
|
35
|
-
[],
|
45
|
+
component, status, [],
|
36
46
|
allow_no_sprint: options.include_no_sprint_tickets
|
37
47
|
).reject do |issue|
|
38
48
|
excluded_ticket_keys.include? issue.key
|
39
49
|
end
|
40
50
|
|
41
|
-
|
51
|
+
issue_keys = issues.map(&:key)
|
52
|
+
@logger.message("Found issues to consider #{issue_keys.join(", ")}")
|
53
|
+
|
54
|
+
# Get the issues in the git changelog, filtered for the issues being considered
|
55
|
+
changelog_ids = @issues_from_changelog_action.issue_ids_from_changelog(
|
56
|
+
@git_utils.merge_changelog(issue_keys)
|
57
|
+
)
|
58
|
+
|
42
59
|
final_list = issues.filter do |issue|
|
43
60
|
# Decide whether to include this ticket based on PRs
|
44
|
-
process_prs(issue, custom_flag_messages)
|
61
|
+
status = process_prs(issue, custom_flag_messages)
|
62
|
+
decide_should_include(issue, status, changelog_ids)
|
45
63
|
end
|
64
|
+
|
46
65
|
@logger.message("Final list: #{final_list.map(&:key).join(", ")}")
|
47
66
|
final_list
|
48
67
|
end
|
49
68
|
|
50
69
|
private
|
51
70
|
|
71
|
+
# @param issue [JIRA::Resource::Issue]
|
72
|
+
# @param pr_status [Int] status of whether or not we can move
|
73
|
+
# @param changelog_ids [Array<String>] the ticket ids pulled from git
|
74
|
+
def decide_should_include(issue, pr_status, changelog_ids)
|
75
|
+
# For merged PRs, check if the ticket appears in the changelog.
|
76
|
+
# If it doesn't then it's likely it was merged AFTER this release build was triggered and shouldn't be moved
|
77
|
+
# by this build
|
78
|
+
if pr_status == PrStatus::MERGED
|
79
|
+
is_in_changelog = changelog_ids.include?(issue.key)
|
80
|
+
@logger.message("NOTE: Not including #{issue.key} since it's not in the git changelog.") unless is_in_changelog
|
81
|
+
return is_in_changelog
|
82
|
+
end
|
83
|
+
|
84
|
+
pr_status != PrStatus::UN_INCLUDED
|
85
|
+
end
|
86
|
+
|
52
87
|
# @param issue [JIRA::Resource::Issue]
|
53
88
|
# @param custom_flag_messages [FlagMessages]
|
54
|
-
# @return [
|
89
|
+
# @return [Int] status of whether or not we can move
|
55
90
|
def process_prs(issue, custom_flag_messages)
|
56
91
|
prs = @jira_wrapper.get_ticket_prs(issue)
|
57
92
|
|
58
93
|
if prs.empty?
|
59
94
|
@logger.message("#{issue.key} has no PRs. Flagging it: STILL MOVABLE")
|
60
95
|
@jira_wrapper.flag_ticket(issue.key, custom_flag_messages.no_prs_flag_msg)
|
61
|
-
return
|
96
|
+
return PrStatus::UNMERGED_BUT_INCLUDED
|
62
97
|
elsif prs.all?(&:open)
|
63
98
|
@logger.message("#{issue.key} has only open PRs. Flagging it: NOT MOVABLE")
|
64
99
|
@jira_wrapper.flag_ticket(issue.key, custom_flag_messages.open_prs_flag_msg)
|
65
|
-
return
|
100
|
+
return PrStatus::UN_INCLUDED
|
66
101
|
elsif prs.all?(&:declined)
|
67
102
|
@logger.message("#{issue.key} has only declined PRs. Flagging it: NOT MOVABLE")
|
68
103
|
@jira_wrapper.flag_ticket(issue.key, custom_flag_messages.declined_prs_flag_msg)
|
69
|
-
return
|
104
|
+
return PrStatus::UN_INCLUDED
|
70
105
|
elsif prs.none?(&:merged)
|
71
106
|
@logger.message("#{issue.key} has no merged PRs. Flagging it: NOT MOVABLE")
|
72
107
|
@jira_wrapper.flag_ticket(issue.key, custom_flag_messages.no_merged_prs_flag_msg)
|
73
|
-
return
|
108
|
+
return PrStatus::UN_INCLUDED
|
74
109
|
end
|
75
110
|
|
76
|
-
|
111
|
+
PrStatus::MERGED # At least one merged PR
|
77
112
|
end
|
78
113
|
end
|
79
114
|
end
|
@@ -13,7 +13,8 @@ module Apadmi
|
|
13
13
|
# @return [Apadmi::Grout::FlagMessages]
|
14
14
|
def self.default(status)
|
15
15
|
FlagMessages.new(
|
16
|
-
"REASON FOR FLAG: Check this ticket - it was put in #{status} but has no PRs connected to it. CI still moved it"
|
16
|
+
"REASON FOR FLAG: Check this ticket - it was put in #{status} but has no PRs connected to it. CI still moved it. " \
|
17
|
+
"(WARNING: this may cause the `fix_versions` to be incorrect)",
|
17
18
|
"REASON FOR FLAG: Check this ticket - it was put in #{status} but has no MERGED PRs and at least one OPEN PR",
|
18
19
|
"REASON FOR FLAG: Check this ticket - it was put in #{status} but has only DECLINED PRs",
|
19
20
|
"REASON FOR FLAG: Check this ticket - it was put in #{status} but has no MERGED PRs"
|
@@ -24,6 +24,16 @@ module Apadmi
|
|
24
24
|
|
25
25
|
stdout.strip
|
26
26
|
end
|
27
|
+
|
28
|
+
# Gets all the merges accessible from the current HEAD which matches at least one of the given grep conditions
|
29
|
+
# @param grep_conditions [Array<String>] values to be passed in as grep cases (https://git-scm.com/docs/git-log)
|
30
|
+
def self.merge_changelog(grep_conditions)
|
31
|
+
command = "git log HEAD --merges --format=%s#{grep_conditions.map { |c| " --grep #{c}" }.join(" ")}"
|
32
|
+
stdout, stderr, = Open3.capture3(command)
|
33
|
+
raise "Failed to get changelog: #{stderr}" unless stderr.strip.empty?
|
34
|
+
|
35
|
+
stdout
|
36
|
+
end
|
27
37
|
end
|
28
38
|
end
|
29
39
|
end
|
data/lib/apadmi/grout/version.rb
CHANGED
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: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Apadmi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-05-
|
11
|
+
date: 2022-05-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|