]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commit
Add cwd post-write hook option
authorBen Mares <15216687+maresb@users.noreply.github.com>
Mon, 29 Mar 2021 20:44:36 +0000 (16:44 -0400)
committersqla-tester <sqla-tester@sqlalchemy.org>
Mon, 29 Mar 2021 20:44:36 +0000 (16:44 -0400)
commite49691ef7e822ec24c2c733a1c442be9ba3cccda
treeffd0b33925169a615c7154e614fc1f4168536ff4
parentd4146eceb4258ab5a4af9fa6c711e6677e19e91b
Add cwd post-write hook option

Fixes #822

Implements a `.cwd` suboption for post-write hooks.

For example, one can do
```ini
[post_write_hooks]
hooks = pre-commit

pre-commit.type = console_scripts
pre-commit.entrypoint = pre-commit
pre-commit.options = run --files REVISION_SCRIPT_FILENAME
pre-commit.cwd = %(here)s
```

This feature is illustrated by the last line above.

### Description

* Improve the names of some variables recently created in #820 in order to make the code more readable.
* Add `cwd` as an option which is passed directly into `subprocess.run()`
* Add a brief description to the documentation, together with an example with `pre-commit`.
<!-- Describe your changes in detail -->

### Checklist
<!-- go over following points. check them with an `x` if they do apply, (they turn into clickable checkboxes once the PR is submitted, so no need to do everything at once)

-->

This pull request is:

A new feature implementation

- [X] please include the issue number, and create an issue if none exists, which must
- [X] include a complete example of how the feature would look.
- [X] Please include: `Fixes: #<issue number>` in the commit message
- [x] **please include tests.**

**Help requested:** I can't think of any simple way to write a test. Does anyone have a suggestion???

Closes: #823
Pull-request: https://github.com/sqlalchemy/alembic/pull/823
Pull-request-sha: 9a694a7fdfc55160d1e124f6119a7a5677ce019a

Change-Id: Iacbb06d52acc362588cff2cdfec442393be8594a
alembic/script/write_hooks.py
docs/build/autogenerate.rst
docs/build/unreleased/822.rst [new file with mode: 0644]
tests/test_post_write.py