-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a6f5009
commit 454b2f3
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
function git_check() { | ||
if [[ "$1" == "--help" ]]; then | ||
echo "Usage: ${FUNCNAME[0]}" | ||
echo | ||
echo "Recursively scans the current directory for Git repositories," | ||
echo "checks if they are clean, and lists changes in dirty repositories." | ||
return 0 | ||
fi | ||
scan_directories() { | ||
local base_dir="$1" | ||
|
||
for dir in "${base_dir}"/*; do | ||
if [[ -d "${dir}" ]]; then | ||
if [[ -d "${dir}/.git" ]]; then | ||
cd "${dir}" || continue | ||
# Check if the repository is clean | ||
if ! git diff --quiet || ! git diff --cached --quiet; then | ||
echo "Dirty Git repository found: ${dir}" | ||
echo "Changes:" | ||
git status --short | ||
echo "---------------------------------" | ||
fi | ||
cd - > /dev/null || continue | ||
fi | ||
scan_directories "${dir}" | ||
fi | ||
done | ||
} | ||
scan_directories "$(pwd)" | ||
} | ||
|