-
Notifications
You must be signed in to change notification settings - Fork 0
/
lsrepos
executable file
·52 lines (46 loc) · 1.26 KB
/
lsrepos
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
#!/bin/bash
##############################################################################
#
# NAME: lsrepos
#
# DESCRIPTION: List the subdirectories under the current directory that are
# version controlled and specify which version control system
# they use.
# If extra arguments are given, they will be trated as
# directories and will be checked for version control system
# themselves.
#
# USAGE: lsrepos [DIRECTORY [DIRECTORY ...]]
#
# DEPENDENCIES: None
#
##############################################################################
#
detect_repo()
{
for file in "$@"
do
if [[ $file != '.' ]] && [[ $file != '..' ]]
then
if [[ -d $file/.git ]]; then # Git repository
echo "GIT $file"
elif [[ -d $file/.svn ]]; then # Subversion repository
echo "SVN $file"
elif [[ -d $file/.hg ]]; then # Mercurial repository
echo "HG $file"
elif [[ -d $file ]] && [[ $showall -eq 1 ]]; then
echo "--- $file"
fi
fi
done
}
if [[ $1 == '-a' ]]
then
shift
showall=1
fi
if [[ $# < 1 ]]; then
detect_repo *
else
detect_repo "$@"
fi