Bugfix: repo-hash.sh didn't wasn't independent of the current working dir.
Warning, cannot access the index:
_darcs/index: opening of '_darcs/index' failed: permission denied (Permission denied)
diff -rN -u old-bii_scripts/bin/repo-hash.sh new-bii_scripts/bin/repo-hash.sh
--- old-bii_scripts/bin/repo-hash.sh 2022-09-28 11:14:15.043410048 +0200
+++ new-bii_scripts/bin/repo-hash.sh 2022-09-28 11:14:15.043410048 +0200
@@ -123,19 +123,22 @@
function githash {
# create hash for git repo
- CMDRET "git log --pretty=format:'%H' | md5sum | sed -e 's/ .*//'"
+ # $1: dir
+ CMDRET "(cd $1 && git log --pretty=format:'%H' | md5sum | sed -e 's/ .*//')"
echo "$cmddata"
}
function darcshash {
# create hash for git repo
- CMDRET "darcs log | grep patch | md5sum | sed -e 's/ .*//'"
+ # $1: dir
+ CMDRET "(cd $1 && darcs log | grep patch | md5sum | sed -e 's/ .*//')"
echo "$cmddata"
}
function hghash {
# create hash for git repo
- CMDRET "hg log --template '{node}\n' | md5sum | sed -e 's/ .*//'"
+ # $1: dir
+ CMDRET "(cd $1 && hg log --template '{node}\n' | md5sum | sed -e 's/ .*//')"
echo "$cmddata"
}
@@ -143,28 +146,29 @@
# hash for git repos
# $1: directory
# $2: hashfile (optional)
- REPOTYPE=$(repotype "$1")
- CD "$1"
+ local REPODIR="$1"
+ local HASHFILE="$2"
+ REPOTYPE=$(repotype "$REPODIR")
if [ "$REPOTYPE" == "git" ]; then
- HASH="$(githash)"
+ HASH="$(githash "$REPODIR")"
elif [ "$REPOTYPE" == "mercurial" ]; then
- HASH="$(hghash)"
+ HASH="$(hghash "$REPODIR")"
elif [ "$REPOTYPE" == "darcs" ]; then
- HASH="$(darcshash)"
+ HASH="$(darcshash "$REPODIR")"
else
echo "internal error, unexpected REPOTYPE $REPOTYPE" >&2
exit 1
fi
- if [ -z "$2" ]; then
+ if [ -z "$HASHFILE" ]; then
echo "$HASH"
return
fi
OLDHASH=""
- if [ -e $2 ]; then
- OLDHASH=$(cat $2)
+ if [ -e $HASHFILE ]; then
+ OLDHASH=$(cat $HASHFILE)
fi
if [ "$OLDHASH" != "$HASH" ]; then
- CMD "echo \"$HASH\" > $2"
+ CMD "echo \"$HASH\" > $HASHFILE"
else
returncode=1
fi
patch cf55088ec5eefe650646da8bf6f464f3dbc7a677
Author: Goetz.Pfeiffer@helmholtz-berlin.de
Date: Sun May 29 18:23:27 CEST 2022
* Bugfix: repo-hash.sh didn't wasn't independent of the current working dir