Skip to content

Instantly share code, notes, and snippets.

@shichao-an
Last active February 11, 2022 20:11
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save shichao-an/0baf62e53c07ed566c9b to your computer and use it in GitHub Desktop.
Save shichao-an/0baf62e53c07ed566c9b to your computer and use it in GitHub Desktop.
Script for git svn --authors-prog argument (author name conversion)
#!/usr/bin/env bash
# Script for converting author from SVN to Git, used as an argument for
# --authors-prog
# Example:
# "foo.bar" will be "Foo Bar <foo.bar@example.com>"
# "not-human" will be "not-human <not-human@example.com>"
set -e
EMAIL_DOMAIN=example.com
username2name() {
local username=$1
local firstname=${username%%.*}
local lastname=${username##*.}
local name="${firstname~} ${lastname~}"
if [[ "$firstname" == "$lastname" ]]; then
local name="$firstname"
fi
local email="${username}@$EMAIL_DOMAIN"
echo "$name <$email>"
}
username2name $1
@paulohy
Copy link

paulohy commented Aug 24, 2018

thank you so much for this!

@cassek
Copy link

cassek commented Feb 11, 2022

thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment