Kaynağa Gözat

Attempts to fix #58 - work with sub-modules

Also fixes issue with nested repos
main
Eric Amodio 7 yıl önce
ebeveyn
işleme
d3af67b21b
21 değiştirilmiş dosya ile 38 ekleme ve 25 silme
  1. +1
    -1
      src/commands/closeUnchangedFiles.ts
  2. +2
    -0
      src/commands/copyMessageToClipboard.ts
  3. +2
    -0
      src/commands/copyShaToClipboard.ts
  4. +1
    -1
      src/commands/diffDirectory.ts
  5. +1
    -1
      src/commands/openChangedFiles.ts
  6. +4
    -2
      src/commands/openCommitInRemote.ts
  7. +6
    -2
      src/commands/openFileInRemote.ts
  8. +1
    -1
      src/commands/showQuickBranchHistory.ts
  9. +1
    -1
      src/commands/showQuickCommitDetails.ts
  10. +4
    -1
      src/commands/showQuickCurrentBranchHistory.ts
  11. +1
    -1
      src/commands/showQuickRepoStatus.ts
  12. +1
    -1
      src/commands/showQuickStashList.ts
  13. +1
    -0
      src/commands/stashApply.ts
  14. +1
    -0
      src/commands/stashDelete.ts
  15. +1
    -0
      src/commands/stashSave.ts
  16. +1
    -1
      src/git/gitUri.ts
  17. +3
    -6
      src/gitService.ts
  18. +2
    -2
      src/quickPicks/branchHistory.ts
  19. +1
    -1
      src/quickPicks/commitDetails.ts
  20. +1
    -1
      src/quickPicks/commitFileDetails.ts
  21. +2
    -2
      src/quickPicks/fileHistory.ts

+ 1
- 1
src/commands/closeUnchangedFiles.ts Dosyayı Görüntüle

@ -19,7 +19,7 @@ export class CloseUnchangedFilesCommand extends ActiveEditorCommand {
try { try {
if (!uris) { 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`); if (!repoPath) return window.showWarningMessage(`Unable to close unchanged files`);
const status = await this.git.getStatusForRepo(repoPath); const status = await this.git.getStatusForRepo(repoPath);

+ 2
- 0
src/commands/copyMessageToClipboard.ts Dosyayı Görüntüle

@ -20,6 +20,8 @@ export class CopyMessageToClipboardCommand extends ActiveEditorCommand {
try { try {
// If we don't have an editor then get the message of the last commit to the branch // If we don't have an editor then get the message of the last commit to the branch
if (!uri) { if (!uri) {
if (!this.git.repoPath) return undefined;
const log = await this.git.getLogForRepo(this.git.repoPath, undefined, 1); const log = await this.git.getLogForRepo(this.git.repoPath, undefined, 1);
if (!log) return undefined; if (!log) return undefined;

+ 2
- 0
src/commands/copyShaToClipboard.ts Dosyayı Görüntüle

@ -20,6 +20,8 @@ export class CopyShaToClipboardCommand extends ActiveEditorCommand {
try { try {
// If we don't have an editor then get the sha of the last commit to the branch // If we don't have an editor then get the sha of the last commit to the branch
if (!uri) { if (!uri) {
if (!this.git.repoPath) return undefined;
const log = await this.git.getLogForRepo(this.git.repoPath, undefined, 1); const log = await this.git.getLogForRepo(this.git.repoPath, undefined, 1);
if (!log) return undefined; if (!log) return undefined;

+ 1
- 1
src/commands/diffDirectory.ts Dosyayı Görüntüle

@ -18,7 +18,7 @@ export class DiffDirectoryCommand extends ActiveEditorCommand {
} }
try { 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 (!repoPath) return window.showWarningMessage(`Unable to open directory diff`);
if (!shaOrBranch1) { if (!shaOrBranch1) {

+ 1
- 1
src/commands/openChangedFiles.ts Dosyayı Görüntüle

@ -17,7 +17,7 @@ export class OpenChangedFilesCommand extends ActiveEditorCommand {
try { try {
if (!uris) { 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`); if (!repoPath) return window.showWarningMessage(`Unable to open changed files`);
const status = await this.git.getStatusForRepo(repoPath); const status = await this.git.getStatusForRepo(repoPath);

+ 4
- 2
src/commands/openCommitInRemote.ts Dosyayı Görüntüle

@ -17,9 +17,11 @@ export class OpenCommitInRemoteCommand extends ActiveEditorCommand {
uri = editor.document.uri; 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); const gitUri = await GitUri.fromUri(uri, this.git);
if (!gitUri.repoPath) return undefined;
const line = (editor && editor.selection.active.line) || gitUri.offset; const line = (editor && editor.selection.active.line) || gitUri.offset;
try { 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); 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]); return commands.executeCommand(Commands.OpenInRemote, uri, remotes, 'commit', [commit.sha]);
} }
catch (ex) { catch (ex) {

+ 6
- 2
src/commands/openFileInRemote.ts Dosyayı Görüntüle

@ -17,11 +17,15 @@ export class OpenFileInRemoteCommand extends ActiveEditorCommand {
uri = editor.document.uri; uri = editor.document.uri;
} }
if (!uri) return undefined;
const gitUri = await GitUri.fromUri(uri, this.git); 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 { 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 })); 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]); return commands.executeCommand(Commands.OpenInRemote, uri, remotes, 'file', [gitUri.getRelativePath(), branch.name, gitUri.sha, range]);
} }

