Skip to content

Commit

Permalink
⚡ Attempt to fix support for bash 3
Browse files Browse the repository at this point in the history
This attempts to fix support for bash 3 to help out with #6.
  • Loading branch information
paulbarton90 committed Apr 10, 2024
1 parent 529576e commit 7c46d5a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ The correct scopes can be verified via `gh auth status`. The last line it prints
informs you of the "Token scopes".

Other requirements:

* `awk`
* `gh>=2.40`
* `jq`
* `sort`
* `tr`

## Usage

Expand Down
17 changes: 9 additions & 8 deletions gh-clean-notifications
Original file line number Diff line number Diff line change
Expand Up @@ -147,21 +147,22 @@ process_notifications() {
-q ".data.viewer.notificationThreads.nodes[] | select(.subject.state == (${STATES})) | {\"id\":.id,\"title\":.title,\"path\":.subject.resourcePath}"
)

readarray -t my_array < <(echo "${data}" | jq -s -c '.[]')

# If there are IDs, mark them as done.
if [ ${#my_array[@]} -gt 0 ]; then
if [ ${#data} -gt 0 ]; then
IDS=()
for item in "${my_array[@]}"; do
while read -r item; do
echo "Marking as Done: $(echo "${item}" | jq -r .title)"
echo " https://github.com$(echo "${item}" | jq -r .path)"
IDS+=(-f "ids[]=$(echo "${item}" | jq -r .id)")
if test ${#IDS[@]} -eq 100
then
gh api graphql --silent "${IDS[@]}" -f query="${MARK_IDS_AS_DONE_QUERY}"
IDS=()
IDS=()
fi
done

# Since this indented with spaces, EOT is fully left aligned.
done <<EOT
$(echo "$data" | jq -s -c .[])
EOT

test ${#IDS[@]} -eq 0 ||
gh api graphql --silent "${IDS[@]}" -f query="${MARK_IDS_AS_DONE_QUERY}"
Expand Down Expand Up @@ -195,7 +196,7 @@ do
VERBOSE=1;;

s) # Process states into a string for jq
value=${OPTARG^^}
value=$(echo "${OPTARG}" | tr '[:lower:]' '[:upper:]')
oldIFS=$IFS
IFS=','
STATES=""
Expand Down

0 comments on commit 7c46d5a

Please sign in to comment.