-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathgit-update-tool.sh
More file actions
38 lines (38 loc) · 1.05 KB
/
Copy pathgit-update-tool.sh
File metadata and controls
38 lines (38 loc) · 1.05 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
#!/bin/bash
declare -a uncommitted_repos
for f in *; do
if [ -d "$f" ] ; then
cd "$f"
echo -e "\n ------------------ NEW REPOSITORY ------------------\n"
echo "Now checking $f"
if [ -d .git ] ; then
git add .
git diff-index --quiet HEAD --
if [ "$?" -ne 0 ] ; then
echo "THE REPO NEEDS TO BE COMMITTED"
uncommitted_repos=( "${uncommitted_repos[@]}" "${PWD##*/}" )
fi
git status
git push
git pull
fi
cd ..
fi
done
red=`tput setaf 1`
reset=`tput sgr0`
green=`tput setaf 2`
if [ ${#uncommitted_repos[@]} -ne 0 ]; then
var=$(IFS=' '; echo "${uncommitted_repos[*]}")
var="${red}$var${reset}"
if [ ${#uncommitted_repos[@]} -eq 1 ]; then
var="The repository $var"
var="$var has uncomitted changes."
else
var="The repositories $var"
var="$var have uncomitted changes."
fi
echo "$var"
else
echo -e "\n${green}All repositories are up to date!${reset}"
fi