aboutsummaryrefslogtreecommitdiffstats
path: root/git-svn-fix-authors.sh
blob: 7b46ef40e6fc659925f8abbfc96d288b503e3aa2 (plain) (blame)
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
47
48
49
50
51
52
53
54
55
56
57
#!/bin/sh
set -eu

AUTHORS_FILE=$(git config svn.authorsfile) || \
    AUTHORS_FILE=$(git config svn-remote.svn.authorsfile) || {
    echo "ERROR: set config.svn.authorsfile!"
    exit 128
}
export AUTHORS_FILE=$(readlink -f $AUTHORS_FILE)

git filter-branch -f --tag-name-filter cat --env-filter '

function replacement() {
    REPL=$(awk -F"[[:space:]]*=[[:space:]]*" "/$1/ {print \$2}" $AUTHORS_FILE)
    MAIL=$(echo "$REPL"|awk "{print \$NF}"|tr -d "<>" )
    NAME=$(echo "$REPL"|awk "{print gensub(/[[:space:]]*<[^[:space:]]*/,\"\",\"\")}" )
}

replacement "${GIT_AUTHOR_NAME}"
#if [ "x$NAME" == "x" ] ; then
#    echo -e "\nERROR: When changing ${GIT_COMMIT} we got empty reply."
#    echo -e "I do not know how to map ${GIT_AUTHOR_NAME}.\n"
#    set|grep ^GIT
#    exit 1
#fi

if [ "x$NAME" != "x" ] ; then
export GIT_AUTHOR_NAME="$NAME"
export GIT_AUTHOR_EMAIL="$MAIL"
export GIT_COMMITTER_NAME="$NAME"
export GIT_COMMITTER_EMAIL="$MAIL"
fi
' -- --tags

git filter-branch -f --env-filter '

function replacement() {
    REPL=$(awk -F"[[:space:]]*=[[:space:]]*" "/$1/ {print \$2}" $AUTHORS_FILE)
    MAIL=$(echo "$REPL"|awk "{print \$NF}"|tr -d "<>" )
    NAME=$(echo "$REPL"|awk "{print gensub(/[[:space:]]*<[^[:space:]]*/,\"\",\"\")}" )
}

replacement "${GIT_AUTHOR_NAME}"
#if [ "x$NAME" == "x" ] ; then
#    echo -e "\nERROR: When changing ${GIT_COMMIT} we got empty reply."
#    echo -e "I do not know how to map ${GIT_AUTHOR_NAME}.\n"
#    set|grep ^GIT
#    exit 1
#fi

if [ "x$NAME" != "x" ] ; then
export GIT_AUTHOR_NAME="$NAME"
export GIT_AUTHOR_EMAIL="$MAIL"
export GIT_COMMITTER_NAME="$NAME"
export GIT_COMMITTER_EMAIL="$MAIL"
fi
' -- --all