Skip to content

Instantly share code, notes, and snippets.

@dsdanielpark
Last active April 11, 2023 13:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dsdanielpark/c6997c592d5bb8334ac09c603820955b to your computer and use it in GitHub Desktop.
Save dsdanielpark/c6997c592d5bb8334ac09c603820955b to your computer and use it in GitHub Desktop.
make star clear

How to unstar all repository.

Reference: https://gist.github.com/justlaputa/a6da84981eca963817e652b5f2452cfc

  1. Generate authorization token for unstar. https://github.com/settings/tokens

  2. Export variable

export APIKEY=xxxxxxxxx
  1. Gain access to the starred repositories page.
curl -I -H "Authorization: token $APIKEY" https://api.github.com/user/starred
  1. Retrieve the list of starred repositories and save it to a file called stars.txt.
for p in `seq 1 4`;do
echo page 
curl -s -H "Authorization: token $APIKEY" https://api.github.com/user/starred\?page\=$p | jq -r '.[] |.full_name' >>stars.txt
done
  1. Unstar any repositories that are listed in the stars.txt file.
while read REPO;do
echo 
curl -X DELETE -s -H "Authorization: token $APIKEY" https://api.github.com/user/starred/$REPO
sleep .5
done<stars.txt
@dsdanielpark
Copy link
Author

dsdanielpark commented Apr 11, 2023

#!/usr/bin/env bash

set -o errexit
set -o pipefail
set -o nounset

STARS_PAGE_COUNT=20
STARS_FILE=stars.txt
DELETE_SLEEP_TIME=.5

function get_all_star_repos() {
  for p in $(seq 1 $STARS_PAGE_COUNT);do
    echo "page: $p"
    curl -s -H "Authorization: token $APIKEY" https://api.github.com/user/starred\?page\=$p | jq -r '.[] |.full_name' >> $STARS_FILE
  done
}

function remove_all_star_repos() {
  while read REPO;do
    echo "REPO: $REPO"
    curl -X DELETE -s -H "Authorization: token $APIKEY" https://api.github.com/user/starred/$REPO
    sleep $DELETE_SLEEP_TIME
  done < $STARS_FILE
}

get_all_star_repos
remove_all_star_repos

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment