-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathis-everything-pushed.sh
More file actions
executable file
·74 lines (60 loc) · 1.45 KB
/
is-everything-pushed.sh
File metadata and controls
executable file
·74 lines (60 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env bash
# This scripts assumes you have all your Git repositories in the same
# parent-folder.
#
# .
# ├── repo-1
# ├── repo-2
# ├── repo-3
# ├── ...
# └── repo-N
#
### Usage
#
# First argument should be absolute path to the parent-folder
# Example:
#
# /bin/bash is-everything-pushed.sh /Users/simon/repos
#
readonly folder=$1
if [ -z "$folder" ]; then
echo "No folder provided, run it like this:";
echo " /bin/bash is-everything-pushed.sh [FOLDER]";
exit
fi
if [ ! -d "$folder" ]; then
printf "Cannot find [%s]\\n" "$folder"
exit
fi
function is_git_repo {
if [ -d .git ]; then
return 0;
elif git rev-parse --git-dir 2> /dev/null; then
return 0;
fi;
return 1;
}
readonly repos_str="$(ls -d "$folder"/*/)"
readonly repo_paths="$(echo "$repos_str" | tr ";" "\\n")"
unpushed_changes=false
for folder_path in $repo_paths
do
# Make sure folder exist
if [ ! -d "$folder_path" ]; then
printf "Can't pushd to [%s]\\n" "$folder_path";
exit;
fi
# Don't output pushd results
# If pushd fails, exit
pushd "$folder_path" > /dev/null ||
(printf "Can't pushd to [%s]\\n" "$folder_path" && exit);
if is_git_repo > /dev/null; then
if (git status | grep -c "Your branch is ahead") > /dev/null; then
unpushed_changes=true
printf "🙈 Unpushed changes in\\t%s\\n" "$folder_path";
fi
fi
done
if ! $unpushed_changes; then
echo "No unpushed changes! All is good 👌";
fi