Skip to content

Commit 9baea04

Browse files
committed
Init installation script
1 parent 0a7ba7c commit 9baea04

File tree

2 files changed

+36
-12
lines changed

2 files changed

+36
-12
lines changed

README.md

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,14 @@ long.
1111

1212
## Installation
1313

14-
Execute the command for your platform within the root folder of your git
15-
project. This will download the latest release, puts it in the `./.git/hooks/`
16-
folder and makes it executable. See git documentation about hooks for
14+
Execute the command within the root folder of your git
15+
project. This will download the installation script that determines the OS and
16+
downloads the latest binary. Afterwards, the initialization is started and the
17+
corresponding hook files are prepared. See git documentation about hooks for
1718
further [reference](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks).
1819

19-
### MacOS
20-
21-
```shell
22-
curl -o .git/hooks/commit-msg -L https://github.com/rockstaedt/commit-message-check/releases/download/v0.0.4/commit-message-check-v0.0.4-darwin-arm64 && chmod +x .git/hooks/commit-msg
23-
```
24-
25-
### Linux
26-
2720
```shell
28-
curl -o .git/hooks/commit-msg -L https://github.com/rockstaedt/commit-message-check/releases/download/v0.0.4/commit-message-check-v0.0.4-linux-amd64 && chmod +x .git/hooks/commit-msg
21+
curl -o install.sh -L https://raw.githubusercontent.com/rockstaedt/commit-message-check/main/install.sh && chmod +x ./install.sh && ./install.sh
2922
```
3023

3124
## Usage

install.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/sh
2+
3+
version=$(curl --silent "https://api.github.com/repos/rockstaedt/commit-message-check/releases/latest" |
4+
grep '"tag_name":' |
5+
sed -E 's/.*"([^"]+)".*/\1/')
6+
7+
echo "-> Installing commit-message-check ${version}"
8+
9+
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
10+
os="linux"
11+
elif [[ "$OSTYPE" == "darwin"* ]]; then
12+
os="darwin"
13+
else
14+
echo "ERROR - Could not determine operating system. Please download binary manually."
15+
exit
16+
fi
17+
18+
os="${os}-$(uname -m)"
19+
binary="commit-message-check-${version}-${os}"
20+
url="https://github.com/rockstaedt/commit-message-check/releases/latest/download/${binary}"
21+
22+
curl -o commit-message-check -L $url && chmod +x ./commit-message-check
23+
24+
if !(grep -Fxq "commit-message-check" .gitignore); then
25+
read -e -p "Do you want to add the binary to gitignore? (y/n) " choice
26+
[[ "$choice" == [Yy]* ]] && echo 'commit-message-check'>>.gitignore
27+
fi
28+
29+
./commit-message-check init
30+
31+
rm ./install.sh

0 commit comments

Comments
 (0)