Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,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.
Optionally, also `user.signingkey` and `commit.gpgsign` can be configured independently. Corresponding variablels `gpgid` and `gpgsign` might be set or omitted.

## Installation

Expand Down Expand Up @@ -30,8 +31,8 @@ Example:
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";;
*@corp.com:* ) email="my-corporate@email"; name="real name"; gpgid="GPG ID"; gpgsign="true/false";;
*//corp.com/* ) email="my-corporate@email"; name="real name"; gpgid="GPG ID"; gpgsign="true/false";;
esac
```

Expand Down
4 changes: 4 additions & 0 deletions git-clone-init
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/bin/bash

#You can also provide the following variables:
# gpgid ID of an gpg key configuration of user.signingkey
# gpgsign true/false configuration of commit.gpgsign

case "$url" in
*@github.com:* ) email=""; name="";;
*//github.com/* ) email=""; name="";;
Expand Down
16 changes: 16 additions & 0 deletions post-checkout
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ if [[ ! -f "$configpath" ]]; then
cat << INPUT > "$configpath"
#!/bin/bash

#You can also provide the following variables:
# gpgid ID of an gpg key configuration of user.signingkey
# gpgsign true/false configuration of commit.gpgsign

case "\$url" in
*@github.com:* ) email=""; name="";;
*//github.com/* ) email=""; name="";;
Expand All @@ -52,3 +56,15 @@ 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 user.signingkey "$gpgid"

echo -e "\n Repo configured to use $gpgid GPG Identity"
fi

if [[ ! -z $gpgsign ]]; then
git config commit.gpgsign "$gpgsign"

echo -e "\n Repo configured to use commit.gpgsign=$gpgsign"
fi