#!/usr/bin/env bash # Close a Gitea issue by setting its state to "closed". # # Usage: ./close_issue.sh # # Auth: macOS keychain via `git credential fill` (same as the other scripts). set -euo pipefail HOST="gitea.dadeschools.net" API="https://$HOST/api/v1" ORG="Contractor" REPO="Timesheet" ISSUE_NUM="${1:?usage: close_issue.sh }" CREDS=$(printf "host=%s\nprotocol=https\n\n" "$HOST" | git credential fill) USER=$(printf '%s\n' "$CREDS" | sed -n 's/^username=//p') PASS=$(printf '%s\n' "$CREDS" | sed -n 's/^password=//p') curl -sSL -X PATCH \ -u "$USER:$PASS" \ -H "Content-Type: application/json" \ -d '{"state": "closed"}' \ "$API/repos/$ORG/$REPO/issues/$ISSUE_NUM" echo "" echo "#$ISSUE_NUM closed"