+ 1
- 1
src/commands/showQuickBranchHistory.ts Dosyayı Görüntüle

@ -24,7 +24,7 @@ export class ShowQuickBranchHistoryCommand extends ActiveEditorCachedCommand {
let progressCancellation = branch && BranchHistoryQuickPick.showProgress(branch); let progressCancellation = branch && BranchHistoryQuickPick.showProgress(branch);
try { 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 (!repoPath) return window.showWarningMessage(`Unable to show branch history`);
if (!branch) { if (!branch) {

+ 1
- 1
src/commands/showQuickCommitDetails.ts Dosyayı Görüntüle

@ -56,7 +56,7 @@ export class ShowQuickCommitDetailsCommand extends ActiveEditorCachedCommand {
} }
if (!repoLog) { 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`); if (!log) return window.showWarningMessage(`Unable to show commit details`);
commit = log.commits.get(sha); commit = log.commits.get(sha);

+ 4
- 1
src/commands/showQuickCurrentBranchHistory.ts Dosyayı Görüntüle

@ -17,7 +17,10 @@ export class ShowQuickCurrentBranchHistoryCommand extends ActiveEditorCachedComm
} }
try { 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; if (!branch) return undefined;
return commands.executeCommand(Commands.ShowQuickBranchHistory, uri, branch.name, undefined, goBackCommand); return commands.executeCommand(Commands.ShowQuickBranchHistory, uri, branch.name, undefined, goBackCommand);

+ 1
- 1
src/commands/showQuickRepoStatus.ts Dosyayı Görüntüle

@ -17,7 +17,7 @@ export class ShowQuickRepoStatusCommand extends ActiveEditorCachedCommand {
} }
try { 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`); if (!repoPath) return window.showWarningMessage(`Unable to show repository status`);
const status = await this.git.getStatusForRepo(repoPath); const status = await this.git.getStatusForRepo(repoPath);

+ 1
- 1
src/commands/showQuickStashList.ts Dosyayı Görüntüle

@ -17,7 +17,7 @@ export class ShowQuickStashListCommand extends ActiveEditorCachedCommand {
} }
try { 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`); if (!repoPath) return window.showWarningMessage(`Unable to show stashed changes`);
const stash = await this.git.getStashList(repoPath); const stash = await this.git.getStashList(repoPath);

+ 1
- 0
src/commands/stashApply.ts Dosyayı Görüntüle

@ -13,6 +13,7 @@ export class StashApplyCommand extends Command {
async execute(stashItem: { stashName: string, message: string }, confirm: boolean = true, deleteAfter: boolean = false) { async execute(stashItem: { stashName: string, message: string }, confirm: boolean = true, deleteAfter: boolean = false) {
if (!this.git.config.insiders) return undefined; if (!this.git.config.insiders) return undefined;
if (!this.git.repoPath) return undefined;
if (!stashItem || !stashItem.stashName) { if (!stashItem || !stashItem.stashName) {
const stash = await this.git.getStashList(this.git.repoPath); const stash = await this.git.getStashList(this.git.repoPath);

+ 1
- 0
src/commands/stashDelete.ts Dosyayı Görüntüle

@ -12,6 +12,7 @@ export class StashDeleteCommand extends Command {
async execute(stashItem: { stashName: string, message: string }, confirm: boolean = true) { async execute(stashItem: { stashName: string, message: string }, confirm: boolean = true) {
if (!this.git.config.insiders) return undefined; if (!this.git.config.insiders) return undefined;
if (!this.git.repoPath) return undefined;
if (!stashItem || !stashItem.stashName) return undefined; if (!stashItem || !stashItem.stashName) return undefined;
try { try {

+ 1
- 0
src/commands/stashSave.ts Dosyayı Görüntüle

@ -12,6 +12,7 @@ export class StashSaveCommand extends Command {
async execute(message?: string, unstagedOnly: boolean = false) { async execute(message?: string, unstagedOnly: boolean = false) {
if (!this.git.config.insiders) return undefined; if (!this.git.config.insiders) return undefined;
if (!this.git.repoPath) return undefined;
try { try {
if (message == null) { if (message == null) {

+ 1
- 1
src/git/gitUri.ts Dosyayı Görüntüle

@ -87,7 +87,7 @@ export class GitUri extends Uri {
if (commit) return new GitUri(uri, commit); if (commit) return new GitUri(uri, commit);
} }
return new GitUri(uri, git && git.repoPath);
return new GitUri(uri, (await git.getRepoPathFromFile(uri.fsPath)) || git.repoPath);
} }
static fromFileStatus(status: IGitStatusFile, repoPath: string, original?: boolean): GitUri; static fromFileStatus(status: IGitStatusFile, repoPath: string, original?: boolean): GitUri;

+ 3
- 6
src/gitService.ts Dosyayı Görüntüle

@ -668,13 +668,10 @@ export class GitService extends Disposable {
return log && log.repoPath; return log && log.repoPath;
} }
async getRepoPathFromUri(uri?: Uri, fallbackRepoPath?: string): Promise<string | undefined> {
if (!(uri instanceof Uri)) return fallbackRepoPath;
async getRepoPathFromUri(uri: Uri | undefined): Promise<string | undefined> {
if (!(uri instanceof Uri)) return this.repoPath;
const gitUri = await GitUri.fromUri(uri, this);
if (gitUri.repoPath) return gitUri.repoPath;
return (await this.getRepoPathFromFile(gitUri.fsPath)) || fallbackRepoPath;
return (await GitUri.fromUri(uri, this)).repoPath || this.repoPath;
} }
async getStashList(repoPath: string): Promise<IGitStash> { async getStashList(repoPath: string): Promise<IGitStash> {

+ 2
- 2
src/quickPicks/branchHistory.ts Dosyayı Görüntüle

@ -17,7 +17,7 @@ export class BranchHistoryQuickPick {
}); });
} }
static async show(git: GitService, log: IGitLog, uri: GitUri, branch: string, progressCancellation: CancellationTokenSource, goBackCommand?: CommandQuickPickItem, nextPageCommand?: CommandQuickPickItem): Promise<CommitQuickPickItem | CommandQuickPickItem | undefined> {
static async show(git: GitService, log: IGitLog, uri: GitUri | undefined, branch: string, progressCancellation: CancellationTokenSource, goBackCommand?: CommandQuickPickItem, nextPageCommand?: CommandQuickPickItem): Promise<CommitQuickPickItem | CommandQuickPickItem | undefined> {
const items = Array.from(Iterables.map(log.commits.values(), c => new CommitQuickPickItem(c))) as (CommitQuickPickItem | CommandQuickPickItem)[]; const items = Array.from(Iterables.map(log.commits.values(), c => new CommitQuickPickItem(c))) as (CommitQuickPickItem | CommandQuickPickItem)[];
const currentCommand = new CommandQuickPickItem({ const currentCommand = new CommandQuickPickItem({
@ -25,7 +25,7 @@ export class BranchHistoryQuickPick {
description: `\u00a0 \u2014 \u00a0\u00a0 to \u00a0$(git-branch) ${branch} history` description: `\u00a0 \u2014 \u00a0\u00a0 to \u00a0$(git-branch) ${branch} history`
}, Commands.ShowQuickBranchHistory, [uri, branch, log.maxCount, goBackCommand, log]); }, Commands.ShowQuickBranchHistory, [uri, branch, log.maxCount, goBackCommand, log]);
const remotes = Arrays.uniqueBy(await git.getRemotes(git.repoPath), _ => _.url, _ => !!_.provider);
const remotes = Arrays.uniqueBy(await git.getRemotes((uri && uri.repoPath) || git.repoPath), _ => _.url, _ => !!_.provider);
if (remotes.length) { if (remotes.length) {
items.splice(0, 0, new OpenRemotesCommandQuickPickItem(remotes, 'branch', branch, currentCommand)); items.splice(0, 0, new OpenRemotesCommandQuickPickItem(remotes, 'branch', branch, currentCommand));
} }

+ 1
- 1
src/quickPicks/commitDetails.ts Dosyayı Görüntüle

@ -101,7 +101,7 @@ export class CommitDetailsQuickPick {
}, Commands.CopyMessageToClipboard, [uri, commit.sha, commit.message])); }, Commands.CopyMessageToClipboard, [uri, commit.sha, commit.message]));
if (!stash) { if (!stash) {
const remotes = Arrays.uniqueBy(await git.getRemotes(git.repoPath), _ => _.url, _ => !!_.provider);
const remotes = Arrays.uniqueBy(await git.getRemotes(commit.repoPath), _ => _.url, _ => !!_.provider);
if (remotes.length) { if (remotes.length) {
items.splice(index++, 0, new OpenRemotesCommandQuickPickItem(remotes, 'commit', commit.sha, currentCommand)); items.splice(index++, 0, new OpenRemotesCommandQuickPickItem(remotes, 'commit', commit.sha, currentCommand));
} }

+ 1
- 1
src/quickPicks/commitFileDetails.ts Dosyayı Görüntüle

@ -84,7 +84,7 @@ export class CommitFileDetailsQuickPick {
items.push(new OpenCommitWorkingTreeFileCommandQuickPickItem(commit)); items.push(new OpenCommitWorkingTreeFileCommandQuickPickItem(commit));
} }
const remotes = Arrays.uniqueBy(await git.getRemotes(git.repoPath), _ => _.url, _ => !!_.provider);
const remotes = Arrays.uniqueBy(await git.getRemotes(commit.repoPath), _ => _.url, _ => !!_.provider);
if (remotes.length) { if (remotes.length) {
if (!stash) { if (!stash) {
items.push(new OpenRemotesCommandQuickPickItem(remotes, 'file', commit.fileName, undefined, commit.sha, currentCommand)); items.push(new OpenRemotesCommandQuickPickItem(remotes, 'file', commit.fileName, undefined, commit.sha, currentCommand));

+ 2
- 2
src/quickPicks/fileHistory.ts Dosyayı Görüntüle

@ -74,7 +74,7 @@ export class FileHistoryQuickPick {
} }
} }
const branch = await git.getBranch(uri.repoPath || git.repoPath);
const branch = await git.getBranch(uri.repoPath);
const currentCommand = new CommandQuickPickItem({ const currentCommand = new CommandQuickPickItem({
label: `go back \u21A9`, label: `go back \u21A9`,
@ -93,7 +93,7 @@ export class FileHistoryQuickPick {
])); ]));
} }
const remotes = Arrays.uniqueBy(await git.getRemotes(git.repoPath), _ => _.url, _ => !!_.provider);
const remotes = Arrays.uniqueBy(await git.getRemotes(uri.repoPath), _ => _.url, _ => !!_.provider);
if (remotes.length) { if (remotes.length) {
items.splice(index++, 0, new OpenRemotesCommandQuickPickItem(remotes, 'file', uri.getRelativePath(), branch.name, uri.sha, currentCommand)); items.splice(index++, 0, new OpenRemotesCommandQuickPickItem(remotes, 'file', uri.getRelativePath(), branch.name, uri.sha, currentCommand));
} }

Yükleniyor…
İptal
Kaydet