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
((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")
# 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}"
# 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
((NOT_FOUND_COUNT++))
continue
fi
((NOT_FOUND_COUNT++))
continue
fi
# Check issue state
STATE=$(echo"$RESPONSE" | jq -r .state)
# Check issue state
STATE=$(echo"$RESPONSE" | jq -r .state)
if[["$STATE"=="closed"]];then
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."
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."
REPO_ISSUE="https://github.com/${issue%%|*}"# up to the first |
REMAINING="${issue#*|}"# after the first |
TITLE="${REMAINING%%|*}"# up to the second |
LOC="${REMAINING#*|}"# after the second |
# Truncate if necessary
if[${#REPO_ISSUE}-gt 47 ];then
REPO_ISSUE=$(printf"%.47s...""$REPO_ISSUE")
fi
if[${#TITLE}-gt 47 ];then
TITLE=$(printf"%.52s...""$TITLE")
fi
if[${#LOC}-gt 27 ];then
LOC=$(printf"%.24s...""$LOC")
fi
if[["$STATE"=="closed"]];then
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})"
# Save the Process ID of the job you started in the background
PID=$!
# Print summary
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."