Skip to content
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
9 changes: 8 additions & 1 deletion mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ description = "Run tests with coverage"
alias = "t"
run = "coverage run -m pytest . && coverage report -m && coverage xml"

[tasks.audit]
description = "Audit dependencies for vulnerabilities"
run = "pip-audit"

[tasks.verify]
description = "Run all verification checks"
depends = ["lint", "test", "audit"]

[tasks.all]
description = "Full setup from scratch"
depends = ["install", "lint", "test"]
Expand Down Expand Up @@ -94,4 +102,3 @@ run = "app"
[tasks.init]
description = "Initialize project (run once)"
run = "init"

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ dev = [
"coverage>=7.15.3",
"pre-commit>=4.6.1",
"pyright>=1.1.411",
"pip-audit>=2.10.1",
]
docs = [
"mkdocs>=1.6.1",
Expand Down Expand Up @@ -57,4 +58,3 @@ reportMissingImports = "error"
[tool.pytest.ini_options]
testpaths = ["tests"]
addopts = "-ra -q"

2 changes: 2 additions & 0 deletions scripts/init.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import re
import shutil
from functools import lru_cache
from pathlib import Path
from subprocess import CalledProcessError, TimeoutExpired, check_output

Expand Down Expand Up @@ -64,6 +65,7 @@ def _get_git_config(key: str) -> str:
return ""


@lru_cache(maxsize=1)
def _get_default_github() -> str:
# Try git config first
username = _get_git_config("github.user") or _get_git_config("user.name")
Expand Down
6 changes: 6 additions & 0 deletions tests/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,16 @@ def mock_check_output(args, **kwargs):


def test_get_default_github(monkeypatch):
# Clear lru_cache on _get_default_github before testing
init._get_default_github.cache_clear()

# Case 1: valid username in git config
monkeypatch.setattr(init, "_git_config_loaded", True)
monkeypatch.setattr(init, "_git_config_cache", {"github.user": "jane-doe"})
assert init._get_default_github() == "jane-doe"

# Case 2: invalid username in git config, fallback to remote URL (HTTPS format)
init._get_default_github.cache_clear()
monkeypatch.setattr(init, "_git_config_cache", {})

def mock_check_output(args, **kwargs):
Expand All @@ -84,6 +88,8 @@ def mock_check_output(args, **kwargs):
assert init._get_default_github() == "some-org"

# Case 3: invalid username in git config, fallback to remote URL (SSH format)
init._get_default_github.cache_clear()

def mock_check_output_ssh(args, **kwargs):
if "remote" in args and "get-url" in args:
return "git@github.com:ssh-user/some-repo.git\n"
Expand Down
Loading
Loading