Skip to content

Commit 968eb3b

Browse files
committed
Show name of folder fixed in some situations; Analyzing only root git repositories
1 parent 8860e26 commit 968eb3b

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

git/analyze_changes_in_folders.sh

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,31 @@ else
1717
fi
1818

1919
# iterate folders
20-
ls -d * | while read -r folder;
20+
ls -d */ | while read -r folder;
2121
do
22+
GIT_TOPLEVEL_FOLDER=$(git -C $folder rev-parse --show-toplevel)'/'
23+
CURRENT_FOLDER=$(pwd)'/'$folder
24+
25+
if [[ "${GIT_TOPLEVEL_FOLDER}" != "${CURRENT_FOLDER}" ]];
26+
then
27+
echo -e "$COLOR_RED"
28+
echo "Folder ${folder} is not git repository!"
29+
30+
continue
31+
fi
32+
2233
GIT_STATUS=$(git -C $folder status -su)
2334

24-
if [[ "$1" = "--empty" ]] && [[ -z "$GIT_STATUS" ]];
35+
if [[ "$1" = "--empty" ]] || [[ ! -z "$GIT_STATUS" ]];
2536
then
2637
echo -e "$COLOR_BLUE"
2738
echo 'Showing git status of folder:' $folder
2839
fi
2940

3041
if [[ ! -z "$GIT_STATUS" ]];
3142
then
32-
if [[ ! "$1" = "--empty" ]];
33-
then
34-
echo -e "$COLOR_BLUE"
35-
echo 'Showing git status of folder:' $folder
36-
fi
37-
3843
echo -e "$COLOR_WHITE"
3944
echo "$GIT_STATUS"
4045
fi
4146

42-
done;
43-
47+
done

0 commit comments

Comments
 (0)