Browse Source

Switches to use repoPath on GitService

main
Eric Amodio 7 years ago
parent
commit
19fe22f061
13 changed files with 34 additions and 40 deletions
  1. +2
    -2
      src/commands/closeUnchangedFiles.ts
  2. +2
    -2
      src/commands/copyMessageToClipboard.ts
  3. +2
    -2
      src/commands/copyShaToClipboard.ts
  4. +2
    -2
      src/commands/diffDirectory.ts
  5. +2
    -2
      src/commands/openChangedFiles.ts
  6. +2
    -2
      src/commands/openCommitInRemote.ts
  7. +3
    -3
      src/commands/openFileInRemote.ts
  8. +2
    -2
      src/commands/showQuickBranchHistory.ts
  9. +2
    -2
      src/commands/showQuickCommitDetails.ts
  10. +2
    -2
      src/commands/showQuickRepoStatus.ts
  11. +0
    -1
      src/constants.ts
  12. +11
    -13
      src/extension.ts
  13. +2
    -5
      src/gitService.ts

+ 2
- 2
src/commands/closeUnchangedFiles.ts View File

@ -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);

+ 2
- 2
src/commands/copyMessageToClipboard.ts View File

@ -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;

+ 2
- 2
src/commands/copyShaToClipboard.ts View File

@ -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;

+ 2
- 2
src/commands/diffDirectory.ts View File

@ -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) {

+ 2
- 2
src/commands/openChangedFiles.ts View File

@ -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);

+ 2
- 2
src/commands/openCommitInRemote.ts View File

@ -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) {

+ 3
- 3
src/commands/openFileInRemote.ts View File

@ -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]);
}

+ 2
- 2
src/commands/showQuickBranchHistory.ts View File

@ -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) {

+ 2
- 2
src/commands/showQuickCommitDetails.ts View File

@ -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);

+ 2
- 2
src/commands/showQuickRepoStatus.ts View File

@ -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);

+ 0
- 1
src/constants.ts View File

@ -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
};

+ 11
- 13
src/extension.ts View File

@ -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));

+ 2
- 5
src/gitService.ts View File

@ -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();

Loading…
Cancel
Save