Skip to content

SCM - Include stashes in the SCM history graph#302315

Open
iumehara wants to merge 1 commit intomicrosoft:mainfrom
iumehara:scm-graph-stash
Open

SCM - Include stashes in the SCM history graph#302315
iumehara wants to merge 1 commit intomicrosoft:mainfrom
iumehara:scm-graph-stash

Conversation

@iumehara
Copy link
Contributor

For Issue #280264

Behavior:

  • Source Control Git graph now includes stashes in addition to remotes/branches and tags.
  • Stashes are displayed in the selector dropdown via historyProvider.provideHistoryItemRefs
  • Selected stashes (but not their index commits) are displayed in the graph via historyProvider.provideHistoryItems
  • onDidRunWriteOperation diff calculation includes change in stash history
  • Avoids potential race-condition in stashRef with @sequentialize decorator

Copilot AI review requested due to automatic review settings March 17, 2026 01:25
@vs-code-engineering
Copy link
Contributor

vs-code-engineering bot commented Mar 17, 2026

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

@lszomoru

Matched files:

  • extensions/git/src/historyProvider.ts
  • extensions/git/src/test/historyProvider.test.ts

Copy link
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

Adds stash awareness to the Git SCM history provider so stashes can appear as history refs, stash “index” commits are hidden from history results, and stash refs are attached to matching stash commits.

Changes:

  • Extend GitHistoryProvider to fetch/sync stash refs, include them in provideHistoryItemRefs, and attach stash refs to matching commits.
  • Filter out “index on …” stash index commits from provideHistoryItems results.
  • Add unit tests covering stash ref inclusion/sorting/error handling and stash-related history filtering/attachment behavior.

Reviewed changes

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

File Description
extensions/git/src/historyProvider.ts Adds stash ref syncing, stash commit filtering, and stash ref attachment to history items.
extensions/git/src/test/historyProvider.test.ts Introduces unit tests for stash refs and stash-related history item behavior.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +155 to +159
const updateComplete = new Promise<void>(resolve => {
gitHistoryProvider.onDidChangeCurrentHistoryItemRefs(() => resolve(), { dispose: () => { } });
});
onDidRunOperationEmitter.fire({ operation: { kind: 0 } });
await updateComplete;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Opted for { operation: { kind: OperationKind.Commit, readOnly: false, showProgress: false } } instead because,

  • OperationKind.Commit and OperationKind.Stash are the correct kinds of operation in this case
  • readOnly: true operations get filtered out in the constructor

Comment on lines +160 to +162

const historyItems = await gitHistoryProvider.provideHistoryItems({ historyItemRefs: ['refs/heads/main'] }, {} as CancellationToken);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unchanged, as CancellationToken is an interface, and the CancellationToken.None defined in the internal codebase is not exposed to the extension API.

];
mockRepository.log.resolves(commits);

const historyItems = await gitHistoryProvider.provideHistoryItems({ historyItemRefs: ['refs/heads/main'] }, {} as CancellationToken);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unchanged. CancellationToken is an interface, as explained in comment above

- historyProvider.provideHistoryItemRefs includes stashes
- historyProvider.provideHistoryItems includes stashes but not stash index commits
- onDidRunWriteOperation diff calculation includes change in stash history
- Avoid potential racecondition in stashRef with @sequentialize decorator
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