feat: support git revision syntax for spec paths#799
Merged
reuvenharrison merged 4 commits intomainfrom Mar 9, 2026
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #799 +/- ##
==========================================
+ Coverage 89.54% 89.57% +0.02%
==========================================
Files 239 239
Lines 12154 12179 +25
==========================================
+ Hits 10883 10909 +26
+ Misses 841 840 -1
Partials 430 430
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
3 tasks
Allow oasdiff to accept git revision specs like "origin/main:openapi.yaml" or "HEAD~1:spec.yaml" directly as base/revision arguments, without needing a separate "git show" step in CI workflows. NewSource() detects the <ref>:<path> pattern (excluding URLs with "://" and Windows drive letters) and categorises it as SourceTypeGitRevision. The loader runs "git show <ref>:<path>", writes the content to a temp file in the spec's directory (preserving relative $ref resolution), and loads from that file. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…g temp file Now that the Loader interface is gone (PR #800), use *openapi3.Loader directly and call LoadFromDataWithPath so relative $refs resolve against the spec path without needing a temporary file on disk. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
f9f95e1 to
fae321e
Compare
Document the new git revision syntax (<ref>:<path>) with usage examples, a reference table, explanation of how it works, and a GitHub Actions snippet. Update the README feature bullet to link to the new doc. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…n PATH Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SourceTypeGitRevisionto theloadpackage so that paths likeorigin/main:openapi.yamlorHEAD~1:spec.yamlare recognised nativelyNewSource()detects the<ref>:<path>pattern — excluded URLs (://) and Windows drive letters (single uppercase letter before:)loadFromGitRevision()runsgit show <ref>:<path>and loads the output viaLoadFromDataWithPath, passing the spec path as the URL so that relative$refs resolve correctly — no temp file neededMotivation
Previously, using oasdiff in GitHub Actions required an extra manual step:
After this change, the workflow collapses to:
Test plan
TestSource_IsGitRevision— detection of valid git revision patternsTestSource_IsNotGitRevision— non-git paths (files, URLs, Windows drive letters) are not misclassifiedTestLoadInfo_GitRevision— end-to-end: real git repo, committed spec, loaded viaHEAD:openapi.yamlTestLoadInfo_GitRevisionNotFound— clear error when ref or path doesn't exist./load/...test suite passes with no regressions🤖 Generated with Claude Code