read REBASE_HEAD when rebasing, swap yours/theirs (label, sides) as well (#155208)

https://github.com/microsoft/vscode/issues/153737
This commit is contained in:
Johannes Rieken
2022-07-14 18:23:44 +02:00
committed by GitHub
parent 0abc5761ca
commit 1878583319
+9 -5
View File
@@ -418,6 +418,7 @@ export class CommandCenter {
return;
}
const isRebasing = Boolean(repo.rebaseCommit);
type InputData = { uri: Uri; title?: string; detail?: string; description?: string };
const mergeUris = toMergeUris(uri);
@@ -425,14 +426,17 @@ export class CommandCenter {
const theirs: InputData = { uri: mergeUris.theirs, title: localize('Theirs', 'Theirs') };
try {
const [head, mergeHead] = await Promise.all([repo.getCommit('HEAD'), repo.getCommit('MERGE_HEAD')]);
const [head, rebaseOrMergeHead] = await Promise.all([
repo.getCommit('HEAD'),
isRebasing ? repo.getCommit('REBASE_HEAD') : repo.getCommit('MERGE_HEAD')
]);
// ours (current branch and commit)
ours.detail = head.refNames.map(s => s.replace(/^HEAD ->/, '')).join(', ');
ours.description = head.hash.substring(0, 7);
// theirs
theirs.detail = mergeHead.refNames.join(', ');
theirs.description = mergeHead.hash.substring(0, 7);
theirs.detail = rebaseOrMergeHead.refNames.join(', ');
theirs.description = rebaseOrMergeHead.hash.substring(0, 7);
} catch (error) {
// not so bad, can continue with just uris
@@ -442,8 +446,8 @@ export class CommandCenter {
const options = {
base: mergeUris.base,
input1: theirs,
input2: ours,
input1: isRebasing ? ours : theirs,
input2: isRebasing ? theirs : ours,
output: uri
};