fix(ontology): read the ontology commit SHA from git metadata - #328
Merged
Conversation
Co-Authored-By: jason.han <jason.han@jpl.nasa.gov>
Author
Original prompt from jason.han
|
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Co-Authored-By: jason.han <jason.han@jpl.nasa.gov>
Co-Authored-By: jason.han <jason.han@jpl.nasa.gov>
Co-Authored-By: jason.han <jason.han@jpl.nasa.gov>
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
Clears the one SonarCloud finding on the upstream sync PR:
go:S4036("Make sure thePATHvariable only contains fixed, unwriteable directories") on the ontology table generator, which resolvedgitthroughPATH:Rather than pinning an absolute
gitpath,commitSHAnow reads the checkout's plumbing files directly, which removes the finding at its root and drops agitbinary dependency from a code generator:.git/HEAD→ symref → loose ref underrefs/, falling back topacked-refs(the case that actually matters, since a freshgit cloneusually has the branch packed and no loose ref), plus raw-SHA detached HEAD, a.gitfile containinggitdir:, and worktreecommondirfor where refs live.Every failure path returns a
*gitMetadataErrornaming the file it could not read, and the result must match^[0-9a-f]{40}$before it is returned — the generator printscommit[:12], so a short or garbage value would otherwise be recorded in the generated table (or panic the slice).internal/core/rdf/ontology/table.gois untouched and verified byte-identical tomain: the recorded SHA does not change here.Tests build the fixtures as temp directories and cover symref→loose, symref→packed, detached HEAD, the
gitdir:file, missingHEAD, and a malformed SHA.Verification:
go build ./...,go vet ./...,gofmt -l .(empty) and the fullgo test ./...all pass, includinginternal/core/model(the training-corpus gate).Link to Devin session: https://nasa-jpl-demo.devinenterprise.com/sessions/6eb85b61128b4de8bdcfd7991202ccdc
Requested by: @HuiJun