forked from lemeurherve/jira-issues-importer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpost_process_issues.sh
More file actions
executable file
·45 lines (32 loc) · 1.36 KB
/
post_process_issues.sh
File metadata and controls
executable file
·45 lines (32 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env bash
set -e -o pipefail
# Run this over issues to:
# - add epic children to epics
OWNER=${1:-timja-org}
REPO=${2:-jenkins-gh-issues-poc-11-04}
echo "Fetching all issues from ${OWNER}/${REPO}"
ALL_ISSUES=$(gh issue list -R ${OWNER}/${REPO} --limit 20000 --state=all --json number,labels)
echo "Fetched all issues"
# Function to process issues with a specific label and type
process_issue_type() {
local label=$1
local type=$2
echo "Processing issues with label '$label' as type '$type'"
ALL_ISSUES_OF_TYPE=$(echo "${ALL_ISSUES}" | jq --arg LABEL "$label" '[.[] | select(.labels[].name == $LABEL)]')
ALL_ISSUE_NUMBERS=$(echo "${ALL_ISSUES_OF_TYPE}"| jq '.[].number' | sort -g | uniq)
if [ -z "${ALL_ISSUE_NUMBERS}" ]; then
echo "No issues found with label '$label'"
return
fi
COUNT=$(echo "${ALL_ISSUE_NUMBERS}" | wc -l | tr -d ' ')
echo "Found $COUNT issues with label '$label'"
while IFS= read -r ISSUE_CHECKING; do
echo "Checking $ISSUE_CHECKING"
gh api -X PATCH repos/$OWNER/$REPO/issues/$ISSUE_CHECKING --field type="$type" > /dev/null
gh issue edit --remove-label "$label" -R ${OWNER}/${REPO} "${ISSUE_CHECKING}"
done <<< "${ALL_ISSUE_NUMBERS}"
}
process_issue_type "rfe" "Enhancement"
process_issue_type "bug" "Bug"
# handles an edge case where there are some epics with no issues
process_issue_type "epic" "Epic"