Skip to content

Instantly share code, notes, and snippets.

@r17x
Created January 21, 2024 15:42
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 r17x/1ef29f592e11855f925fe1d225846abf to your computer and use it in GitHub Desktop.
Save r17x/1ef29f592e11855f925fe1d225846abf to your computer and use it in GitHub Desktop.
Tag Clean 30 day ago
#!/usr/bin/env sh
git for-each-ref --sort=taggerdate --format '%(refname:short) %(taggerdate:format:%s)' "refs/tags/*" | while read tag tagdate; do
threshold_date=$(date -d '60 days ago' --utc '+%s')
if [ -n "$tagdate" ]; then
if [ "$tagdate" -lt "$threshold_date" ]; then
echo "==> $tag is older than 60 days"
echo "==> $tag will be deleted"
git tag --delete $tag
git push origin --delete $tag
echo -e "\n\n"
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment