Created
August 3, 2018 08:44
-
-
Save toschneck/d702abce1c783d08cd9d53a6a2a5ac39 to your computer and use it in GitHub Desktop.
Revisions
-
toschneck created this gist
Aug 3, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,41 @@ # add this to your bash env # Set git user and signing key function git-set-user() { if [ "$#" -lt "1" ] then echo "Missing required arguments" >&2 echo "Usage: $0 EMAIL [PATH_TO_GIT_REPO]" >&2 exit 65 fi USER_EMAIL="$1" USER_KEY=`gpg --with-colons -K "$USER_EMAIL" 2>/dev/null | awk -F: '$1 =="fpr" {print $10; exit}'` if [ -z "$USER_KEY" ] then echo "Unable to retrieve GPG key for $USER_EMAIL" >&2 exit 1 fi if [ -n "$2" ] then WORKING_DIR="$2" else WORKING_DIR="`pwd`" fi if [ ! -e "$WORKING_DIR/.git" ] then echo "Error: $WORKING_DIR is not a Git repository" >&2 exit 1 fi set -x git config --local user.email "$USER_EMAIL" git config --local user.signingkey "$USER_KEY" git config --local commit.gpgsign true }