1
0
Fork 0

Only run config heavy if our repo has commits

This commit is contained in:
krcroft 2020-01-11 14:48:56 -08:00 committed by Patryk Obara
parent d859decccb
commit d56afec70b
3 changed files with 90 additions and 12 deletions

32
scripts/has-commits-since.sh Executable file
View file

@ -0,0 +1,32 @@
#!/bin/bash
# Copyright (C) 2020 Kevin Croft <krcroft@gmail.com>
# SPDX-License-Identifier: GPL-2.0-or-later
# This script indicates if the git repository has had
# any commits since a given timeframe.
# Usage: ./has-commits-since.sh TIMEFRAME
# Where TIMEFRAME is provided in git's --since notation
# Example: ./has-commits-since.sh "24 hours ago"
# The script prints either "true" or "false" indicating
# if commits were (or weren't) found for the timeframe.
# The exit code is zero unless the script itself fails.
set -euo pipefail
if [[ "$#" != 1 ]]; then
echo "Usage: $0 TIMEFRAME"
echo "Example: $0 \"24 hours ago\""
exit 1
fi
timeframe="${1}"
commits="$(git --no-pager log --pretty=oneline --since="${timeframe}" | wc -l)"
if [[ "${commits}" -gt "0" ]]; then
echo "true"
else
echo "false"
fi