diff options
author | Ben Mares <15216687+maresb@users.noreply.github.com> | 2021-03-27 04:44:49 -0400 |
---|---|---|
committer | sqla-tester <sqla-tester@sqlalchemy.org> | 2021-03-27 04:44:49 -0400 |
commit | d4146eceb4258ab5a4af9fa6c711e6677e19e91b (patch) | |
tree | 3ea27ddca4897927d6124bd0a7818ed61a83eefe /docs/build/tutorial.rst | |
parent | 8043d5d2b46a2d12e445c8d352d0249447340613 (diff) | |
download | alembic-d4146eceb4258ab5a4af9fa6c711e6677e19e91b.tar.gz |
Add REVISION_SCRIPT_FILENAME token for post_write_hooks options
I include a token called `REVISION_SCRIPT_FILENAME` which can be used in the `options` setting of a post-write hook. This token is replaced by the filename of the revision script, allowing the filename to be passed to the post-write hook in a flexible manner. Thus I 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
```
Note that the existing behavior is to prepend `REVISION_SCRIPT_FILENAME` to the argument list. In order to preserve backwards compatibility, this is done when `REVISION_SCRIPT_FILENAME` is not present.
### Description
* Implement the `REVISION_SCRIPT_FILENAME` token.
* Switch from `str.split()` to `shlex.split()` for robust command line argument processing.
* Insert `REVISION_SCRIPT_FILENAME` in appropriate locations in the docs and templates.
* Properly document that `REVISION_SCRIPT_FILENAME` is prepended instead of appended to the argument list.
* Refactored existing "test of `black` as a post-write hook" in order to avoid code duplication.
* Add a test for `REVISION_SCRIPT_FILENAME` and shlex.
### 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:
- [X] A new feature implementation
- please include the issue number, and create an issue if none exists, which must
include a complete example of how the feature would look.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests.
Fixes issue #819
Closes: #820
Pull-request: https://github.com/sqlalchemy/alembic/pull/820
Pull-request-sha: 73dd0a4d60758a06551a0aff47b9723b0345d74a
Change-Id: Ibfc677d59086703872d7cfd5c2da32bd0220a25f
Diffstat (limited to 'docs/build/tutorial.rst')
-rw-r--r-- | docs/build/tutorial.rst | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/docs/build/tutorial.rst b/docs/build/tutorial.rst index 54da111..2ef8419 100644 --- a/docs/build/tutorial.rst +++ b/docs/build/tutorial.rst @@ -173,10 +173,10 @@ The file generated with the "generic" configuration looks like:: # format using "black" - use the console_scripts runner, # against the "black" entrypoint - # hooks=black - # black.type=console_scripts - # black.entrypoint=black - # black.options=-l 79 + # hooks = black + # black.type = console_scripts + # black.entrypoint = black + # black.options = -l 79 REVISION_SCRIPT_FILENAME # Logging configuration [loggers] |