Skip to content

Commit 99b7851

Browse files
committed
fix: imporper pattern matching
1 parent a78d8f3 commit 99b7851

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

.github/workflows/validateIssue.sh

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,10 @@ patterns=(
4242
# Returns a list of "issue_num,repo" pairs, one per line, to standard output.
4343
# All diagnostic messages are redirected to stderr to prevent interference with readarray.
4444
extract_all_issues() {
45-
local -a found_issues=()
46-
local default_repo="devtron-labs/devtron" # Default repository if not explicitly mentioned in the link
45+
# Removed 'local' keyword for array declaration
46+
found_issues=()
47+
# Removed 'local' keyword for variable declaration
48+
default_repo="devtron-labs/devtron" # Default repository if not explicitly mentioned in the link
4749

4850
# Loop through each defined pattern
4951
for pattern in "${patterns[@]}"; do
@@ -52,13 +54,16 @@ extract_all_issues() {
5254

5355
# If matches are found for the current pattern
5456
if [[ -n "$matches" ]]; then
55-
echo "Matched for pattern: $pattern" >&2 # Redirect diagnostic output to stderr
57+
# IMPORTANT: Redirect all diagnostic echo statements to stderr (>&2)
58+
echo "Matched for pattern: $pattern" >&2
5659
# Read each match into the 'match' variable
5760
while IFS= read -r match; do
5861
# Extract the issue number (sequence of digits) from the matched string
59-
local current_issue_num=$(echo "$match" | grep -oE "[0-9]+")
62+
# Removed 'local' keyword for variable declaration
63+
current_issue_num=$(echo "$match" | grep -oE "[0-9]+")
6064
# Extract the repository name (e.g., devtron-labs/devtron) from the matched string
61-
local current_repo=$(echo "$match" | grep -oE "devtron-labs/[a-zA-Z0-9_-]+")
65+
# Removed 'local' keyword for variable declaration
66+
current_repo=$(echo "$match" | grep -oE "devtron-labs/[a-zA-Z0-9_-]+")
6267

6368
# If no specific repository is found in the link, use the default
6469
if [[ -z "$current_repo" ]]; then
@@ -68,7 +73,8 @@ extract_all_issues() {
6873
# If a valid issue number was extracted, add it to the list
6974
if [[ -n "$current_issue_num" ]]; then
7075
found_issues+=("$current_issue_num,$current_repo")
71-
echo "Extracted issue: $current_issue_num from repo: $current_repo" >&2 # Redirect diagnostic output to stderr
76+
# IMPORTANT: Redirect all diagnostic echo statements to stderr (>&2)
77+
echo "Extracted issue: $current_issue_num from repo: $current_repo" >&2
7278
fi
7379
done <<< "$matches" # Use a here-string to feed matches into the while loop
7480
fi
@@ -98,7 +104,7 @@ failed_issue_links=""
98104
# Loop through each unique issue-repo pair found
99105
for issue_repo_pair in "${all_issues[@]}"; do
100106
# Split the pair into issue_num and repo using comma as delimiter
101-
# Removed 'local' keyword as these variables are not within a function scope
107+
# Variables are now global, no 'local' needed here
102108
IFS=',' read -r issue_num repo <<< "$issue_repo_pair"
103109

104110
echo "Validating issue number: #$issue_num in repo: $repo"
@@ -107,7 +113,7 @@ for issue_repo_pair in "${all_issues[@]}"; do
107113
issue_api_url="https://api.github.com/repos/$repo/issues/$issue_num"
108114
echo "API URL: $issue_api_url"
109115

110-
# Removed 'local' keyword for these variable declarations
116+
# Variables are now global, no 'local' needed here
111117
response=""
112118
response_code=""
113119
response_body=""
@@ -130,7 +136,7 @@ for issue_repo_pair in "${all_issues[@]}"; do
130136

131137
echo "Response Code: $response_code"
132138
# Extract the 'html_url' from the JSON response body using jq
133-
# Removed 'local' keyword for this variable declaration
139+
# Variable is now global, no 'local' needed here
134140
html_url=$(echo "$response_body" | jq -r '.html_url')
135141

136142
# Check if the extracted URL points to a pull request instead of an issue
@@ -176,4 +182,4 @@ else
176182
echo "Some linked issues are invalid for forked PR:\n$failed_issue_links"
177183
exit 1
178184
fi
179-
fi
185+
fi

0 commit comments

Comments
 (0)