Skip to content

Commit

Permalink
Adds Copy Remote Url to quickpicks
Browse files Browse the repository at this point in the history
  • Loading branch information
eamodio committed May 22, 2019
1 parent 5c03903 commit a75cba5
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/quickpicks/commitFileQuickPick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { commands, QuickPickItem, TextDocumentShowOptions, TextEditor, Uri, wind
import {
Commands,
CopyMessageToClipboardCommandArgs,
CopyRemoteFileUrlToClipboardCommandArgs,
CopyShaToClipboardCommandArgs,
DiffWithPreviousCommandArgs,
DiffWithWorkingCommandArgs,
Expand Down Expand Up @@ -255,6 +256,21 @@ export class CommitFileQuickPick {
[uri, copyMessageCommandArgs]
)
);

if (remotes.length) {
const copyRemoteUrlCommandArgs: CopyRemoteFileUrlToClipboardCommandArgs = {
sha: commit.sha
};
items.push(
new CommandQuickPickItem(
{
label: '$(clippy) Copy Remote Url to Clipboard'
},
Commands.CopyRemoteFileUrlToClipboard,
[uri, copyRemoteUrlCommandArgs]
)
);
}
}

if (workingUri) {
Expand Down
23 changes: 22 additions & 1 deletion src/quickpicks/commitQuickPick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { commands, TextDocumentShowOptions, TextEditor, Uri, window } from 'vsco
import {
Commands,
CopyMessageToClipboardCommandArgs,
CopyRemoteFileUrlToClipboardCommandArgs,
CopyShaToClipboardCommandArgs,
DiffDirectoryCommandArgs,
DiffWithPreviousCommandArgs,
Expand Down Expand Up @@ -248,6 +249,7 @@ export class CommitQuickPick {

let index = 0;

let remotes;
if (stash) {
const stashApplyCommmandArgs: StashApplyCommandArgs = {
confirm: true,
Expand Down Expand Up @@ -291,7 +293,7 @@ export class CommitQuickPick {
else {
items.splice(index++, 0, new ShowCommitInViewQuickPickItem(commit));

const remotes = await Container.git.getRemotes(commit.repoPath);
remotes = await Container.git.getRemotes(commit.repoPath);
if (remotes.length) {
items.splice(
index++,
Expand Down Expand Up @@ -383,6 +385,25 @@ export class CommitQuickPick {
)
);

if (!stash) {
if (remotes !== undefined && remotes.length) {
const copyRemoteUrlCommandArgs: CopyRemoteFileUrlToClipboardCommandArgs = {
sha: commit.sha
};
items.splice(
index++,
0,
new CommandQuickPickItem(
{
label: '$(clippy) Copy Remote Url to Clipboard'
},
Commands.CopyRemoteFileUrlToClipboard,
[uri, copyRemoteUrlCommandArgs]
)
);
}
}

const commitDetailsCommandArgs: ShowQuickCommitDetailsCommandArgs = {
commit: commit,
repoLog: options.repoLog,
Expand Down

0 comments on commit a75cba5

Please sign in to comment.