Skip to content

Instantly share code, notes, and snippets.

@augustohp
Created October 9, 2018 20:29
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 augustohp/ee6eeb3079196a3a27eed047f67bf607 to your computer and use it in GitHub Desktop.
Save augustohp/ee6eeb3079196a3a27eed047f67bf607 to your computer and use it in GitHub Desktop.
Report Git repositories that do not have commits for a given time
#!/usr/bin/env bash
# vim: ft=sh:
APP_NAME=$(basename $0)
APP_VERSION="1.0.0"
OPTION_ACTIVE_IS="6 month ago"
command_help()
{
cat <<-EOT
Will print the name of repositories which do not have commits for a given
amount of time.
Usage: $APP_NAME
$APP_NAME [-v | --version]
$APP_NAME [-h | --help]
$APP_NAME [-a <d> | --active <d]
Options
-a <d> Considers repository to be inactive if there are no commits
since that period (Default: $OPTION_ACTIVE_IS).
Send bugs or suggestions to augusto.hp@gmail.com
EOT
}
test ! -z "$DEBUG" && { set -x; }
while :;
do
if [ $# = 0 ]
then
break
fi
case $1 in
-h|--help)
command_help
exit 0
;;
-a|--active)
OPTION_ACTIVE_IS="$2"
;;
-v|--version)
echo "$APP_NAME $APP_VERSION"
exit 0
;;
--)
break
;;
esac
shift
done
for git_path in $(find . -name ".git" -type d)
do
repository="${git_path%%/.git}"
pushd "$repository" > /dev/null
commits=$(git log --since "$OPTION_ACTIVE_IS" --oneline | wc -l)
if [ $commits -eq 0 ]
then
echo $repository
fi
popd > /dev/null
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment