diff options
| author | Claude <noreply@anthropic.com> | 2026-11-06 00:54:48 +0000 |
|---|---|---|
| committer | Claude <noreply@anthropic.com> | 2026-11-06 00:54:48 +0000 |
| commit | 7aba3deae3ff17d032c37e07d2929d1426b34278 (patch) | |
| tree | 9c482f9acda1599bd2f9bed95a6a46b75e634e80 /plugins/claude-security/scripts/lib/revision.py | |
| parent | 5472f5f56e0070feeeb464318b316714fe3e9105 (diff) | |
| parent | b8331dd69ab3e132bbf8cd6e89b5d8c1747e21b1 (diff) | |
Merge remote-tracking branch 'origin/main' into add-plugin/xcodeadd-plugin/xcode
Diffstat (limited to 'plugins/claude-security/scripts/lib/revision.py')
| -rw-r--r-- | plugins/claude-security/scripts/lib/revision.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/plugins/claude-security/scripts/lib/revision.py b/plugins/claude-security/scripts/lib/revision.py new file mode 100644 index 00000000..afe334e2 --- /dev/null +++ b/plugins/claude-security/scripts/lib/revision.py @@ -0,0 +1,28 @@ +"""The revision a scan records, and the `<base>..<commit>` range a change scan's revision names.""" + +from __future__ import annotations + +from typing import Literal, TypedDict + +from .strictjson import JsonMap, is_str + + +class Revision(TypedDict, total=False): + """What was scanned. `versioned` is always present; the rest when in git.""" + + versioned: bool + commit: str | None + parent: str | None + branch: str | None + dirty: bool | None + sparse: Literal[True] + not_checked_out_dirs: list[str] + base: str | None + merge_base: str | None + + +def change_range(revision: JsonMap) -> str | None: + """The `<base>..<commit>` range a change scan's revision names; None when it names no change.""" + base = revision.get("merge_base") or revision.get("parent") + commit = revision.get("commit") + return f"{base}..{commit}" if is_str(base) and is_str(commit) else None |
