Skip to content

Instantly share code, notes, and snippets.

@PandaEox
Created June 3, 2014 11:12
Show Gist options
  • Select an option

  • Save PandaEox/42a9f27bff9d0515b51c to your computer and use it in GitHub Desktop.

Select an option

Save PandaEox/42a9f27bff9d0515b51c to your computer and use it in GitHub Desktop.

Revisions

  1. PandaEox created this gist Jun 3, 2014.
    45 changes: 45 additions & 0 deletions rewrite.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,45 @@
    #!/bin/bash

    raw=`cat users.txt`
    IFS=$'\n'
    arr=($raw)

    output=""
    for i in "${arr[@]}"
    do
    IFS='=' read -a line <<< "$i"
    svn_user=`echo "${line[0]}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'`
    git_name=`echo "${line[1]}" | egrep -o '(\w.*)\s*<' | egrep -o '\w.*\w'`
    git_mail=`echo "${line[1]}" | egrep -o '<(.+)>' | egrep -o '[^<>]+'`
    echo "Processing $svn_user who is really name ($git_name) with mail ($git_mail)"

    output=$( cat <<EOF
    $output
    if [ "\$GIT_COMMITTER_EMAIL" = "$svn_user" ]
    then
    cn="$git_name"
    cm="$git_mail"
    fi
    if [ "\$GIT_AUTHOR_EMAIL" = "$svn_user" ]
    then
    an="$git_name"
    am="$git_mail"
    fi
    EOF
    )

    done

    git filter-branch -f --env-filter "
    an=\"\$GIT_AUTHOR_NAME\"
    am=\"\$GIT_AUTHOR_EMAIL\"
    cn=\"\$GIT_COMMITTER_NAME\"
    cm=\"\$GIT_COMMITTER_EMAIL\"
    $output
    export GIT_AUTHOR_NAME=\"\$an\"
    export GIT_AUTHOR_EMAIL=\"\$am\"
    export GIT_COMMITTER_NAME=\"\$cn\"
    export GIT_COMMITTER_EMAIL=\"\$cm\"
    "
    1 change: 1 addition & 0 deletions users.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    DaPanda = Da Panda <[email protected]>