feat(backend): parse and fetch single-commit metadata (#2090) - #2113
Draft
felipebergamin wants to merge 3 commits into
Draft
felipebergamin wants to merge 3 commits into
felipebergamin wants to merge 3 commits into
Conversation
* Add `Commits` model: unique `git_commit_hash`, nullable author/committer/subject/message/`fetched_from_url` * Add `CommitParents` model: FKs to `commits.id`, `ord` with 0 = first parent, unique `(commit_id, ord)` * Add migration `0021_commits_and_commit_parents` (`commits`, `commit_parents` tables and indexes) * Join from `checkouts.git_commit_hash` without new checkout columns Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi>
Dump commits and commit_parents in full so git ancestry survives restore. Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi>
Add a SHA-only helper for commit author/parents so later sync can reuse parsing without duplicating git format handling. Signed-off-by: Felipe Bergamin <felipebergamin@profusion.mobi>
alanpeixinho
approved these changes
Sep 24, 2026
| def _run_git(repo: Path, *args: str) -> str: | ||
| env = { | ||
| **os.environ, | ||
| "GIT_AUTHOR_NAME": "Alice Author", |
Contributor
There was a problem hiding this comment.
nit: would it be better to create a local constant for those values being reused?
| """Read one commit from an existing repo. Does not fetch.""" | ||
| try: | ||
| full_hash = ( | ||
| _git( |
Contributor
There was a problem hiding this comment.
Have we considered using pygit2 or GitPython?
| kernel_org = "git.kernel.org" in host | ||
| maestro = origin == "maestro" | ||
| if maestro and kernel_org: | ||
| tier = 0 |
Contributor
There was a problem hiding this comment.
what exactly are those tiers?
|
|
||
| from kernelCI_app.models import Checkouts | ||
|
|
||
| FETCH_TIMEOUT_SECONDS = 60 |
Contributor
There was a problem hiding this comment.
shouldnt we keep this as parameters, so the django settings can expose as config?
This branch has not been deployed
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
(hash, url?)→ commit metadata or a typed error. No DB writes.parse_commit/parse_commit_objectwork on an existing repo path so the mirrored-tree sync job ([#2079] Sync mirrored trees into commits #2109) can reuse parsing.GIT_SCRATCH_DIR(git fetch --no-tags --depth=1 --filter=tree:0), then wipes. Rejects oversized / treeful packs. Parent hashes come from the child object only.checkouts(prefer maestro / git.kernel.org). Malformed URLs do not crash.Stacked on #2106 (
commits/commit_parentsschema). This is not the fill path forcommits.Closes #2090
Test plan
pytest backend/kernelCI_app/tests/unitTests/helpers/gitCommit_test.py -n0 --reruns 0git fetch