ソースを参照

Closes #1201 - deal with bogus onto value

main
Eric Amodio 3年前
コミット
dd4a5a6db7
2個のファイルの変更40行の追加30行の削除
  1. +19
    -15
      src/webviews/apps/rebase/rebase.ts
  2. +21
    -15
      src/webviews/rebaseEditor.ts

+ 19
- 15
src/webviews/apps/rebase/rebase.ts ファイルの表示

@ -265,7 +265,9 @@ class RebaseEditor extends App {
const $subhead = document.getElementById('subhead')! as HTMLHeadingElement;
$subhead.innerHTML = `<span class="branch ml-1 mr-1">${state.branch}</span><span>Rebasing ${
state.entries.length
} commit${state.entries.length !== 1 ? 's' : ''} onto <span class="commit">${state.onto}</span>`;
} commit${state.entries.length !== 1 ? 's' : ''}${
state.onto ? ` onto <span class="commit">${state.onto}</span>` : ''
}</span>`;
const $container = document.getElementById('entries')!;
@ -320,20 +322,22 @@ class RebaseEditor extends App {
$container.appendChild($el);
}
const commit = state.commits.find(c => c.ref.startsWith(state.onto));
if (commit != null) {
const [$el] = this.createEntry(
{
action: undefined!,
index: 0,
message: commit.message.split('\n')[0],
ref: state.onto,
},
state,
++tabIndex,
);
$container.appendChild($el);
$container.classList.add('entries--base');
if (state.onto) {
const commit = state.commits.find(c => c.ref.startsWith(state.onto));
if (commit != null) {
const [$el] = this.createEntry(
{
action: undefined!,
index: 0,
message: commit.message.split('\n')[0],
ref: state.onto,
},
state,
++tabIndex,
);
$container.appendChild($el);
$container.classList.add('entries--base');
}
}
document

+ 21
- 15
src/webviews/rebaseEditor.ts ファイルの表示

@ -210,36 +210,42 @@ export class RebaseEditorProvider implements CustomTextEditorProvider, Disposabl
const contents = document.getText();
const entries = this.parseEntries(contents);
const [, , , onto] = rebaseRegex.exec(contents) ?? ['', '', ''];
let [, , , onto] = rebaseRegex.exec(contents) ?? ['', '', ''];
const authors = new Map<string, Author>();
const commits: Commit[] = [];
let commit = await Container.git.getCommit(repoPath!, onto);
if (commit != null) {
if (!authors.has(commit.author)) {
authors.set(commit.author, {
author: commit.author,
const ontoCommit = await Container.git.getCommit(repoPath!, onto);
if (ontoCommit != null) {
if (!authors.has(ontoCommit.author)) {
authors.set(ontoCommit.author, {
author: ontoCommit.author,
avatarUrl: (
await commit.getAvatarUri({ defaultStyle: Container.config.defaultGravatarsStyle })
await ontoCommit.getAvatarUri({ defaultStyle: Container.config.defaultGravatarsStyle })
).toString(true),
email: commit.email,
email: ontoCommit.email,
});
}
commits.push({
ref: commit.ref,
author: commit.author,
date: commit.formatDate(Container.config.defaultDateFormat),
dateFromNow: commit.formatDateFromNow(),
message: commit.message || 'root',
ref: ontoCommit.ref,
author: ontoCommit.author,
date: ontoCommit.formatDate(Container.config.defaultDateFormat),
dateFromNow: ontoCommit.formatDateFromNow(),
message: ontoCommit.message || 'root',
});
}
for (const entry of entries) {
commit = await Container.git.getCommit(repoPath!, entry.ref);
const commit = await Container.git.getCommit(repoPath!, entry.ref);
if (commit == null) continue;
// If the onto commit is contained in the list of commits, remove it and clear the 'onto' value — See #1201
if (commit.ref === ontoCommit?.ref) {
commits.splice(0, 1);
onto = '';
}
if (!authors.has(commit.author)) {
authors.set(commit.author, {
author: commit.author,
@ -261,7 +267,7 @@ export class RebaseEditorProvider implements CustomTextEditorProvider, Disposabl
return {
branch: branch?.name ?? '',
onto: onto ?? '',
onto: onto,
entries: entries,
authors: [...authors.values()],
commits: commits,

読み込み中…
キャンセル
保存