Skip to content

Instantly share code, notes, and snippets.

@danthewildcat
danthewildcat / slugify
Last active February 28, 2020 21:36
Slugify - command line slugify helper
slugify() {
echo "${1}" | iconv -t ascii//TRANSLIT | gsed -r 's/[^a-zA-Z0-9]+/-/g' | gsed -r 's/^-+|-+$//g' | tr '[:upper:]' '[:lower:]'
}
@danthewildcat
danthewildcat / bulk-delete-tags
Last active August 7, 2019 18:30
Takes a file that lists the tags to delete and deletes them, updates the file on each successful tag deletion
#!/bin/bash
set -Eeu -o pipefail
# Pass in the path to a file that lists the tags to be
# deleted either on separate lines or separated by spaces
# Intended to be used with a file generated by:
# https://gist.github.com/danthewildcat/4494ae16d291d707f31292bfb3cecca7
bulk-delete-tags () {
local tag_file tag_array
@danthewildcat
danthewildcat / get-stale-tags
Last active August 7, 2019 18:26
Get the list of git tags for a repo and make a list of all the tags that represent branches that no longer exist
#!/bin/bash
set -Eeu -o pipefail
# Requires slugify: https://gist.github.com/danthewildcat/f5774242f01c4fa003fc679757faad6a
get-active-branches () {
local branch_list
# Get the list of all git branches for this repo
read -r -a branch_list <<< "$(git branch -l --format='%(refname)' | cut -c 12- | tr '\n' ' ')"
# Return the slugified version of these (undoes the bb-tag command)
@danthewildcat
danthewildcat / bb-tag-branch.sh
Last active February 28, 2020 21:36
Tag a git commit with the current branch and shortened commit hash
# Requires slugify: https://gist.github.com/danthewildcat/f5774242f01c4fa003fc679757faad6a
bb-tag () {
local branch="$(slugify "$(git rev-parse --abbrev-ref HEAD)")"
local commit="$(git rev-parse --short HEAD)"
local tag="${1}-${branch}-${commit}"
git tag $tag
echo $tag
}

Keybase proof

I hereby claim:

  • I am danthewildcat on github.
  • I am danthewildcat (https://keybase.io/danthewildcat) on keybase.
  • I have a public key whose fingerprint is 675B 918F 6B20 2F76 693D DEBC F978 FD5D 133E 2461

To claim this, I am signing this object: