diff --git a/.git-clone-init b/.git-clone-init index 4cae6b7..06dd361 100644 --- a/.git-clone-init +++ b/.git-clone-init @@ -1,6 +1,6 @@ #!/bin/bash case "$url" in - *@github.com:* ) email=""; name="";; - *//github.com/* ) email=""; name="";; + *@github.com:* ) email=""; name=""; gpgid="";; + *//github.com/* ) email=""; name=""; gpgid="";; esac diff --git a/README.md b/README.md index 33aacff..6e3fe64 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ![Screenshot of a git clone](/about.png) -Whenever a repository is cloned, author information (user.email, user.name) is set according defined patterns. No longer pushing commits with your corporate email address by accident. +Whenever a repository is cloned, author information (user.email, user.name, user.signingkey) is set according defined patterns. No longer pushing commits with your corporate email address by accident. ## Installation @@ -28,10 +28,10 @@ You can use the file ".git-clone-init" as a starting point. Keep in mind to crea Example: ```bash case "$url" in - *@github.com:* ) email="my-public@email"; name="public name";; - *//github.com/* ) email="my-public@email"; name="public name";; - *@corp.com:* ) email="my-corporate@email"; name="real name";; - *//corp.com/* ) email="my-corporate@email"; name="real name";; + *@github.com:* ) email="my-public@email"; name="public name"; gpgid="GPG ID";; + *//github.com/* ) email="my-public@email"; name="public name"; gpgid="GPG ID";; + *@corp.com:* ) email="my-corporate@email"; name="real name"; gpgid="GPG same/other ID";; + *//corp.com/* ) email="my-corporate@email"; name="real name"; gpgid="GPG same/other ID";; esac ``` diff --git a/post-checkout b/post-checkout index 27e6557..8a0b945 100755 --- a/post-checkout +++ b/post-checkout @@ -33,8 +33,8 @@ cat << INPUT > ~/.git-clone-init #!/bin/bash case "\$url" in - *@github.com:* ) email=""; name="";; - *//github.com/* ) email=""; name="";; + *@github.com:* ) email=""; name=""; gpgid="";; + *//github.com/* ) email=""; name=""; gpgid="";; esac INPUT warn "\nMissing file ~/.git-clone-init. Template created..." @@ -51,3 +51,10 @@ git config --local user.email "$email" git config --local user.name "$name" echo -e "\nLocal identity for ${PWD##*/} set to \"$name <$email>\"" + +if [[ ! -z $gpgid ]]; then + git config commit.gpgsign true + git config user.signingkey $gpgid + + echo -e "\n Repo configured to use $gpgid GPG Identity" +fi