Skip to content

Commit f4853d2

Browse files
committed
Merge branch 'BoostCookie-master'
* BoostCookie-master: Replace tilde by \$HOME Respect the XDG Base Directory specification
2 parents 585a739 + fcc7f5b commit f4853d2

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,28 @@
22

33
![Screenshot of a git clone](/about.png)
44

5-
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.
5+
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.
66

77
## Installation
88

99
In case you do not already have a git template directory, create and register one:
1010

1111
```bash
12-
mkdir -p ~/.git-templates/hooks
13-
git config --global init.templatedir ~/.git-templates
12+
mkdir -p ~/.config/git/templates/hooks
13+
git config --global init.templatedir ~/.config/git/templates
1414
```
1515
Copy the file "post-checkout" to your registered git template directory:
1616
```bash
1717
git clone https://github.com/DrVanScott/git-clone-init.git /tmp/git-clone-init
18-
cp /tmp/git-clone-init/post-checkout ~/.git-templates/hooks/
18+
cp /tmp/git-clone-init/post-checkout ~/.config/git/templates/hooks/
1919
```
2020
Copy a configuration template:
2121
```bash
22-
cp /tmp/git-clone-init/.git-clone-init ~/
22+
cp /tmp/git-clone-init/git-clone-init ~/.config/git/templates/
2323
```
2424
## Configuration
2525

26-
You can use the file ".git-clone-init" as a starting point. Keep in mind to create a pattern for each protocol you are using, normally ssh and https.
26+
You can use the file `git-clone-init` as a starting point. Keep in mind to create a pattern for each protocol you are using, normally ssh and https.
2727

2828
Example:
2929
```bash
File renamed without changes.

post-checkout

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,23 @@ fi
2828

2929
url="$(git config --local remote.${remote}.url)"
3030

31-
if [[ ! -f ~/.git-clone-init ]]; then
32-
cat << INPUT > ~/.git-clone-init
31+
configpath="${XDG_CONFIG_HOME:-${HOME}/.config}/git/templates/git-clone-init"
32+
if [[ ! -f "$configpath" ]]; then
33+
cat << INPUT > "$configpath"
3334
#!/bin/bash
3435
3536
case "\$url" in
3637
*@github.com:* ) email=""; name="";;
3738
*//github.com/* ) email=""; name="";;
3839
esac
3940
INPUT
40-
warn "\nMissing file ~/.git-clone-init. Template created..."
41+
warn "\nMissing file $configpath. Template created..."
4142
exit 0
4243
fi
43-
. ~/.git-clone-init
44+
. "$configpath"
4445

4546
if [[ -z $name || -z $email ]]; then
46-
warn "Failed to detect identity using ~/.git-clone-init."
47+
warn "Failed to detect identity using $configpath."
4748
exit 0
4849
fi
4950

0 commit comments

Comments
 (0)