Skip to content

Adds initial support for recomposing commits from a branch#4713

Merged
ramin-t merged 5 commits intomainfrom
feature/recompose-branch
Nov 6, 2025
Merged

Adds initial support for recomposing commits from a branch#4713
ramin-t merged 5 commits intomainfrom
feature/recompose-branch

Conversation

@ramin-t
Copy link
Contributor

@ramin-t ramin-t commented Oct 21, 2025

Closes #4598
Closes #4599

New command is Recompose Commits (Preview) and is accessible from branches in views and graph, and from Command Palette.

@ramin-t ramin-t requested review from d13 and eamodio October 21, 2025 22:33
@ramin-t ramin-t added the area-composer Issues or features related to Commit Composer label Oct 21, 2025
@ramin-t
Copy link
Contributor Author

ramin-t commented Oct 21, 2025

Note: we have a bug with storing merge bases for branches at the moment (we are choosing the upstream rather than the upstream's merge base) which causes the composer to find no diff when you make a local branch from a remote one. I will address this separately and rebase this on top of it once it is addressed.

@ramin-t ramin-t force-pushed the feature/recompose-branch branch from 8561a88 to 7c9fab4 Compare October 24, 2025 18:15
@ramin-t ramin-t force-pushed the feature/recompose-branch branch from 099b6f0 to 07bf736 Compare November 3, 2025 15:55
@ramin-t
Copy link
Contributor Author

ramin-t commented Nov 3, 2025

Note: we have a bug with storing merge bases for branches at the moment (we are choosing the upstream rather than the upstream's merge base) which causes the composer to find no diff when you make a local branch from a remote one. I will address this separately and rebase this on top of it once it is addressed.

It was not a bug. It looked for the upstream only when the local wasn't available. But that logic wasn't working well in several cases (it would return zero commit responses), so I just used recursive merge target look-up until we find one with commits.

Comment on lines +646 to +660
export function parseCoAuthorsFromGitCommit(commit: GitCommit): GitCommitIdentityShape[] {
const coAuthors: GitCommitIdentityShape[] = [];
if (!commit.message) return coAuthors;

const coAuthorRegex = /^Co-authored-by:\s*(.+?)(?:\s*<(.+?)>)?\s*$/gm;
let match;
while ((match = coAuthorRegex.exec(commit.message)) !== null) {
const [, name, email] = match;
if (name) {
coAuthors.push({ name: name.trim(), email: email?.trim(), date: commit.date });
}
}

return coAuthors;
}
Copy link
Member

Choose a reason for hiding this comment

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

This will be great to add in other commit authorship/avatar content throughout GitLens.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will make a note to pull it into a shared util file later. Thanks!

Copy link
Member

@d13 d13 left a comment

Choose a reason for hiding this comment

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

LGTM

@ramin-t ramin-t force-pushed the feature/recompose-branch branch from 07bf736 to 12b86ff Compare November 6, 2025 15:25
@ramin-t ramin-t merged commit b85bba6 into main Nov 6, 2025
4 checks passed
@ramin-t ramin-t deleted the feature/recompose-branch branch November 6, 2025 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-composer Issues or features related to Commit Composer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow existing commits to be auto-recomposed with AI Recompose an entire branch in Composer

3 participants