mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-01-18 09:45:36 -05:00
Switches to use repoPath on GitService
This commit is contained in:
@@ -9,7 +9,7 @@ import * as path from 'path';
|
||||
|
||||
export class CloseUnchangedFilesCommand extends ActiveEditorCommand {
|
||||
|
||||
constructor(private git: GitService, private repoPath: string) {
|
||||
constructor(private git: GitService) {
|
||||
super(Commands.CloseUnchangedFiles);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ export class CloseUnchangedFilesCommand extends ActiveEditorCommand {
|
||||
|
||||
try {
|
||||
if (!uris) {
|
||||
const repoPath = await this.git.getRepoPathFromUri(uri, this.repoPath);
|
||||
const repoPath = await this.git.getRepoPathFromUri(uri, this.git.repoPath);
|
||||
if (!repoPath) return window.showWarningMessage(`Unable to close unchanged files`);
|
||||
|
||||
const status = await this.git.getStatusForRepo(repoPath);
|
||||
|
||||
@@ -8,7 +8,7 @@ import { copy } from 'copy-paste';
|
||||
|
||||
export class CopyMessageToClipboardCommand extends ActiveEditorCommand {
|
||||
|
||||
constructor(private git: GitService, private repoPath: string) {
|
||||
constructor(private git: GitService) {
|
||||
super(Commands.CopyMessageToClipboard);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ export class CopyMessageToClipboardCommand extends ActiveEditorCommand {
|
||||
try {
|
||||
// If we don't have an editor then get the message of the last commit to the branch
|
||||
if (!uri) {
|
||||
const log = await this.git.getLogForRepo(this.repoPath, undefined, 1);
|
||||
const log = await this.git.getLogForRepo(this.git.repoPath, undefined, 1);
|
||||
if (!log) return undefined;
|
||||
|
||||
message = Iterables.first(log.commits.values()).message;
|
||||
|
||||
@@ -8,7 +8,7 @@ import { copy } from 'copy-paste';
|
||||
|
||||
export class CopyShaToClipboardCommand extends ActiveEditorCommand {
|
||||
|
||||
constructor(private git: GitService, private repoPath: string) {
|
||||
constructor(private git: GitService) {
|
||||
super(Commands.CopyShaToClipboard);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ export class CopyShaToClipboardCommand extends ActiveEditorCommand {
|
||||
try {
|
||||
// If we don't have an editor then get the sha of the last commit to the branch
|
||||
if (!uri) {
|
||||
const log = await this.git.getLogForRepo(this.repoPath, undefined, 1);
|
||||
const log = await this.git.getLogForRepo(this.git.repoPath, undefined, 1);
|
||||
if (!log) return undefined;
|
||||
|
||||
sha = Iterables.first(log.commits.values()).sha;
|
||||
|
||||
@@ -8,7 +8,7 @@ import { CommandQuickPickItem, BranchesQuickPick } from '../quickPicks';
|
||||
|
||||
export class DiffDirectoryCommand extends ActiveEditorCommand {
|
||||
|
||||
constructor(private git: GitService, private repoPath: string) {
|
||||
constructor(private git: GitService) {
|
||||
super(Commands.DiffDirectory);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ export class DiffDirectoryCommand extends ActiveEditorCommand {
|
||||
}
|
||||
|
||||
try {
|
||||
const repoPath = await this.git.getRepoPathFromUri(uri, this.repoPath);
|
||||
const repoPath = await this.git.getRepoPathFromUri(uri, this.git.repoPath);
|
||||
if (!repoPath) return window.showWarningMessage(`Unable to open directory diff`);
|
||||
|
||||
if (!shaOrBranch1) {
|
||||
|
||||
@@ -7,7 +7,7 @@ import * as path from 'path';
|
||||
|
||||
export class OpenChangedFilesCommand extends ActiveEditorCommand {
|
||||
|
||||
constructor(private git: GitService, private repoPath: string) {
|
||||
constructor(private git: GitService) {
|
||||
super(Commands.OpenChangedFiles);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ export class OpenChangedFilesCommand extends ActiveEditorCommand {
|
||||
|
||||
try {
|
||||
if (!uris) {
|
||||
const repoPath = await this.git.getRepoPathFromUri(uri, this.repoPath);
|
||||
const repoPath = await this.git.getRepoPathFromUri(uri, this.git.repoPath);
|
||||
if (!repoPath) return window.showWarningMessage(`Unable to open changed files`);
|
||||
|
||||
const status = await this.git.getStatusForRepo(repoPath);
|
||||
|
||||
@@ -7,7 +7,7 @@ import { Logger } from '../logger';
|
||||
|
||||
export class OpenCommitInRemoteCommand extends ActiveEditorCommand {
|
||||
|
||||
constructor(private git: GitService, private repoPath: string) {
|
||||
constructor(private git: GitService) {
|
||||
super(Commands.OpenCommitInRemote);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ export class OpenCommitInRemoteCommand extends ActiveEditorCommand {
|
||||
commit = new GitCommit(commit.type, commit.repoPath, commit.previousSha, commit.previousFileName, commit.author, commit.date, commit.message);
|
||||
}
|
||||
|
||||
const remotes = Arrays.uniqueBy(await this.git.getRemotes(this.repoPath), _ => _.url, _ => !!_.provider);
|
||||
const remotes = Arrays.uniqueBy(await this.git.getRemotes(this.git.repoPath), _ => _.url, _ => !!_.provider);
|
||||
return commands.executeCommand(Commands.OpenInRemote, uri, remotes, 'commit', [commit.sha]);
|
||||
}
|
||||
catch (ex) {
|
||||
|
||||
@@ -7,7 +7,7 @@ import { Logger } from '../logger';
|
||||
|
||||
export class OpenFileInRemoteCommand extends ActiveEditorCommand {
|
||||
|
||||
constructor(private git: GitService, private repoPath: string) {
|
||||
constructor(private git: GitService) {
|
||||
super(Commands.OpenFileInRemote);
|
||||
}
|
||||
|
||||
@@ -18,10 +18,10 @@ export class OpenFileInRemoteCommand extends ActiveEditorCommand {
|
||||
}
|
||||
|
||||
const gitUri = await GitUri.fromUri(uri, this.git);
|
||||
const branch = await this.git.getBranch(gitUri.repoPath || this.repoPath);
|
||||
const branch = await this.git.getBranch(gitUri.repoPath || this.git.repoPath);
|
||||
|
||||
try {
|
||||
const remotes = Arrays.uniqueBy(await this.git.getRemotes(this.repoPath), _ => _.url, _ => !!_.provider);
|
||||
const remotes = Arrays.uniqueBy(await this.git.getRemotes(this.git.repoPath), _ => _.url, _ => !!_.provider);
|
||||
const range = editor && new Range(editor.selection.start.with({ line: editor.selection.start.line + 1 }), editor.selection.end.with({ line: editor.selection.end.line + 1 }));
|
||||
return commands.executeCommand(Commands.OpenInRemote, uri, remotes, 'file', [gitUri.getRelativePath(), branch.name, gitUri.sha, range]);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import { BranchesQuickPick, BranchHistoryQuickPick, CommandQuickPickItem } from
|
||||
|
||||
export class ShowQuickBranchHistoryCommand extends ActiveEditorCachedCommand {
|
||||
|
||||
constructor(private git: GitService, private repoPath: string) {
|
||||
constructor(private git: GitService) {
|
||||
super(Commands.ShowQuickBranchHistory);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ export class ShowQuickBranchHistoryCommand extends ActiveEditorCachedCommand {
|
||||
|
||||
let progressCancellation = branch && BranchHistoryQuickPick.showProgress(branch);
|
||||
try {
|
||||
const repoPath = (gitUri && gitUri.repoPath) || await this.git.getRepoPathFromUri(uri, this.repoPath);
|
||||
const repoPath = (gitUri && gitUri.repoPath) || await this.git.getRepoPathFromUri(uri, this.git.repoPath);
|
||||
if (!repoPath) return window.showWarningMessage(`Unable to show branch history`);
|
||||
|
||||
if (!branch) {
|
||||
|
||||
@@ -8,7 +8,7 @@ import * as path from 'path';
|
||||
|
||||
export class ShowQuickCommitDetailsCommand extends ActiveEditorCachedCommand {
|
||||
|
||||
constructor(private git: GitService, private repoPath: string) {
|
||||
constructor(private git: GitService) {
|
||||
super(Commands.ShowQuickCommitDetails);
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ export class ShowQuickCommitDetailsCommand extends ActiveEditorCachedCommand {
|
||||
}
|
||||
|
||||
if (!repoLog) {
|
||||
const log = await this.git.getLogForRepo(repoPath || this.repoPath, sha, 2);
|
||||
const log = await this.git.getLogForRepo(repoPath || this.git.repoPath, sha, 2);
|
||||
if (!log) return window.showWarningMessage(`Unable to show commit details`);
|
||||
|
||||
commit = log.commits.get(sha);
|
||||
|
||||
@@ -7,7 +7,7 @@ import { CommandQuickPickItem, RepoStatusQuickPick } from '../quickPicks';
|
||||
|
||||
export class ShowQuickRepoStatusCommand extends ActiveEditorCachedCommand {
|
||||
|
||||
constructor(private git: GitService, private repoPath: string) {
|
||||
constructor(private git: GitService) {
|
||||
super(Commands.ShowQuickRepoStatus);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ export class ShowQuickRepoStatusCommand extends ActiveEditorCachedCommand {
|
||||
}
|
||||
|
||||
try {
|
||||
const repoPath = await this.git.getRepoPathFromUri(uri, this.repoPath);
|
||||
const repoPath = await this.git.getRepoPathFromUri(uri, this.git.repoPath);
|
||||
if (!repoPath) return window.showWarningMessage(`Unable to show repository status`);
|
||||
|
||||
const status = await this.git.getStatusForRepo(repoPath);
|
||||
|
||||
@@ -29,7 +29,6 @@ export const DocumentSchemes = {
|
||||
export type WorkspaceState = 'repoPath';
|
||||
export const WorkspaceState = {
|
||||
GitLensVersion: 'gitlensVersion' as WorkspaceState,
|
||||
RepoPath: 'repoPath' as WorkspaceState,
|
||||
SuppressGitVersionWarning: 'suppressGitVersionWarning' as WorkspaceState
|
||||
};
|
||||
|
||||
|
||||
@@ -70,9 +70,7 @@ export async function activate(context: ExtensionContext) {
|
||||
notifyOnUnsupportedGitVersion(context, gitVersion);
|
||||
notifyOnNewGitLensVersion(context, gitlensVersion);
|
||||
|
||||
context.workspaceState.update(WorkspaceState.RepoPath, repoPath);
|
||||
|
||||
const git = new GitService(context);
|
||||
const git = new GitService(context, repoPath);
|
||||
context.subscriptions.push(git);
|
||||
|
||||
setCommandsContext(context, git);
|
||||
@@ -92,31 +90,31 @@ export async function activate(context: ExtensionContext) {
|
||||
|
||||
context.subscriptions.push(new Keyboard());
|
||||
|
||||
context.subscriptions.push(new CloseUnchangedFilesCommand(git, repoPath));
|
||||
context.subscriptions.push(new OpenChangedFilesCommand(git, repoPath));
|
||||
context.subscriptions.push(new CopyMessageToClipboardCommand(git, repoPath));
|
||||
context.subscriptions.push(new CopyShaToClipboardCommand(git, repoPath));
|
||||
context.subscriptions.push(new DiffDirectoryCommand(git, repoPath));
|
||||
context.subscriptions.push(new CloseUnchangedFilesCommand(git));
|
||||
context.subscriptions.push(new OpenChangedFilesCommand(git));
|
||||
context.subscriptions.push(new CopyMessageToClipboardCommand(git));
|
||||
context.subscriptions.push(new CopyShaToClipboardCommand(git));
|
||||
context.subscriptions.push(new DiffDirectoryCommand(git));
|
||||
context.subscriptions.push(new DiffLineWithPreviousCommand(git));
|
||||
context.subscriptions.push(new DiffLineWithWorkingCommand(git));
|
||||
context.subscriptions.push(new DiffWithBranchCommand(git));
|
||||
context.subscriptions.push(new DiffWithNextCommand(git));
|
||||
context.subscriptions.push(new DiffWithPreviousCommand(git));
|
||||
context.subscriptions.push(new DiffWithWorkingCommand(git));
|
||||
context.subscriptions.push(new OpenCommitInRemoteCommand(git, repoPath));
|
||||
context.subscriptions.push(new OpenFileInRemoteCommand(git, repoPath));
|
||||
context.subscriptions.push(new OpenCommitInRemoteCommand(git));
|
||||
context.subscriptions.push(new OpenFileInRemoteCommand(git));
|
||||
context.subscriptions.push(new OpenInRemoteCommand());
|
||||
context.subscriptions.push(new ShowBlameCommand(annotationController));
|
||||
context.subscriptions.push(new ToggleBlameCommand(annotationController));
|
||||
context.subscriptions.push(new ShowBlameHistoryCommand(git));
|
||||
context.subscriptions.push(new ShowFileHistoryCommand(git));
|
||||
context.subscriptions.push(new ShowLastQuickPickCommand());
|
||||
context.subscriptions.push(new ShowQuickBranchHistoryCommand(git, repoPath));
|
||||
context.subscriptions.push(new ShowQuickBranchHistoryCommand(git));
|
||||
context.subscriptions.push(new ShowQuickCurrentBranchHistoryCommand(git));
|
||||
context.subscriptions.push(new ShowQuickCommitDetailsCommand(git, repoPath));
|
||||
context.subscriptions.push(new ShowQuickCommitDetailsCommand(git));
|
||||
context.subscriptions.push(new ShowQuickCommitFileDetailsCommand(git));
|
||||
context.subscriptions.push(new ShowQuickFileHistoryCommand(git));
|
||||
context.subscriptions.push(new ShowQuickRepoStatusCommand(git, repoPath));
|
||||
context.subscriptions.push(new ShowQuickRepoStatusCommand(git));
|
||||
context.subscriptions.push(new ToggleCodeLensCommand(git));
|
||||
|
||||
Telemetry.trackEvent('initialized', Objects.flatten(config, 'config', true));
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Iterables, Objects } from './system';
|
||||
import { Disposable, Event, EventEmitter, ExtensionContext, FileSystemWatcher, languages, Location, Position, Range, TextDocument, TextEditor, Uri, workspace } from 'vscode';
|
||||
import { CommandContext, setCommandContext } from './commands';
|
||||
import { CodeLensVisibility, IConfig } from './configuration';
|
||||
import { DocumentSchemes, WorkspaceState } from './constants';
|
||||
import { DocumentSchemes } from './constants';
|
||||
import { Git, GitBlameParser, GitBranch, GitCommit, GitLogCommit, GitLogParser, GitRemote, GitStatusFile, GitStatusParser, IGitAuthor, IGitBlame, IGitBlameLine, IGitBlameLines, IGitLog, IGitStatus } from './git/git';
|
||||
import { IGitUriData, GitUri } from './git/gitUri';
|
||||
import { GitCodeLensProvider } from './gitCodeLensProvider';
|
||||
@@ -60,8 +60,6 @@ export class GitService extends Disposable {
|
||||
return this._onDidBlameFailEmitter.event;
|
||||
}
|
||||
|
||||
public repoPath: string;
|
||||
|
||||
private _gitCache: Map<string, GitCacheEntry> | undefined;
|
||||
private _remotesCache: GitRemote[];
|
||||
private _cacheDisposable: Disposable | undefined;
|
||||
@@ -76,10 +74,9 @@ export class GitService extends Disposable {
|
||||
|
||||
static EmptyPromise: Promise<IGitBlame | IGitLog> = Promise.resolve(undefined);
|
||||
|
||||
constructor(private context: ExtensionContext) {
|
||||
constructor(private context: ExtensionContext, public repoPath: string) {
|
||||
super(() => this.dispose());
|
||||
|
||||
this.repoPath = context.workspaceState.get(WorkspaceState.RepoPath) as string;
|
||||
this._uriCache = new Map();
|
||||
|
||||
this._onConfigurationChanged();
|
||||
|
||||
Reference in New Issue
Block a user