From 7267191d5e5c6ed2c62c45ff4ec79b8135e6f95b Mon Sep 17 00:00:00 2001 From: jfishe Date: Mon, 12 Feb 2024 08:49:51 -0800 Subject: [PATCH] Add pre-commit manifest to simplify installing the pre-commit hook (Issue #7) (#14) --- .github/workflows/ci.yml | 6 +++--- .pre-commit-hooks.yaml | 18 ++++++++++++++++++ CHANGELOG.md | 12 ++++++++++++ README.md | 21 +++++++++++++++++---- 4 files changed, 50 insertions(+), 7 deletions(-) create mode 100644 .pre-commit-hooks.yaml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 23e9223..941e14c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,14 +10,14 @@ jobs: strategy: matrix: python-version: - - '2.7' - '3.7' - '3.8' - '3.9' - '3.10' + - '3.11' steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml new file mode 100644 index 0000000..294986c --- /dev/null +++ b/.pre-commit-hooks.yaml @@ -0,0 +1,18 @@ +- id: vimwiki-cli + name: Vimwiki Command-Line Interface + description: | + A pre-commit hook script to execute non-interactive vimwiki commands to + rebuild tag metadata and generate links before commit. This hook relies on + the following configuration options. + vimwiki.options -- Extra options to pass to the vimwiki command + vimwiki.linkspage -- Page which contains generated links + vimwiki.taglinkspage -- Page which contains generated tag links + vimwiki.generatelinks -- Generate links before commit (bool) + vimwiki.generatediarylinks -- Generate diary links before commit (bool) + vimwiki.generatetaglinks -- Generate tag links before commit (bool) + vimwiki.rebuildtags -- Rebuild tag metadata before commit (bool) + vimwiki.allhtml -- Convert wiki to HTML before commit (bool) + entry: scripts/pre-commit.sh + language: script + require_serial: true + types: [text] diff --git a/CHANGELOG.md b/CHANGELOG.md index 25e8457..91d1a9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- `pre-commit` hook `id: vimwiki-cli` to simplify installing `pre-commit.sh` + script ( + [Issue #7](https://github.com/sstallion/vimwiki-cli/issues/7#issue-876664886)) + +### Changed + +- Github Actions workflow `CI` removed python-2.7 and added python-3.11 because + `ubuntu-latest` dropped python-2.7 support. Updated `checkout` and + `setup-python` actions to latest versions. + ## [v1.1.0] - 2023-05-08 ### Added diff --git a/README.md b/README.md index d641049..e280ed0 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ variables are available to modify default behavior without the need to pass global options on the command line: | Environment Variable | Global Option | Description | -|------------------------|------------------|---------------------------------------------------| +| ---------------------- | ---------------- | ------------------------------------------------- | | `VIMWIKI_EDITOR` | `--editor` | Editor to launch, defaults to `$EDITOR` or `vim`. | | `VIMWIKI_COUNT` | `--count` | Index of wiki to open. | | `VIMWIKI_SELECT` | `--select` | Select wiki from interactive list. | @@ -43,7 +43,7 @@ Each CLI command corresponds to one or more Ex commands executed in the editor. The following table details the mapping between these commands: | CLI Command | Ex Commands | -|-----------------------------------------|---------------------------------------------------------------------| +| --------------------------------------- | ------------------------------------------------------------------- | | `vimwiki` | `:VimwikiIndex` | | `vimwiki all-html` | `:VimwikiIndex \| VimwikiAll2HTML` | | `vimwiki check-links` | `:VimwikiIndex \| VimwikiCheckLinks` | @@ -81,7 +81,7 @@ commit. The pre-commit hook relies on the following configuration options: | Configuration Option | Description | -|------------------------------|------------------------------------------------| +| ---------------------------- | ---------------------------------------------- | | `vimwiki.options` | Extra options to pass to the `vimwiki` command | | `vimwiki.linkspage` | Page which contains generated links | | `vimwiki.taglinkspage` | Page which contains generated tag links | @@ -99,7 +99,19 @@ links in the `Tags` page before commit, issue: $ git config vimwiki.rebuildtags true To enable the hook, copy or link [pre-commit.sh][6] to `.git/hooks/pre-commit` -in the wiki directory. +in the wiki directory. Alternatively, if [pre-commit][8] is installed, add a +`pre-commit` configuration file, `.pre-commit-config.yaml` and run +`pre-commit autoupdate` to enable the latest version of the hook. + +```yaml +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +repos: + - repo: https://github.com/sstallion/vimwiki-cli + rev: v1.1.0 + hooks: + - id: vimwiki-cli +``` ## Contributing @@ -117,3 +129,4 @@ Source code in this repository is licensed under a Simplified BSD License. See [5]: https://www.vim.org/ [6]: https://github.com/sstallion/vimwiki-cli/blob/master/scripts/pre-commit.sh [7]: https://github.com/sstallion/vimwiki-cli/blob/master/CONTRIBUTING.md +[8]: https://pre-commit.com/index