mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-pkg
synced 2026-01-15 03:53:32 +01:00
purge-stale-projects.sh: Support --vcs
Support option --vcs. CVS is retired, but worked well as a test case for mixing multiple version-control systems in one tree. purge-stale-projects.sh is still pretty ugly and will have to go, but its API might still serve as a working template. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
841e3067a6
commit
c3c6cdc446
2 changed files with 73 additions and 55 deletions
|
|
@ -267,7 +267,7 @@ clean-all-dirs:
|
|||
|
||||
purge: $(SSH_WRAPPER_SH)
|
||||
ifneq ($(PURGE_SH),/bin/bash purge-not-found)
|
||||
$(PURGE_SH)
|
||||
$(PURGE_SH) --vcs git
|
||||
endif
|
||||
|
||||
$(PROJECTS_TXT):
|
||||
|
|
|
|||
|
|
@ -43,6 +43,28 @@ check_scm()
|
|||
|
||||
set -e
|
||||
|
||||
date=`date +'%Y%m%d'`
|
||||
myname=`basename $0`
|
||||
vcss="git"
|
||||
|
||||
opts=$(getopt -o C --long "vcs:" -n $myname -- "$@") || fatal "Failed to parse options $@"
|
||||
eval set -- "$opts"
|
||||
while [ "$1" != -- ]; do
|
||||
case "$1" in
|
||||
--vcs)
|
||||
vcss="$2"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
fatal "Unknown option $1"
|
||||
;;
|
||||
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
vcss=$(echo -e $vcss | sed 's/[, ]\+/\n/g' | sort -u)
|
||||
|
||||
ssh=ssh
|
||||
[ "$CVS_RSH" ] && ssh="$CVS_RSH"
|
||||
[ "$GIT_SSH" ] && ssh="$GIT_SSH"
|
||||
|
|
@ -51,21 +73,22 @@ ssh=`which $ssh`
|
|||
[ "$JANWARE_USER" ] || JANWARE_USER=`whoami`
|
||||
ssh="$ssh -l $JANWARE_USER"
|
||||
|
||||
for host in cvs.janware.com git.janware.com; do
|
||||
for vcs in $vcss; do
|
||||
case "$vcs" in
|
||||
cvs|CVS) host=cvs.janware.com;;
|
||||
git|Git) host=git.janware.com;;
|
||||
esac
|
||||
$ssh $host echo hallo >/dev/null 2>&1 || fatal "Can't ssh into host $host"
|
||||
done
|
||||
|
||||
local_cvs_proj=`ls -d */CVS 2>/dev/null | sed 's%/[^/]*%%'`
|
||||
local_git_proj=`ls -d */.git 2>/dev/null | sed 's%/[^/]*%%'`
|
||||
remote_cvs_proj=`$ssh cvs.janware.com find /srv/cvs/proj -maxdepth 1 -mindepth 1 -type d -executable -readable | sed 's%.*/%%'`
|
||||
remote_git_proj=`$ssh git.janware.com /opt/jw-pkg/bin/git-srv-admin.sh -j list-personal-projects`
|
||||
|
||||
date=`date +'%Y%m%d'`
|
||||
myname=`basename $0`
|
||||
|
||||
trap goodbye EXIT INT QUIT KILL
|
||||
scm_status=`mktemp /tmp/$myname""_XXXXXX`
|
||||
|
||||
for vcs in $vcss; do
|
||||
case $vcs in
|
||||
cvs|CVS)
|
||||
local_cvs_proj=`ls -d */CVS 2>/dev/null | sed 's%/[^/]*%%'`
|
||||
remote_cvs_proj=`$ssh cvs.janware.com find /srv/cvs/proj -maxdepth 1 -mindepth 1 -type d -executable -readable | sed 's%.*/%%'`
|
||||
for p in $local_cvs_proj; do
|
||||
[ -L $p ] && continue
|
||||
[ -d $p ] || continue
|
||||
|
|
@ -80,26 +103,16 @@ for p in $local_cvs_proj; do
|
|||
purged="$purged $p"
|
||||
done
|
||||
|
||||
[ -d old ] && mv old purged
|
||||
|
||||
[ "$purged" ] && {
|
||||
cp -p CVS/Entries CVS/Entries-$date-`date +'%H%M%S'`
|
||||
}
|
||||
|
||||
for p in $purged; do
|
||||
sed -i "/D\/$p\/\/\/\// d" CVS/Entries
|
||||
done
|
||||
|
||||
if [ -d dspc/src/CVS ]; then
|
||||
for i in dspcd shared; do
|
||||
sed -i "/D\/$i\/\/\/\// d" dspc/src/CVS/Entries
|
||||
done
|
||||
fi
|
||||
|
||||
for i in dspider-btools dspider-shared; do
|
||||
[ -L "$i" ] && rm $i
|
||||
done
|
||||
|
||||
}
|
||||
;;
|
||||
git|Git)
|
||||
local_git_proj=`ls -d */.git 2>/dev/null | sed 's%/[^/]*%%'`
|
||||
remote_git_proj=`$ssh git.janware.com /opt/jw-pkg/bin/git-srv-admin.sh -j list-personal-projects`
|
||||
for p in $local_git_proj; do
|
||||
[ -L $p ] && continue
|
||||
[ -d $p ] || continue
|
||||
|
|
@ -111,4 +124,9 @@ for p in $local_git_proj; do
|
|||
mv $p $n
|
||||
log "moving stale project \"$p\" to \"$n\""
|
||||
done
|
||||
|
||||
;;
|
||||
*)
|
||||
log "Unsupported version-control system >$vcs<, ignoring"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue