Git hook triggered via local commit or Gitea's one. It runs Hugo against its dedicated repository with Markdown files and related assets.
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
Marcell Mars 24ad682cb4 hardcoded path is now hook struct property... 3 years ago
giq new githook.. too many changes for commit message... 3 years ago
vendor new vendor... 3 years ago
README.md hardcoded path is now hook struct property... 3 years ago
go.mod new sphook.. built with go1.16... 3 years ago
go.sum new sphook.. built with go1.16... 3 years ago
install_sphook.sh self-destructing install script for gitea 3 years ago
main.go new githook.. too many changes for commit message... 3 years ago
metahook.go new githook.. too many changes for commit message... 3 years ago
metahugo.go new githook.. too many changes for commit message... 3 years ago
sphook new sphook.. built with go1.16... 3 years ago

README.md

# Sandpoints git hook

## Initialization & build

`sphook` binary was built like this:

```
go mod init main
go mod vendor
go build -o sphook .
```

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, build it, test it and report back or even better do PR here.

## Hugo's final output directory

`sphook' has hardcoded filepath for Hugo's final output directory:

```
/var/www/html/sandpoints
```

If you want to build it against another directory where Hugo will render its content you should manually find the line:

```
hook.PublicHTMLPath = filepath.Join("/var", "www", "html", "sandpoints")
```

change it there and rebuild it.

## Two scenarios: post-commit (local) & post-receive (gitea)

`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. `sphook` 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 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.