Переглянути джерело

Fixes #1361 - no longer needs an opened repo

main
Eric Amodio 3 роки тому
джерело
коміт
eab65f576f
2 змінених файлів з 22 додано та 24 видалено
  1. +1
    -0
      CHANGELOG.md
  2. +21
    -24
      src/webviews/rebaseEditor.ts

+ 1
- 0
CHANGELOG.md Переглянути файл

@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
### Fixed
- Fixes [#1361](https://github.com/eamodio/vscode-gitlens/issues/1361) - Interactive rebase editor fails when opened in a VS Code window that doesn't have the repository opened
- Fixes [#1357](https://github.com/eamodio/vscode-gitlens/issues/1357) - Branch sorting may be reversed — thanks to [PR #1358](https://github.com/eamodio/vscode-gitlens/pull/1358) by sueka ([@sueka](https://github.com/sueka))
## [11.2.0] - 2021-02-02

+ 21
- 24
src/webviews/rebaseEditor.ts Переглянути файл

@ -19,10 +19,10 @@ import { ShowQuickCommitCommand } from '../commands';
import { configuration } from '../configuration';
import { BuiltInCommands } from '../constants';
import { Container } from '../container';
import { Repository, RepositoryChange, RepositoryChangeComparisonMode } from '../git/git';
import { RepositoryChange, RepositoryChangeComparisonMode } from '../git/git';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { debug, gate, Iterables } from '../system';
import { debug, gate, Iterables, Strings } from '../system';
import {
Author,
Commit,
@ -86,7 +86,7 @@ interface RebaseEditorContext {
readonly id: number;
readonly document: TextDocument;
readonly panel: WebviewPanel;
readonly repo: Repository;
readonly repoPath: string;
readonly subscriptions: Disposable[];
abortOnClose: boolean;
@ -172,7 +172,8 @@ export class RebaseEditorProvider implements CustomTextEditorProvider, Disposabl
@debug<RebaseEditorProvider['resolveCustomTextEditor']>({ args: false })
async resolveCustomTextEditor(document: TextDocument, panel: WebviewPanel, _token: CancellationToken) {
const repo = await this.getRepository(document);
const repoPath = Strings.normalizePath(Uri.joinPath(document.uri, '..', '..', '..').fsPath);
const repo = await Container.git.getRepository(repoPath);
const subscriptions: Disposable[] = [];
const context: RebaseEditorContext = {
@ -182,7 +183,7 @@ export class RebaseEditorProvider implements CustomTextEditorProvider, Disposabl
subscriptions: subscriptions,
document: document,
panel: panel,
repo: repo,
repoPath: repo?.path ?? repoPath,
abortOnClose: true,
};
@ -210,13 +211,18 @@ export class RebaseEditorProvider implements CustomTextEditorProvider, Disposabl
void this.getStateAndNotify(context);
}),
repo.onDidChange(e => {
if (!e.changed(RepositoryChange.Rebase, RepositoryChangeComparisonMode.Any)) return;
void this.getStateAndNotify(context);
}),
);
if (repo != null) {
subscriptions.push(
repo.onDidChange(e => {
if (!e.changed(RepositoryChange.Rebase, RepositoryChangeComparisonMode.Any)) return;
void this.getStateAndNotify(context);
}),
);
}
panel.webview.options = { enableCommandUris: true, enableScripts: true };
panel.webview.html = await this.getHtml(context);
@ -243,8 +249,8 @@ export class RebaseEditorProvider implements CustomTextEditorProvider, Disposabl
}
private async parseState(context: RebaseEditorContext): Promise<RebaseState> {
const branch = await context.repo.getBranch();
const state = await parseRebaseTodo(context.document.getText(), context.repo, branch?.name);
const branch = await Container.git.getBranch(context.repoPath);
const state = await parseRebaseTodo(context.document.getText(), context.repoPath, branch?.name);
return state;
}
@ -493,20 +499,11 @@ export class RebaseEditorProvider implements CustomTextEditorProvider, Disposabl
return html;
}
private async getRepository(document: TextDocument): Promise<Repository> {
const repo = await Container.git.getRepository(Uri.joinPath(document.uri, '..', '..', '..'));
if (repo == null) {
// eslint-disable-next-line no-debugger
debugger;
}
return repo!;
}
}
async function parseRebaseTodo(
contents: string | { entries: RebaseEntry[]; onto: string },
repo: Repository,
repoPath: string,
branch: string | undefined,
): Promise<Omit<RebaseState, 'rebasing'>> {
let onto: string;
@ -521,7 +518,7 @@ async function parseRebaseTodo(
const authors = new Map<string, Author>();
const commits: Commit[] = [];
const log = await repo.searchForCommits({
const log = await Container.git.getLogForSearch(repoPath, {
pattern: `${onto ? `#:${onto} ` : ''}${Iterables.join(
Iterables.map(entries, e => `#:${e.ref}`),
' ',
@ -587,7 +584,7 @@ async function parseRebaseTodo(
commits: commits,
commands: {
// eslint-disable-next-line no-template-curly-in-string
commit: ShowQuickCommitCommand.getMarkdownCommandArgs('${commit}', repo.path),
commit: ShowQuickCommitCommand.getMarkdownCommandArgs('${commit}', repoPath),
},
};
}

Завантаження…
Відмінити
Зберегти