Skip to content

feat(dist-git): Construct dist-git with lock file history#121

Open
Tonisal-byte wants to merge 3 commits intomicrosoft:mainfrom
Tonisal-byte:asalinas/dist-git-2.0
Open

feat(dist-git): Construct dist-git with lock file history#121
Tonisal-byte wants to merge 3 commits intomicrosoft:mainfrom
Tonisal-byte:asalinas/dist-git-2.0

Conversation

@Tonisal-byte
Copy link
Copy Markdown
Contributor

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's input-fingerprint field in its lock file (specs///.lock).

Copilot AI review requested due to automatic review settings April 24, 2026 22:55
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.RunInDir helper to execute git -C <dir> ... via the repo command factory.
  • Rework synthistory to discover FingerprintChange entries 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 CmdFactory for 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.

Comment thread internal/app/azldev/core/sources/synthistory.go Outdated
Comment thread internal/app/azldev/core/sources/sourceprep.go
Comment thread internal/utils/git/git.go
Comment thread internal/app/azldev/core/sources/synthistory.go Outdated
Comment thread internal/app/azldev/core/sources/synthistory.go
Comment thread internal/app/azldev/core/sources/synthistory.go
Comment thread internal/app/azldev/core/sources/synthistory.go
Comment thread internal/app/azldev/core/sources/synthistory.go
@Tonisal-byte Tonisal-byte force-pushed the asalinas/dist-git-2.0 branch from d0b1ece to 3e294ed Compare April 27, 2026 23:34
@Tonisal-byte Tonisal-byte marked this pull request as ready for review April 27, 2026 23:35
Copilot AI review requested due to automatic review settings April 27, 2026 23:35
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Comment thread internal/app/azldev/core/sources/synthistory.go Outdated
Comment thread internal/app/azldev/core/sources/synthistory.go
Comment thread internal/utils/git/git.go Outdated
Comment thread internal/utils/git/git.go
@reubeno reubeno requested a review from dmcilvaney April 28, 2026 16:23
Comment thread internal/app/azldev/core/sources/synthistory.go Outdated
Comment thread internal/app/azldev/core/sources/synthistory.go Outdated
Comment thread internal/app/azldev/core/sources/synthistory.go Outdated
Comment thread internal/app/azldev/core/sources/synthistory.go Outdated
Comment thread internal/utils/git/git.go
Comment thread internal/app/azldev/core/sources/synthistory.go Outdated
Comment thread internal/app/azldev/core/sources/sourceprep.go
Comment thread internal/app/azldev/core/sources/synthistory.go
Comment thread internal/app/azldev/core/sources/synthistory.go Outdated
Comment thread internal/app/azldev/core/sources/synthistory.go Outdated
Comment thread internal/app/azldev/core/sources/synthistory.go
Comment thread internal/utils/git/git.go
Comment thread internal/app/azldev/cmds/component/render.go Outdated
@Tonisal-byte Tonisal-byte force-pushed the asalinas/dist-git-2.0 branch from 3e294ed to 1dd6506 Compare April 29, 2026 17:42
Copilot AI review requested due to automatic review settings April 29, 2026 18:04
@Tonisal-byte Tonisal-byte force-pushed the asalinas/dist-git-2.0 branch from 1dd6506 to cd67e7a Compare April 29, 2026 18:04
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.

Comment thread internal/app/azldev/core/sources/synthistory.go Outdated
Comment thread internal/app/azldev/cmds/component/component.go Outdated
Comment on lines +623 to +630
// 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)
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment thread internal/app/azldev/core/sources/synthistory.go Outdated
Comment thread internal/app/azldev/core/sources/synthistory.go
// 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
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.

Could this be a LockReader, and we add some extra functions to the interface (like get path, etc.).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Chatted offline, moving this to another PR

config := component.GetConfig()
componentName := component.GetName()

lockRelPath, err := lockfile.LockPath(p.lockDir, componentName)
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.

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.

Comment thread internal/app/azldev/core/sources/synthistory.go
Comment thread internal/app/azldev/cmds/component/component.go Outdated
Comment thread internal/app/azldev/core/sources/synthistory.go Outdated
Comment thread internal/app/azldev/core/sources/synthistory.go Outdated
Comment thread internal/app/azldev/core/sources/synthistory.go
Comment thread internal/app/azldev/cmds/component/component.go Outdated
Comment thread internal/app/azldev/core/sources/synthistory.go
Comment thread internal/app/azldev/cmds/component/component.go Outdated
return nil, fmt.Errorf("failed to read lock file %#q at HEAD:\n%w",
lockFileRelPath, lockFileErr)
}

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.

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.

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.

3 participants