mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-01-26 10:15:39 -05:00
Attempts to fix #58 - work with sub-modules
Also fixes issue with nested repos
This commit is contained in:
@@ -19,7 +19,7 @@ export class CloseUnchangedFilesCommand extends ActiveEditorCommand {
|
||||
|
||||
try {
|
||||
if (!uris) {
|
||||
const repoPath = await this.git.getRepoPathFromUri(uri, this.git.repoPath);
|
||||
const repoPath = await this.git.getRepoPathFromUri(uri);
|
||||
if (!repoPath) return window.showWarningMessage(`Unable to close unchanged files`);
|
||||
|
||||
const status = await this.git.getStatusForRepo(repoPath);
|
||||
|
||||
@@ -20,6 +20,8 @@ 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) {
|
||||
if (!this.git.repoPath) return undefined;
|
||||
|
||||
const log = await this.git.getLogForRepo(this.git.repoPath, undefined, 1);
|
||||
if (!log) return undefined;
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@ 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) {
|
||||
if (!this.git.repoPath) return undefined;
|
||||
|
||||
const log = await this.git.getLogForRepo(this.git.repoPath, undefined, 1);
|
||||
if (!log) return undefined;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ export class DiffDirectoryCommand extends ActiveEditorCommand {
|
||||
}
|
||||
|
||||
try {
|
||||
const repoPath = await this.git.getRepoPathFromUri(uri, this.git.repoPath);
|
||||
const repoPath = await this.git.getRepoPathFromUri(uri);
|
||||
if (!repoPath) return window.showWarningMessage(`Unable to open directory diff`);
|
||||
|
||||
if (!shaOrBranch1) {
|
||||
|
||||
@@ -17,7 +17,7 @@ export class OpenChangedFilesCommand extends ActiveEditorCommand {
|
||||
|
||||
try {
|
||||
if (!uris) {
|
||||
const repoPath = await this.git.getRepoPathFromUri(uri, this.git.repoPath);
|
||||
const repoPath = await this.git.getRepoPathFromUri(uri);
|
||||
if (!repoPath) return window.showWarningMessage(`Unable to open changed files`);
|
||||
|
||||
const status = await this.git.getStatusForRepo(repoPath);
|
||||
|
||||
@@ -17,9 +17,11 @@ export class OpenCommitInRemoteCommand extends ActiveEditorCommand {
|
||||
uri = editor.document.uri;
|
||||
}
|
||||
|
||||
if (editor && editor.document && editor.document.isDirty) return undefined;
|
||||
if ((editor && editor.document && editor.document.isDirty) || uri) return undefined;
|
||||
|
||||
const gitUri = await GitUri.fromUri(uri, this.git);
|
||||
if (!gitUri.repoPath) return undefined;
|
||||
|
||||
const line = (editor && editor.selection.active.line) || gitUri.offset;
|
||||
|
||||
try {
|
||||
@@ -35,7 +37,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.git.repoPath), _ => _.url, _ => !!_.provider);
|
||||
const remotes = Arrays.uniqueBy(await this.git.getRemotes(gitUri.repoPath), _ => _.url, _ => !!_.provider);
|
||||
return commands.executeCommand(Commands.OpenInRemote, uri, remotes, 'commit', [commit.sha]);
|
||||
}
|
||||
catch (ex) {
|
||||
|
||||
@@ -17,11 +17,15 @@ export class OpenFileInRemoteCommand extends ActiveEditorCommand {
|
||||
uri = editor.document.uri;
|
||||
}
|
||||
|
||||
if (!uri) return undefined;
|
||||
|
||||
const gitUri = await GitUri.fromUri(uri, this.git);
|
||||
const branch = await this.git.getBranch(gitUri.repoPath || this.git.repoPath);
|
||||
if (!gitUri.repoPath) return undefined;
|
||||
|
||||
const branch = await this.git.getBranch(gitUri.repoPath);
|
||||
|
||||
try {
|
||||
const remotes = Arrays.uniqueBy(await this.git.getRemotes(this.git.repoPath), _ => _.url, _ => !!_.provider);
|
||||
const remotes = Arrays.uniqueBy(await this.git.getRemotes(gitUri.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]);
|
||||
}
|
||||
|
||||
@@ -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.git.repoPath);
|
||||
const repoPath = (gitUri && gitUri.repoPath) || this.git.repoPath;
|
||||
if (!repoPath) return window.showWarningMessage(`Unable to show branch history`);
|
||||
|
||||
if (!branch) {
|
||||
|
||||
@@ -56,7 +56,7 @@ export class ShowQuickCommitDetailsCommand extends ActiveEditorCachedCommand {
|
||||
}
|
||||
|
||||
if (!repoLog) {
|
||||
const log = await this.git.getLogForRepo(repoPath || this.git.repoPath, sha, 2);
|
||||
const log = await this.git.getLogForRepo(repoPath, sha, 2);
|
||||
if (!log) return window.showWarningMessage(`Unable to show commit details`);
|
||||
|
||||
commit = log.commits.get(sha);
|
||||
|
||||
@@ -17,7 +17,10 @@ export class ShowQuickCurrentBranchHistoryCommand extends ActiveEditorCachedComm
|
||||
}
|
||||
|
||||
try {
|
||||
const branch = await this.git.getBranch(this.git.repoPath);
|
||||
const repoPath = await this.git.getRepoPathFromUri(uri);
|
||||
if (!repoPath) return window.showWarningMessage(`Unable to show branch history`);
|
||||
|
||||
const branch = await this.git.getBranch(repoPath);
|
||||
if (!branch) return undefined;
|
||||
|
||||
return commands.executeCommand(Commands.ShowQuickBranchHistory, uri, branch.name, undefined, goBackCommand);
|
||||
|
||||
@@ -17,7 +17,7 @@ export class ShowQuickRepoStatusCommand extends ActiveEditorCachedCommand {
|
||||
}
|
||||
|
||||
try {
|
||||
const repoPath = await this.git.getRepoPathFromUri(uri, this.git.repoPath);
|
||||
const repoPath = await this.git.getRepoPathFromUri(uri);
|
||||
if (!repoPath) return window.showWarningMessage(`Unable to show repository status`);
|
||||
|
||||
const status = await this.git.getStatusForRepo(repoPath);
|
||||
|
||||
@@ -17,7 +17,7 @@ export class ShowQuickStashListCommand extends ActiveEditorCachedCommand {
|
||||
}
|
||||
|
||||
try {
|
||||
const repoPath = await this.git.getRepoPathFromUri(uri, this.git.repoPath);
|
||||
const repoPath = await this.git.getRepoPathFromUri(uri);
|
||||
if (!repoPath) return window.showWarningMessage(`Unable to show stashed changes`);
|
||||
|
||||
const stash = await this.git.getStashList(repoPath);
|
||||
|
||||
@@ -13,6 +13,7 @@ export class StashApplyCommand extends Command {
|
||||
|
||||
async execute(stashItem: { stashName: string, message: string }, confirm: boolean = true, deleteAfter: boolean = false) {
|
||||
if (!this.git.config.insiders) return undefined;
|
||||
if (!this.git.repoPath) return undefined;
|
||||
|
||||
if (!stashItem || !stashItem.stashName) {
|
||||
const stash = await this.git.getStashList(this.git.repoPath);
|
||||
|
||||
@@ -12,6 +12,7 @@ export class StashDeleteCommand extends Command {
|
||||
|
||||
async execute(stashItem: { stashName: string, message: string }, confirm: boolean = true) {
|
||||
if (!this.git.config.insiders) return undefined;
|
||||
if (!this.git.repoPath) return undefined;
|
||||
if (!stashItem || !stashItem.stashName) return undefined;
|
||||
|
||||
try {
|
||||
|
||||
@@ -12,6 +12,7 @@ export class StashSaveCommand extends Command {
|
||||
|
||||
async execute(message?: string, unstagedOnly: boolean = false) {
|
||||
if (!this.git.config.insiders) return undefined;
|
||||
if (!this.git.repoPath) return undefined;
|
||||
|
||||
try {
|
||||
if (message == null) {
|
||||
|
||||
Reference in New Issue
Block a user