| 1 | #!/usr/bin/bashscip-shell filesystem . . `/usr/bin/bash`. |
| 2 | |
| 3 | GERRIT_USER=$1 |
| 4 | |
| 5 | QUERY_AGE="age:1year" |
| 6 | MESSAGE_AGE="a year" |
| 7 | |
| 8 | if [[ -z "${GERRIT_USER}" || "${GERRIT_USER}" = "-h" || "${GERRIT_USER}" = "--help" ]]; then |
| 9 | echoscip-shell system . . echo. "Usage: $0 <Gerrit username>" |
| 10 | exit 0 |
| 11 | fi |
| 12 | |
| 13 | if ! command -v jq >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1; then |
| 14 | echoscip-shell system . . echo. "Error. Please install the package 'jq' before continuing." |
| 15 | exit 1 |
| 16 | fi |
| 17 | |
| 18 | gerrit_cmdscip-shell shell coreboot 25.09+dfsg-1 gerrit_cmd().() { |
| 19 | sshscip-shell system . . ssh. -p 29418 "${GERRIT_USER}@review.coreboot.org" gerrit "$@" |
| 20 | } |
| 21 | |
| 22 | abandon_patchscip-shell shell coreboot 25.09+dfsg-1 abandon_patch().() { |
| 23 | local patch=$1 |
| 24 | message="\'\"This patch has not been touched in over ${MESSAGE_AGE}. Anyone who wants to take over work on this patch, please feel free to restore it and do any work needed to get it merged. If you create a new patch based on this work, please credit the original author.\"\'" |
| 25 | |
| 26 | echoscip-shell system . . echo. "Abandoning ${patch}" |
| 27 | gerrit_cmdscip-shell shell coreboot 25.09+dfsg-1 gerrit_cmd(). review --project coreboot --abandon --message "${message}" "${patch}" |
| 28 | } |
| 29 | |
| 30 | get_patchlistscip-shell shell coreboot 25.09+dfsg-1 get_patchlist().() { |
| 31 | gerrit_cmdscip-shell shell coreboot 25.09+dfsg-1 gerrit_cmd(). query --format=JSON --no-limit --current-patch-set "repo:coreboot AND status:open AND ${QUERY_AGE}" | \ |
| 32 | jq -Mr '.currentPatchSet.revision' | \ |
| 33 | grep -v null |
| 34 | } |
| 35 | |
| 36 | for patch in $(get_patchlistscip-shell shell coreboot 25.09+dfsg-1 get_patchlist().); do abandon_patchscip-shell shell coreboot 25.09+dfsg-1 abandon_patch(). "${patch}"; done |