bitreich-memestats

metrics and graphs for the bitreich meme collection
git clone git://src.adamsgaard.dk/bitreich-memestats # fast
git clone https://src.adamsgaard.dk/bitreich-memestats.git # slow
Log | Files | Refs | LICENSE Back to index

commit 59cc23745f7cb078911587bfaf9a729f69118c30
parent de4c6bca50d8e9eaf654b32c5fda4ff83b36a52a
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Mon, 30 Aug 2021 17:52:31 +0200

extract-memecount.sh: allow running outside of $annnadir

This makes it possible to run the script without write access to
$annnadir

Signed-off-by: Christoph Lohmann <20h@r-36.net>

Diffstat:
Mextract-memecount.sh | 14+++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/extract-memecount.sh b/extract-memecount.sh @@ -18,12 +18,11 @@ if [ ! -e "${annnadir}/${memefile}" ]; then exit 1 fi -cd "$annnadir" if [ -f "${outputfile}" ]; then lastrevision="$(tail -n 1 "${outputfile}" | cut -f 2)" revisionrange="${lastrevision}..HEAD" else - firstrevision="$(git rev-list --max-parents=0 HEAD)" + firstrevision="$(cd "${annnadir}" && git rev-list --max-parents=0 HEAD)" revisionrange="${firstrevision}..HEAD" fi @@ -36,24 +35,25 @@ case "${outputfile}" in esac if [ "$update_annna" = "yes" ]; then - git pull >/dev/null 2>&1 + (cd "${annnadir}" && git pull >/dev/null 2>&1) fi headcommit="$(git rev-parse HEAD)" i=0 # derived from Hiltjo Posthuma's loc.sh -git log --pretty='format:%H %cd %at' --date="format:%Y-%m-%d" \ - "${revisionrange}" | \ +(cd "${annnadir}" && git log --pretty='format:%H %cd %at' --date="format:%Y-%m-%d" \ + "${revisionrange}") | \ sort -k 2 | uniq -f 1 | \ while read -r commit date timestamp; do # hashtags originally stored in annna-start-services... - n="$(git show "$commit:annna-start-services" 2>/dev/null | \ + n="$(cd "${annnadir}" && git show "$commit:annna-start-services" 2>/dev/null | \ grep -E '^ #[a-z0-9]' | wc -l | awk '{print $1}')" # ...but are now stored in $memefile if [ "$n" -le 1 ]; then - n="$(git show "$commit:$memefile" 2>/dev/null | wc -l | awk '{print $1}')" + n="$(cd "${annnadir}" && git show "$commit:$memefile" 2>/dev/null | \ + wc -l | awk '{print $1}')" fi if [ "$n" -gt 1 ]; then