git
Two tasks to sign commits and use commitizen without pre-requisites.
git template details
- Status: stable
- File: https://gitlab.com/op_so/task/task-templates/-/raw/main/Taskfile.d/git.yml
- Home: https://gitlab.com/op_so/task/task-templates
- License: MIT
List of tasks
| Tasks | Description |
|---|---|
git:commitizen |
Signed commit with Commitizen. Arguments: KEY_PATH|K=key_full_path [PULL|P=n|N] [UPDATE|U=n|N] (*) |
git:signed-commit |
Signed commit. Arguments: KEY_PATH|K=key_full_path MESSAGE|M=message [OPTIONS|O="--amend"] [PULL|P=n|N] [UPDATE|U=n|N] (*) |
git:signed-commit-amend |
Amend a previous signed commit. Arguments: KEY_PATH|K=key_full_path [PULL|P=n|N] (*) |
global variables
| Variables | Description | Default value |
|---|---|---|
CONTAINER |
- | commit-{{now | unixEpoch}}-{{uuid | toString | trunc 8}} |
DOCKER_EXEC_OPTS |
Optional Docker options for docker exec command | {{.DOCKER_EXEC_OPTS | default ""}} |
DOCKER_RUN_OPTS |
Optional Docker options for docker run command | {{.DOCKER_RUN_OPTS | default ""}} |
DOCKER_USER |
Optional user of the container: uid:gid, root... | {{.DOCKER_USER | default ""}} |
IMAGE_DEFAULT |
Default image | jfxs/commitizen-semantic-release:latest |
KEY_MOUNT_POINT |
- | /Private |
KEY_NAME |
- | {{.KEY_PATH | toSlash | base}} |
KEY_PATH |
- | {{.KEY_PATH | default .K}} |
PULL |
- | {{.PULL | default .P}} |
RUN_USER |
- | - |
SRC_MOUNT_POINT |
- | /data |
UPDATE |
- | {{.UPDATE | default .U}} |
git:commitizen
Signed commit with Commitizen. Arguments: KEY_PATH|K=key_full_path [PULL|P=n|N] [UPDATE|U=n|N] (*)
[GIT] Signed commit with Commitizen.
Usage: task git:commitizen KEY_PATH|K=<key_full_path> [PULL|P=<n|N>] [UPDATE|U=n|N]
| Arguments | Description |
|---|---|
KEY_PATH | K |
Absolute path to the private key file (required) |
PULL | P |
Pull docker image (optional, by default yes) |
UPDATE | U |
Update git repository from remote (optional, by default yes) |
Prerequisites:
- Run command: git config user.signingkey XXXX
- Run command: git config commit.gpgsign true
Variables:
DOCKER_USER: User of the container, uid:gid or root (optional, by default the current uid:gid on Linux, none elsewhere or if rootless)
DOCKER_RUN_OPTS: Additional options of docker run (optional)
DOCKER_EXEC_OPTS: Additional options of docker exec (optional)
Notes:
- On Linux the container runs as the current user, so the files created in the repository are not owned by root.
DOCKER_USER=root restores the previous behavior.
- Rootless Docker/Podman is detected: no --user, the root of the container is already the current user.
- Only the key file is mounted in the container, read-only.
- Not tested on Windows.
Requirements:
- docker
git:signed-commit
Signed commit. Arguments: KEY_PATH|K=key_full_path MESSAGE|M=message [OPTIONS|O="--amend"] [PULL|P=n|N] [UPDATE|U=n|N] (*)
[GIT] Signed commit.
Usage: task git:signed-commit KEY_PATH|K=<key_full_path> MESSAGE|M=<message> [OPTIONS|O=\"<options>\"] [PULL|P=<n|N>] [UPDATE|U=n|N]
| Arguments | Description |
|---|---|
KEY_PATH | K |
Absolute path to the private key file (required) |
MESSAGE | M |
Commit message (required) |
OPTIONS | O |
Git options (optional, by default -S --signoff) |
PULL | P |
Pull docker image (optional, by default yes) |
UPDATE | U |
Update git repository from remote (optional, by default yes) |
Prerequisites:
- Run command: git config user.name "your name"
- Run command: git config user.email "your_email@example.com"
- Run command: git config user.signingkey XXXX
- Run command: git config commit.gpgsign true
Variables:
DOCKER_USER: User of the container, uid:gid or root (optional, by default the current uid:gid on Linux, none elsewhere or if rootless)
DOCKER_RUN_OPTS: Additional options of docker run (optional)
DOCKER_EXEC_OPTS: Additional options of docker exec (optional)
Notes:
- On Linux the container runs as the current user, so the files created in the repository are not owned by root.
DOCKER_USER=root restores the previous behavior.
- Rootless Docker/Podman is detected: no --user, the root of the container is already the current user.
- Only the key file is mounted in the container, read-only.
- Task evaluates the arguments given on its command line as templates: a MESSAGE containing double
curly braces must be given by the environment instead: MESSAGE='fix ...' task git:signed-commit KEY_PATH=...
- Not tested on Windows.
Requirements:
- docker
git:signed-commit-amend
Amend a previous signed commit. Arguments: KEY_PATH|K=key_full_path [PULL|P=n|N] (*)
[GIT] Amend a previous signed commit.
Usage: task git:signed-commit-amend KEY_PATH|K=<key_full_path> [PULL|P=<n|N>]
| Arguments | Description |
|---|---|
KEY_PATH | K |
Absolute path to the private key file (required) |
PULL | P |
Pull docker image (optional, by default yes) |
Variables:
DOCKER_USER: User of the container, uid:gid or root (optional, by default the current uid:gid on Linux, none elsewhere or if rootless)
DOCKER_RUN_OPTS: Additional options of docker run (optional)
DOCKER_EXEC_OPTS: Additional options of docker exec (optional)
Notes:
- On Linux the container runs as the current user, so the files created in the repository are not owned by root.
DOCKER_USER=root restores the previous behavior.
- Rootless Docker/Podman is detected: no --user, the root of the container is already the current user.
- Only the key file is mounted in the container, read-only.
- Not tested on Windows.
Requirements:
- docker