mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-03 23:06:49 +01:00
Git - Add "Checkout" action to graph (#237734)
This commit is contained in:
@@ -2545,13 +2545,28 @@ export class CommandCenter {
|
||||
}
|
||||
|
||||
@command('git.checkoutRef', { repository: true })
|
||||
async checkoutRef(repository: Repository, historyItem?: SourceControlHistoryItem, historyItemRefId?: string): Promise<boolean> {
|
||||
async checkoutRef(repository: Repository, historyItem?: SourceControlHistoryItem, historyItemRefId?: string): Promise<void> {
|
||||
const historyItemRef = historyItem?.references?.find(r => r.id === historyItemRefId);
|
||||
if (!historyItemRef) {
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
return this._checkout(repository, { treeish: historyItemRefId });
|
||||
const config = workspace.getConfiguration('git', Uri.file(repository.root));
|
||||
const pullBeforeCheckout = config.get<boolean>('pullBeforeCheckout', false) === true;
|
||||
|
||||
// Branch, tag
|
||||
if (historyItemRef.id.startsWith('refs/heads/') || historyItemRef.id.startsWith('refs/tags/')) {
|
||||
await repository.checkout(historyItemRef.name, { pullBeforeCheckout });
|
||||
return;
|
||||
}
|
||||
|
||||
// Remote branch
|
||||
const branches = await repository.findTrackingBranches(historyItemRef.name);
|
||||
if (branches.length > 0) {
|
||||
await repository.checkout(branches[0].name!, { pullBeforeCheckout });
|
||||
} else {
|
||||
await repository.checkoutTracking(historyItemRef.name);
|
||||
}
|
||||
}
|
||||
|
||||
@command('git.checkoutRefDetached', { repository: true })
|
||||
|
||||
Reference in New Issue
Block a user