Skip to content

feat(backend): parse and fetch single-commit metadata (#2090) - #2113

Draft
felipebergamin wants to merge 5 commits into
kernelci:mainfrom
profusion:feat/2090/commit-metadata-fetch
Draft

felipebergamin wants to merge 5 commits into
kernelci:mainfrom
profusion:feat/2090/commit-metadata-fetch

Conversation

@felipebergamin

Copy link
Copy Markdown
Member

Summary

  • SHA-only library: (hash, url?) → commit metadata or a typed error. No DB writes.
  • parse_commit / parse_commit_object work on an existing repo path so the mirrored-tree sync job ([#2079] Sync mirrored trees into commits #2109) can reuse parsing.
  • One-shot fetch uses a throwaway bare repo on 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.
  • If no URL is passed, pick one from checkouts (prefer maestro / git.kernel.org). Malformed URLs do not crash.

Stacked on #2106 (commits / commit_parents schema). This is not the fill path for commits.

Closes #2090

Test plan

  • pytest backend/kernelCI_app/tests/unitTests/helpers/gitCommit_test.py -n0 --reruns 0
  • Fixture parse: author, committer, subject, ordered parents (first parent first)
  • Parse against a pre-existing repo path with no git fetch
  • Fetch failure, oversized / full pack, and bad URL raise typed errors and wipe the scratch repo

* 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>
…ci#2089)

Keep commits rows narrow: unique git name/email in commit_identity, subject plus UTF-8 body in commit_message as bytea. update_db dumps and restores the new tables and still accepts a flat legacy commits CSV.
Comment thread backend/kernelCI_app/tests/unitTests/helpers/gitCommit_test.py Outdated
"""Read one commit from an existing repo. Does not fetch."""
try:
full_hash = (
_git(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have we considered using pygit2 or GitPython?

kernel_org = "git.kernel.org" in host
maestro = origin == "maestro"
if maestro and kernel_org:
tier = 0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what exactly are those tiers?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what exactly are those tiers?

They’re a priority rank for which checkout URL to use when a SHA has more than one git_repository_url.

I have updated the docstring to make this clearer and will update the docs/sync-commits.md in #2118

Comment thread backend/kernelCI_app/helpers/gitCommit.py Outdated
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>
- Move fetch timeout and max pack size to Django settings
  (GIT_FETCH_TIMEOUT_SECONDS, GIT_FETCH_MAX_PACK_BYTES)
- Document URL preference tiers and why the git CLI is used
- Reuse author/committer constants in tests
@felipebergamin
felipebergamin force-pushed the feat/2090/commit-metadata-fetch branch from acee39a to a4fb0ae Compare September 25, 2026 20:39

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[#2079] Fetch commit metadata via SHA-only partial clone on tmpfs

2 participants