update README.md

master
Marcell Mars 3 years ago
parent a77dfe50d9
commit 513cf36e95

@ -1,40 +1,42 @@
# Sandpoints git hook
this repo was initialized and `sphook` binary built like this:
## Initialization & build
`sphook` binary was built like this:
```
go mod init main
go mod vendor
go build -o sphook .
```
the `sphook` executable in the root repo is built on linux 64bits computer. it should work on common linux x86_64 virtual server or common linux x86_64 bare metal computer.
The `sphook` executable in root directory of this repo is built on linux 64bits computer. It should work on common linux x86_64 virtual server or common linux x86_64 bare metal computer.
The `sphook` binary is only tested on Linux virtual server and developer's laptop. If you need it for some other arch or operating system, please build it, test it and report back or even better do PR here.
it has hardcoded filepath for Hugo's final output directory:
## Hugo's final output directory
`sphook' has hardcoded filepath for Hugo's final output directory:
```
/var/www/html/sandpoints
```
it should work for two scenarios:
- _bare_ git repository and in our case we always run it against the `gitea` instances (git web frontend).
- _working_ git repository and in our case that's usually a git repository running on some local instance (e.g. developer's laptop)
1) in _bare_ git repository scenario it should work as a post-receive hook
2) in _working_ git repository scenario it should work as a post-commit hook
regarding scenario `sphook` will be renamed into `.git/hooks/post-commit`, `gitea_repo.git/hooks/post-received.d/sphook` or whatever is prepared/set in `.git/hooks` directory to trigger an executable after the specific hook.
its task is simple: it takes content from `content/` directory and run `hugo` against it. it places the output into:
If you want to build it against another directory where Hugo will render its content you should manually find the line:
```
/var/www/html/sandpoints/{hugo_project_name}-{`crc32.ChecksumIEEE(git_repo_path)`}
outDir := filepath.Join("/", "var", "www", "html", "sandpoints")
```
change it there and rebuild it.
it is good to check out the logs of git commit in order to find the path of that directory. once that's done logs will be placed in both:
```
/var/www/html/sandpoints/{hugo_project_name}-{`crc32.ChecksumIEEE(git_repo_path)`}/last-commit-log.txt
## Two scenarios: post-commit (local) & post-receive (gitea)
/var/www/html/sandpoints/{hugo_project_name}-{`crc32.ChecksumIEEE(git_repo_path)`}/_preview/last-commit-log.txt
```
`sphook` should work as it is for two scenarios:
- _bare_ git repository and in our case we run it against the `gitea` instances (git web frontend).
- Gitea keeps its `post-receive` hooks inside the `hooks/post-receive.d/` directory relative to particular _bare_ git repository. `sphooks` should land there as it is, no need to change the name, and it will run after every remote `git push` into the repo.
- _working_ git repository
- that's usually a contributor running the local instance of a git repository. In order for `sphinx` to work as `post-commit` hook it should be placed inside `.git/hooks/` directory, renamed to `post-commit` and made executable (`chmod +x post-commit`). Hugo, via that hook, will render its output into:
`/var/www/html/sandpoints/{hugo_project_name}-{`\`crc32.ChecksumIEEE(git_repo_path)\`}`.
## Install `sphook` in Gitea via its web ui
`install_sphook.sh` bash script will install `sphook` in gitea as a `post-receive` hook. it will delete itself if `sphook` is already in `hooks/post-receive.d/` directory.
`install_sphook.sh` bash script can be used to install `sphook` to Gitea via its web user interface. If `install_sphook.sh` is made into `post-received` Gitea's hook it will first check if `sphook` is already in `hooks/post-received.d/` directory and if it is not it would install it there. If `sphook` is already there it would delete itself because it is not needed anymore.
Loading…
Cancel
Save