Skip to content

Commit

Permalink
Removes outdated clibboard error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
eamodio committed Dec 14, 2020
1 parent 32cd4b2 commit 9d8ff1c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 64 deletions.
21 changes: 6 additions & 15 deletions src/commands/copyMessageToClipboard.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
'use strict';
import { env, TextEditor, Uri, window } from 'vscode';
import { Container } from '../container';
import { GitUri } from '../git/gitUri';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { Iterables } from '../system';
import { env, TextEditor, Uri } from 'vscode';
import {
ActiveEditorCommand,
command,
Expand All @@ -15,6 +10,11 @@ import {
isCommandContextViewNodeHasCommit,
isCommandContextViewNodeHasTag,
} from './common';
import { Container } from '../container';
import { GitUri } from '../git/gitUri';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { Iterables } from '../system';

export interface CopyMessageToClipboardCommandArgs {
message?: string;
Expand Down Expand Up @@ -97,15 +97,6 @@ export class CopyMessageToClipboardCommand extends ActiveEditorCommand {

void (await env.clipboard.writeText(args.message));
} catch (ex) {
const msg: string = ex?.message ?? '';
if (msg.includes("Couldn't find the required `xsel` binary")) {
void window.showErrorMessage(
'Unable to copy message, xsel is not installed. Please install it via your package manager, e.g. `sudo apt install xsel`',
);

return;
}

Logger.error(ex, 'CopyMessageToClipboardCommand');
void Messages.showGenericErrorMessage('Unable to copy message');
}
Expand Down
21 changes: 6 additions & 15 deletions src/commands/copyShaToClipboard.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
'use strict';
import { env, TextEditor, Uri, window } from 'vscode';
import { Container } from '../container';
import { GitUri } from '../git/gitUri';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { Iterables } from '../system';
import { env, TextEditor, Uri } from 'vscode';
import {
ActiveEditorCommand,
command,
Expand All @@ -15,6 +10,11 @@ import {
isCommandContextViewNodeHasCommit,
isCommandContextViewNodeHasTag,
} from './common';
import { Container } from '../container';
import { GitUri } from '../git/gitUri';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { Iterables } from '../system';

export interface CopyShaToClipboardCommandArgs {
sha?: string;
Expand Down Expand Up @@ -80,15 +80,6 @@ export class CopyShaToClipboardCommand extends ActiveEditorCommand {

void (await env.clipboard.writeText(args.sha));
} catch (ex) {
const msg: string = ex?.message ?? '';
if (msg.includes("Couldn't find the required `xsel` binary")) {
void window.showErrorMessage(
'Unable to copy commit SHA, xsel is not installed. Please install it via your package manager, e.g. `sudo apt install xsel`',
);

return;
}

Logger.error(ex, 'CopyShaToClipboardCommand');
void Messages.showGenericErrorMessage('Unable to copy commit SHA');
}
Expand Down
20 changes: 2 additions & 18 deletions src/commands/openPullRequestOnRemote.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
'use strict';
import { env, Uri, window } from 'vscode';
import { env, Uri } from 'vscode';
import { Command, command, CommandContext, Commands } from './common';
import { Container } from '../container';
import { PullRequestNode } from '../views/nodes';
import { Logger } from '../logger';
import { Messages } from '../messages';

export interface OpenPullRequestOnRemoteCommandArgs {
clipboard?: boolean;
Expand Down Expand Up @@ -46,21 +44,7 @@ export class OpenPullRequestOnRemoteCommand extends Command {
}

if (args.clipboard) {
try {
void (await env.clipboard.writeText(args.pr.url));
} catch (ex) {
const msg: string = ex?.toString() ?? '';
if (msg.includes("Couldn't find the required `xsel` binary")) {
void window.showErrorMessage(
'Unable to copy remote url, xsel is not installed. Please install it via your package manager, e.g. `sudo apt install xsel`',
);

return;
}

Logger.error(ex, 'CopyRemotePullRequestCommand');
void Messages.showGenericErrorMessage('Unable to copy pull request url');
}
void (await env.clipboard.writeText(args.pr.url));
} else {
void env.openExternal(Uri.parse(args.pr.url));
}
Expand Down
17 changes: 1 addition & 16 deletions src/git/remotes/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { SyncedState, WorkspaceState } from '../../constants';
import { Container } from '../../container';
import { setKeysForSync } from '../../extension';
import { Logger } from '../../logger';
import { Messages } from '../../messages';
import { Account, GitLogCommit, IssueOrPullRequest, PullRequest, PullRequestState, Repository } from '../models/models';
import { debug, gate, log, Promises } from '../../system';

Expand Down Expand Up @@ -120,21 +119,7 @@ export abstract class RemoteProvider {
const url = this.url(resource);
if (url == null) return;

try {
void (await env.clipboard.writeText(url));
} catch (ex) {
const msg: string = ex?.toString() ?? '';
if (msg.includes("Couldn't find the required `xsel` binary")) {
void window.showErrorMessage(
'Unable to copy remote url, xsel is not installed. Please install it via your package manager, e.g. `sudo apt install xsel`',
);

return;
}

Logger.error(ex, 'CopyRemoteUrlCommand');
void Messages.showGenericErrorMessage('Unable to copy remote url');
}
void (await env.clipboard.writeText(url));
}

hasApi(): this is RichRemoteProvider {
Expand Down

0 comments on commit 9d8ff1c

Please sign in to comment.