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

fix: disable for Git deps #8

Merged
merged 10 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
matrix:
python-version: ["3.10", "3.11", "3.12"]
# Empty is latest, head is latest from GitHub
pdm-version: ["", "head", "2.7.4", "2.8.0", "2.8.1", "2.8.2"]
pdm-version: ["", "head", "2.7.4", "2.8.0", "2.8.1", "2.8.2", "2.9.3"]

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -80,7 +80,7 @@ jobs:
pdm run lint-mypy
- name: Lint with ruff
run: |
pdm run lint-ruff --format=github --exit-non-zero-on-fix
pdm run lint-ruff --output-format=github --exit-non-zero-on-fix
- name: Build with pdm
run: |
pdm build
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ jobs:
id-token: write

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: pdm-project/setup-pdm@v3
- name: Publish package distributions to PyPI
run: pdm publish
- uses: actions/upload-artifact@v3
with:
name: dist
path: ./dist/*.whl
# XXX Upload files to GitHub Release
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ default_language_version:
python: python3.11
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-toml
- id: trailing-whitespace
Expand All @@ -15,11 +15,11 @@ repos:
- id: fix-byte-order-marker

- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.9.0
rev: 23.10.1
hooks:
- id: black

- rev: v0.0.287
- rev: v0.1.3
repo: https://github.com/astral-sh/ruff-pre-commit
hooks:
- id: ruff
Expand Down
4 changes: 2 additions & 2 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pdm 2.8.2
python 3.11.5
pdm 2.10.0
python 3.11.6
755 changes: 411 additions & 344 deletions pdm.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ extend-ignore =["S101"]
target-version = "py310"

[tool.mypy]
files = ["src"]
strict = true

[[tool.mypy.overrides]]
Expand Down
2 changes: 1 addition & 1 deletion src/sync_pre_commit_lock/actions/install_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def _get_git_directory_path(self) -> Path | None:
stderr=subprocess.PIPE,
)
return Path(result.decode().strip()) / ".git"
except (subprocess.CalledProcessError,) as exc:
except subprocess.CalledProcessError as exc:
self.printer.debug("Failed to get git root directory.")
self.printer.debug(f"Git command stderr: {exc.stderr.decode()}")
return None
Expand Down
8 changes: 8 additions & 0 deletions src/sync_pre_commit_lock/actions/sync_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,14 @@ def analyze_repos(
)
continue

if "+" in dependency_locked.version:
self.printer.debug(
f"Pre-commit hook {pre_commit_repo.repo} has a mapping to Python package `{dependency_name}`, "
f"but is skipped because the locked version `{dependency_locked.version}` contaims a `+`, "
"which is a local version identifier."
)
continue

new_ver = self.get_pre_commit_repo_new_version(pre_commit_repo, dependency, dependency_locked)
if new_ver:
to_fix[pre_commit_repo] = new_ver
Expand Down
4 changes: 4 additions & 0 deletions src/sync_pre_commit_lock/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ class RepoInfo(TypedDict):
"repo": "https://github.com/regebro/pyroma",
"rev": "${rev}",
},
"yamllint": {
"repo": "https://github.com/adrienverge/yamllint",
"rev": "v${rev}",
},
}

REPOSITORY_ALIASES: dict[str, tuple[str, ...]] = {
Expand Down
23 changes: 23 additions & 0 deletions tests/test_actions/test_sync_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,3 +359,26 @@ def test_analyze_repos_no_new_version() -> None:
result, _ = syncer.analyze_repos(pre_commit_repos, mapping, mapping_reverse_by_url)

assert result == {}


def test_analyze_repos_local() -> None:
printer = MagicMock(spec=Printer)
pre_commit_config_file_path = MagicMock(spec=Path)
locked_packages: dict[str, GenericLockedPackage] = {"lib_name": MagicMock(version="0.1.1+dev")}
plugin_config = MagicMock(spec=SyncPreCommitLockConfig)
plugin_config.ignore = []

syncer = SyncPreCommitHooksVersion(
printer=printer,
pre_commit_config_file_path=pre_commit_config_file_path,
locked_packages=locked_packages,
plugin_config=plugin_config,
)

pre_commit_repos = {PreCommitRepo("repo_url", "1.2.3")}
mapping = {"lib_name": RepoInfo(repo="repo_url", rev="${rev}")}
mapping_reverse_by_url = {"repo_url": "lib_name"}

result, _ = syncer.analyze_repos(pre_commit_repos, mapping, mapping_reverse_by_url)

assert result == {}
Loading