feat(dist-git): Construct dist-git with lock file history#121
feat(dist-git): Construct dist-git with lock file history#121Tonisal-byte wants to merge 3 commits intomicrosoft:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR changes synthetic dist-git history generation to derive synthetic commits from project lock file history (based on input-fingerprint changes) rather than scanning project commit messages for Affects: <component> trailers.
Changes:
- Add a
git.RunInDirhelper to executegit -C <dir> ...via the repo command factory. - Rework
synthistoryto discoverFingerprintChangeentries by reading lock files from project git history and to rebuild dist-git history with interleaved upstream/synthetic commits. - Update source preparation to pass a
CmdFactoryfor git-based fingerprint detection and adjust call sites accordingly.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/utils/git/git.go | Adds RunInDir helper for running git commands in a specific directory. |
| internal/app/azldev/core/sources/synthistory.go | Implements lock-file fingerprint change detection and interleaved dist-git history replay. |
| internal/app/azldev/core/sources/sourceprep.go | Switches synthetic history support to require a CmdFactory for git operations. |
| internal/app/azldev/core/sources/synthistory_test.go | Replaces Affects-trailer tests with tests for lock-path, interleaving, orphan handling, and metadata parsing. |
| internal/app/azldev/cmds/component/render.go | Updates WithGitRepo call to pass env as the command factory. |
| internal/app/azldev/cmds/component/preparesources.go | Updates WithGitRepo call to pass env as the command factory. |
| internal/app/azldev/cmds/component/build.go | Updates WithGitRepo call to pass env as the command factory. |
d0b1ece to
3e294ed
Compare
3e294ed to
1dd6506
Compare
1dd6506 to
cd67e7a
Compare
| // gitLogFileMetadata returns commit metadata (newest-first) for all commits | ||
| // that touched the given file path in the repository at repoDir. Fields within | ||
| // each record are separated by NUL (\x00); records are separated by SOH (\x01). | ||
| func gitLogFileMetadata( | ||
| ctx context.Context, cmdFactory opctx.CmdFactory, repoDir, filePath string, | ||
| ) ([]CommitMetadata, error) { | ||
| output, err := git.RunInDir(ctx, cmdFactory, repoDir, | ||
| "log", "--format=%H%x00%an%x00%ae%x00%at%x00%s%x01", "--", filePath) |
There was a problem hiding this comment.
CommitMetadata is documented as “full metadata for a commit”, but the Message field is populated from %s (subject only), not the full message/body. This is an externally visible behavioral change from the previous go-git implementation that used the full commit message (and it affects what ends up in synthetic commit messages). Either: (1) switch to %B (or another full-message pretty format) and adjust parsing/record separation accordingly, or (2) rename the field to Subject / update docstrings and downstream formatting to make “subject-only” explicit.
| // lockDir is the lock file directory relative to the project repository | ||
| // root. Used to locate lock files for fingerprint change detection in | ||
| // synthetic history generation. Set via [WithGitRepo]. | ||
| lockDir string |
There was a problem hiding this comment.
Could this be a LockReader, and we add some extra functions to the interface (like get path, etc.).
There was a problem hiding this comment.
Chatted offline, moving this to another PR
| config := component.GetConfig() | ||
| componentName := component.GetName() | ||
|
|
||
| lockRelPath, err := lockfile.LockPath(p.lockDir, componentName) |
There was a problem hiding this comment.
less ciritical, but if we have a store, we could use that to also get this data with a new func. This works as is though.
| return nil, fmt.Errorf("failed to read lock file %#q at HEAD:\n%w", | ||
| lockFileRelPath, lockFileErr) | ||
| } | ||
|
|
There was a problem hiding this comment.
for future PR: We should gracefully fall back to a placeholder commit ("Uncommited changes") or something liike that. That will allow devs to iterate more easily.
Replaces the Affects: commit trailer approach for synthetic dist-git history with lock file fingerprint change detection. Instead of scanning commit messages for
Affects: <component>lines, synthetic commits are now derived from changes to a component'sinput-fingerprintfield in its lock file (specs///.lock).