GothenburgBitFactory / GothenburgBitFactory/taskwarrior

Force hooks to specify their target version

Open
#3,851 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
6.1k
Forks
423
Avg merge
1d 19h
Merged PRs (30d)
11

Description

## Problem
Currently, hooks have the possibility to validate that the current hook version matches
their target (e.g., something like: `[ "$1" = "api:2" ] || { echo "Invalid version: $1"; exit 1; }`).

But this is completely voluntary, and not inspectable from the outside. Thus, TW has no
way to know which version a certain hook is targeting, and if it should warn the user
about outdated hooks.

## Proposed improvement
If we moved the hook naming scheme from `` to
`-`, we would require hooks to specify what version they are
targeting.

The changes from a v2 hook directory to a v3:

### V2
```
$ tree ~/.config/task/hooks
/nix/store/qicdpkw69wzp8gxi52i73h4ddaqy5k14-mk-taskwarrior-hooks
├── on-add_enforce-projects
├── on-add_sync-git-repos
├── on-modify_sync-git-repos-mod
├── on-modify_track-timewarrior
└── on-modify_track-total-active-time

1 directory, 5 files
```

### V3
```
$ tree ~/.config/task/hooks
/nix/store/qicdpkw69wzp8gxi52i73h4ddaqy5k14-mk-taskwarrior-hooks
├── on-add-v3_enforce-projects
├── on-add-v3_sync-git-repos
├── on-modify-v3_sync-git-repos-mod
├── on-modify-v3_track-timewarrior
└── on-modify-v3_track-total-active-time

1 directory, 5 files
```

This could also be used to have a hook API version per type, but that seems to be
irrelevant for now.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.