Skip to content

Commit dbe20ab

Browse files
committed
Make signing functionality optional
1 parent 049ad18 commit dbe20ab

File tree

3 files changed

+24
-11
lines changed

3 files changed

+24
-11
lines changed

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
![Screenshot of a git clone](/about.png)
44

55
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.
6-
Optionally, also `user.signingkey` can be configured.
6+
Optionally, also `user.signingkey` and `commit.gpgsign` can be configured independently. Corresponding variablels `gpgid` and `gpgsign` might be set or omitted.
77

88
## Installation
99

@@ -29,10 +29,10 @@ You can use the file `git-clone-init` as a starting point. Keep in mind to creat
2929
Example:
3030
```bash
3131
case "$url" in
32-
*@github.com:* ) email="my-public@email"; name="public name"; gpgid="GPG ID";;
33-
*//github.com/* ) email="my-public@email"; name="public name"; gpgid="GPG ID";;
34-
*@corp.com:* ) email="my-corporate@email"; name="real name"; gpgid="GPG same/other ID";;
35-
*//corp.com/* ) email="my-corporate@email"; name="real name"; gpgid="GPG same/other ID";;
32+
*@github.com:* ) email="my-public@email"; name="public name";;
33+
*//github.com/* ) email="my-public@email"; name="public name";;
34+
*@corp.com:* ) email="my-corporate@email"; name="real name"; gpgid="GPG ID"; gpgsign="true/false";;
35+
*//corp.com/* ) email="my-corporate@email"; name="real name"; gpgid="GPG ID"; gpgsign="true/false";;
3636
esac
3737
```
3838

git-clone-init

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#!/bin/bash
22

3+
#You can also provide the following variables:
4+
# gpgid ID of an gpg key configuration of user.signingkey
5+
# gpgsign true/false configuration of commit.gpgsign
6+
37
case "$url" in
4-
*@github.com:* ) email=""; name=""; gpgid="";;
5-
*//github.com/* ) email=""; name=""; gpgid="";;
8+
*@github.com:* ) email=""; name="";;
9+
*//github.com/* ) email=""; name="";;
610
esac

post-checkout

+13-4
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,13 @@ if [[ ! -f "$configpath" ]]; then
3333
cat << INPUT > "$configpath"
3434
#!/bin/bash
3535
36+
#You can also provide the following variables:
37+
# gpgid ID of an gpg key configuration of user.signingkey
38+
# gpgsign true/false configuration of commit.gpgsign
39+
3640
case "\$url" in
37-
*@github.com:* ) email=""; name=""; gpgid="";;
38-
*//github.com/* ) email=""; name=""; gpgid="";;
41+
*@github.com:* ) email=""; name="";;
42+
*//github.com/* ) email=""; name="";;
3943
esac
4044
INPUT
4145
warn "\nMissing file $configpath. Template created..."
@@ -54,8 +58,13 @@ git config --local user.name "$name"
5458
echo -e "\nLocal identity for ${PWD##*/} set to \"$name <$email>\""
5559

5660
if [[ ! -z $gpgid ]]; then
57-
git config commit.gpgsign true
58-
git config user.signingkey $gpgid
61+
git config user.signingkey "$gpgid"
5962

6063
echo -e "\n Repo configured to use $gpgid GPG Identity"
6164
fi
65+
66+
if [[ ! -z $gpgsign ]]; then
67+
git config commit.gpgsign "$gpgsign"
68+
69+
echo -e "\n Repo configured to use commit.gpgsign=$gpgsign"
70+
fi

0 commit comments

Comments
 (0)