tools/rgit2hg.sh
author Wuzzy <Wuzzy2@mail.ru>
Sat, 27 Oct 2018 15:55:19 +0200
changeset 14014 f09276eb0c27
parent 11517 b3ee79e8e3b9
permissions -rwxr-xr-x
Add 7 new taunts New sounds: * Bugger, Drat: Hog damages self only * Thisoneismine: Crate drop * Whatthe: Something is going to blow up close to hog * Solong, Ohdear: Death * Gonnagetyou: Vow for revenge Fallback code is added for existing voicepacks Thisoneismine is not used in Robot because the text in this sound file is "Threat detected.", which does not make sense.

#!/bin/sh

#HW_HG=

if [ -z "$1" ]; then
    echo 'You have to supply at least one hedgewars git revision as parameter!' >&2
    exit
fi

if [ -z "$HW_HG" ]; then 
    HW_HG="$PWD"
fi

if [ ! -d "$HW_HG/.hg" ]; then
    echo 'You have to set HW_HG (inside script or env) to a repo clone OR call this script from inside the repository!' >&2
    exit
fi

while [ ! -z "$1" ]; do
    echo
    echo
    echo '---------------------------------------------------------------'
    echo "$1"
    echo '---------------------------------------------------------------'
    url="https://github.com/hedgewars/hw/commit/$1"
    echo "Checking $url ..."
    echo
    page=$(wget -q -O- "$url")
    author=$(echo "$page" | sed -rn '1,/"user-mention"/{s/^.*"user-mention"( *[^>]*)?> *([^ <]*).*$/\2/ p}')
    if [ -z "$author" ]; then
        echo 'Couldn'\''t find author! Skipping '"$1"' ...' >&2
        shift
        continue
    fi
    echo 'Found author: '"$author"
    date=$(echo "$page" | sed -rn 's/^.*<time datetime="([^T]+)T([^Z]+).*/\1 \2 +0000/ p')
    if [ -z "$date" ]; then
        echo 'Couldn'\''t find date! Skipping '"$1"' ...' >&2
        shift
        continue
    fi
    echo 'Found date:   '"$date"
    echo
    echo 'Checking mercurial log for matches ...'
    echo
    result=$(hg log -R "$HW_HG" -u "$author" -d "$date" -v -l1)
    if [ -z "$result" ]; then
        echo 'No match with this author'\''s name. It might differ, so let'\''s try using date only ...'
        echo
        result=$(hg log -R "$HW_HG" -d "$date" -v)
    fi
    if [ -z "$result" ]; then
        echo 'No match :('
        shift
        continue
    fi
    rev=$(echo "$result" | sed 's/^.*://;q')
    echo 'Found match: r'"$rev"
    echo 'Link:        http://hg.hedgewars.org/hedgewars/rev/'"$rev"
    echo
    echo "$result"
    # proceed to next parameter
    shift
done

echo