-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathpull_all_vcs
More file actions
executable file
·66 lines (58 loc) · 2.05 KB
/
Copy pathpull_all_vcs
File metadata and controls
executable file
·66 lines (58 loc) · 2.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
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
#!/bin/bash -
#===============================================================================
#
# FILE: pull_all_vcs
#
# USAGE: ./pull_all_vcs
#
# DESCRIPTION:
#
# OPTIONS: ---
# REQUIREMENTS: ---
# BUGS: ---
# NOTES: ---
# AUTHOR: andreas.boettger@gmx.de
# ORGANIZATION:
# CREATED: Do 24 Apr 2014 12:38:05 CEST
# REVISION: ---
#===============================================================================
# set -o nounset # Treat unset variables as an error
if [ "$(command -v jshon)" == "" ]
then
echo "jshon not installed. Aborting."
exit 1
fi
rootDir="$HOME"
if [ "$1" != "" ]
then
rootDir=$(realpath "$1")
fi
red='\e[0;31m'
green='\e[0;32m'
yellow='\e[0;33m'
NC='\e[0m' # No Color
# JSON
# replace \" with " and paste it here: http://www.jsoneditoronline.org/
rc="{\"GIT\":{\"name\":\"GIT\",\"command\":\"git\",\"pullSubCommand\":\"pull\",\"dotFolder\":\".git\"},\"SVN\":{\"name\":\"SVN\",\"command\":\"svn\",\"pullSubCommand\":\"update\",\"dotFolder\":\".svn\"},\"HG\":{\"name\":\"Mercurial\",\"command\":\"hg\",\"pullSubCommand\":\"pull\",\"dotFolder\":\".hg\"},\"BZR\":{\"name\":\"Bazaar\",\"command\":\"bzr\",\"pullSubCommand\":\"pull\",\"dotFolder\":\".bzr\"}}"
for vcr in $(echo "$rc" | jshon -k)
do
command=$(echo "$rc" | jshon -e "$vcr" -e "command" | tr -d "\"")
name=$(echo "$rc" | jshon -e "$vcr" -e "name" | tr -d "\"")
dotFolder=$(echo "$rc" | jshon -e "$vcr" -e "dotFolder" | tr -d "\"")
pullSubCommand=$(echo "$rc" | jshon -e "$vcr" -e "pullSubCommand" | tr -d "\"")
if [ "$(command -v "$command")" == "" ]
then
echo -e "${red}$command not installed${NC}"
else
echo -e "${green}***** Checking $name repositories in ${yellow}$rootDir${NC}"
echo
find "$rootDir" -type d -name "$dotFolder" | sort | while read line; do
workingDir=$(dirname "$line")
echo -e "${green}$name: ${NC}${yellow}$workingDir${NC}"
cd "$workingDir"
echo -e "${green}$("$command" "$pullSubCommand")${NC}"
echo
done
fi
done
exit 0