elif[[$ISSUE_REFERENCE=~ ^([^/]+)/([^#]+)#([0-9]+)$ ]]; then
REPO_FULL="${BASH_REMATCH[1]}/${BASH_REMATCH[2]}"
ISSUE_NUM="${BASH_REMATCH[3]}"
# Check for repo_name#number format
elif[[$ISSUE_REFERENCE=~ ^([^#]+)#([0-9]+)$ ]]; then
REPO_FULL="$ORG/${BASH_REMATCH[1]}"
ISSUE_NUM="${BASH_REMATCH[2]}"
else
if$FAIL_INVALID_FMT||$VERBOSE;then
echo-e"${YELLOW}[Warning]:${NC} Invalid TODO format: $todo"
if$FAIL_INVALID_FMT;then
exit 1
fi
fi
((MISMATCH_COUNT++))
continue
fi
# Use GitHub API to fetch issue details
GH_URL_PATH="$REPO_FULL/issues/$ISSUE_NUM"
RESPONSE=$(curl -sL-H"$AUTH"--request GET "https://api.github.com/repos/$GH_URL_PATH")
# Check if issue was found
if echo"$RESPONSE" | rg -q"Not Found";then
if[[$VERBOSE]];then
echo-e"${YELLOW}[Warning]:${NC} Issue not found: ${RED}$REPO_FULL/$ISSUE_NUM${NC}"
fi
fi
((NOT_FOUND_COUNT++))
continue
fi
fi
((MISMATCH_COUNT++))
continue
fi
# Check issue state
# Use GitHub API to fetch issue details
STATE=$(echo"$RESPONSE" | jq -r .state)
GH_URL_PATH="$REPO_FULL/issues/$ISSUE_NUM"
RESPONSE=$(curl -sL-H"$AUTH"--request GET "https://api.github.com/repos/$GH_URL_PATH")
if[["$STATE"=="closed"]];then
# Check if issue was found
echo-e"${RED}[Error]:${NC} Issue #$ISSUE_NUM is closed. Please remove the TODO in ${GREEN}$FILE:$LINE_NUM${NC} referencing ${YELLOW}$ISSUE_REFERENCE${NC} (${CYAN}https://github.com/$GH_URL_PATH${NC})"
if echo"$RESPONSE" | rg -q"Not Found";then
exit 1
if[[$VERBOSE]];then
echo-e"${YELLOW}[Warning]:${NC} Issue not found: ${RED}$REPO_FULL/$ISSUE_NUM${NC}"
echo-e"${RED}[Error]:${NC} Issue #$ISSUE_NUM is closed. Please remove the TODO in ${GREEN}$FILE:$LINE_NUM${NC} referencing ${YELLOW}$ISSUE_REFERENCE${NC} (${CYAN}https://github.com/$GH_URL_PATH${NC})"
echo-e"${YELLOW}[Warning]:${NC}${CYAN}$NOT_FOUND_COUNT${NC} TODOs referred to issues that were not found."
exit 1
fi
if[[$MISMATCH_COUNT-gt 0 ]];then
echo-e"${YELLOW}[Warning]:${NC}${CYAN}$MISMATCH_COUNT${NC} TODOs did not match the expected pattern. Run with ${RED}\`--verbose\`${NC} to show details."
fi
fi
if[[$OPEN_COUNT-gt 0 ]];then
echo-e"${GREEN}[Info]:${NC}${CYAN}$OPEN_COUNT${NC} TODOs refer to issues that are still open."
# Save the Process ID of the job you started in the background
# Print summary
PID=$!
if[[$NOT_FOUND_COUNT-gt 0 ]];then
echo-e"${YELLOW}[Warning]:${NC}${CYAN}$NOT_FOUND_COUNT${NC} TODOs referred to issues that were not found."
fi
if[[$MISMATCH_COUNT-gt 0 ]];then
echo-e"${YELLOW}[Warning]:${NC}${CYAN}$MISMATCH_COUNT${NC} TODOs did not match the expected pattern. Run with ${RED}\`--verbose\`${NC} to show details."
fi
if[[$OPEN_COUNT-gt 0 ]];then
echo-e"${GREEN}[Info]:${NC}${CYAN}$OPEN_COUNT${NC} TODOs refer to issues that are still open."