Created
October 17, 2024 18:40
-
-
Save bashbunni/0d109124c3033fc2142409d785286a16 to your computer and use it in GitHub Desktop.
Helper script to view number of commits since last release
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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