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
1 change: 1 addition & 0 deletions diffgraph/schema/diffgraph-v2.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@
"invalid_head_ref",
"merge_base_failed",
"malformed_merge_base",
"ambiguous_merge_base",
"malformed_git_output",
"undecodable_path",
"missing_object_id",
Expand Down
1 change: 1 addition & 0 deletions diffgraph/structural.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"invalid_head_ref",
"merge_base_failed",
"malformed_merge_base",
"ambiguous_merge_base",
"malformed_git_output",
"undecodable_path",
"missing_object_id",
Expand Down
31 changes: 30 additions & 1 deletion tests/test_structural.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
import jsonschema
import pytest

from diffgraph.git_snapshot import GitSnapshotError, ResolutionWarning, SnapshotResolution
from diffgraph.git_snapshot import (
CommitRangeResolution,
GitSnapshotError,
ResolutionWarning,
SnapshotResolution,
)
from diffgraph.structural import analyze_local_diff

SCHEMA = json.loads((Path(__file__).parents[1] / "diffgraph/schema/diffgraph-v2.schema.json").read_text())
Expand Down Expand Up @@ -1098,6 +1103,30 @@ def test_resolution_warning_preserves_machine_readable_code(monkeypatch, tmp_pat
]


def test_ambiguous_merge_base_warning_is_not_downgraded(monkeypatch, tmp_path):
"""Three-dot ambiguity remains actionable for JSON consumers."""
root = repo(tmp_path)
warning = ResolutionWarning(
"ambiguous_merge_base", "Git returned 2 merge bases; choose a base", None
)
monkeypatch.setattr(
"diffgraph.structural.resolve_commit_range",
lambda *args, **kwargs: CommitRangeResolution(
(), (warning,), "left", "right", None, None, None, True
),
)

artifact = analyze_local_diff(
str(root), base_ref="left", head_ref="right", three_dot=True
)

assert_valid(artifact)
assert artifact["metadata"]["warnings"] == [{
"code": "ambiguous_merge_base",
"detail": "ambiguous_merge_base: Git returned 2 merge bases; choose a base",
}]


def test_undecodable_path_warning_is_schema_valid(monkeypatch, tmp_path):
root = repo(tmp_path)
warning = ResolutionWarning(
Expand Down
Loading