Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ENV var to skip check if pre-commit hooks are installed #58

Merged
merged 2 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ and this project adheres to [Semantic Versioning][].
### Fixes
- Remove vendored `hiyapyco` code since required changes were released upstream in v0.7.0 ([#45](https://github.com/Boehringer-Ingelheim/dso/pull/45)).
- `None` values in `params.in.yaml` can now be used to override anything, e.g. to disable watermarking only in a specific stage ([#45](https://github.com/Boehringer-Ingelheim/dso/pull/45)).
- DSO now respects a `DSO_SKIP_CHECK_ASK_PRE_COMMIT` environment variable. If it is set
to anything that evaluates as `True`, we skip the check if pre-commit is installed. This was a
requirement introduced by the R API package, see [#50](https://github.com/Boehringer-Ingelheim/dso/issues/50) ([#58](https://github.com/Boehringer-Ingelheim/dso/pull/58)).

## v0.9.0

Expand Down
7 changes: 7 additions & 0 deletions src/dso/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from functools import cache
from importlib import resources
from importlib.abc import Traversable
from os import environ
from pathlib import Path
from typing import Literal

Expand Down Expand Up @@ -205,7 +206,13 @@ def check_ask_pre_commit(dir: Path):
Check if pre-commit hooks are installed and asks to install them

If the user declines, info will be written to `.dso.json` to not ask again in the future.

Additionally, we respect a `DSO_SKIP_CHECK_ASK_PRE_COMMIT` environment variable. If it is set
to anything that evaluates as `True`, we skip the check and question altogether. This was a
requirement introduced by the R API package: https://github.com/Boehringer-Ingelheim/dso/issues/50.
"""
if environ.get("DSO_SKIP_CHECK_ASK_PRE_COMMIT", None):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alternatively could if not environ.get("DSO_SKIP_CHECK_ASK_PRE_COMMIT", None): to avoid break return, but tbh this is the same

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think as a check at the beginning of a function it's quite readable... somewhere within a code block it would be a different story.

return
config = _read_dot_dso_json(dir)
if config.get("check_ask_pre_commit", True):
project_root = get_project_root(dir)
Expand Down
Loading