Skip to content

Instantly share code, notes, and snippets.

@bashbunni
Created October 17, 2024 18:40
Show Gist options
  • Save bashbunni/0d109124c3033fc2142409d785286a16 to your computer and use it in GitHub Desktop.
Save bashbunni/0d109124c3033fc2142409d785286a16 to your computer and use it in GitHub Desktop.
Helper script to view number of commits since last release
#!/usr/bin/env sh
# This is a helper script to decide when you might need a new release.
# Prints the number of commits between origin/main or origin/master and the latest release for the selected repos.
# provide a directory path that includes your repos
if [ -z $1 ]; then
echo "Please provide a path to a directory housing your repos"
exit 1
fi
# check gum is installed
if ! command -v gum 2>&1 >/dev/null; then
echo "gum not found. install @ https://github.com/charmbracelet/gum/"
exit 1
fi
START=$pwd
DIRS=$(find "$1" -maxdepth 1 -type d | gum choose --no-limit)
for d in $DIRS; do
echo $d
cd $d
branch=$(git branch -l main master --format '%(refname:short)')
git fetch --tags --quiet
if [ $(git rev-parse --is-inside-work-tree) ]; then
git rev-list origin/$branch ^$(git describe --tags --abbrev=0) --count
fi
cd $START
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment