forked from ist199211-ist199311/warehouse-manager-po
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_cvs.sh
executable file
·46 lines (36 loc) · 1.1 KB
/
update_cvs.sh
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
#!/bin/zsh
# THIS SCRIPT ONLY WORKS WITH ZSH
export CVS_RSH=ssh
CVS_FOLDER=../project
removed_files() {
# does not detect CVS files (CVS and .settings folders)
# excludes some files from the initial code (.project, .settings, .cproject)
diff -r . $CVS_FOLDER | grep "Only in $SRC_CVS" \
| sed "s/Only in $SRC_CVS\(.*\): /$SRC_CVS\1\//" \
| grep -E '\.java$' \
}
# wrapper to update cvs quietly from the (git) repo root
cvs_update() {
# run in subshell to keep cwd intact
(cd $CVS_FOLDER && cvs -q update)
}
cp --parents **/*.java $CVS_FOLDER/
echo Changes to commit:
cvs_update
echo
# detect files that are not in git but are in CVS
if removed_files &>/dev/null; then
echo "The following files have been deleted from Git but are still in CVS:"
echo
removed_files | xargs -n1 echo rm
echo
fi
# detect files not added to CVS
if cvs_update |& grep -w '?' &>/dev/null; then
echo "You have new files to add to CVS first:"
echo
cvs_update |& grep -w '?' | cut -d' ' -f2 | xargs -n1 echo cvs add
echo
fi
echo Then, commit with
echo 'cvs commit -m "'"$(git log -1 --pretty="%B - From Git by %an at %ai")"'"'