From 9d8ff1cc3688aefa09c23f82b9329bb9bfd8a6da Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Mon, 14 Dec 2020 12:33:06 -0500 Subject: [PATCH] Removes outdated clibboard error handling --- src/commands/copyMessageToClipboard.ts | 21 ++++++--------------- src/commands/copyShaToClipboard.ts | 21 ++++++--------------- src/commands/openPullRequestOnRemote.ts | 20 ++------------------ src/git/remotes/provider.ts | 17 +---------------- 4 files changed, 15 insertions(+), 64 deletions(-) diff --git a/src/commands/copyMessageToClipboard.ts b/src/commands/copyMessageToClipboard.ts index 6eb393c..c09fc76 100644 --- a/src/commands/copyMessageToClipboard.ts +++ b/src/commands/copyMessageToClipboard.ts @@ -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, @@ -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; @@ -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'); } diff --git a/src/commands/copyShaToClipboard.ts b/src/commands/copyShaToClipboard.ts index fe62964..ea15a61 100644 --- a/src/commands/copyShaToClipboard.ts +++ b/src/commands/copyShaToClipboard.ts @@ -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, @@ -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; @@ -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'); } diff --git a/src/commands/openPullRequestOnRemote.ts b/src/commands/openPullRequestOnRemote.ts index c09352c..eb79cc2 100644 --- a/src/commands/openPullRequestOnRemote.ts +++ b/src/commands/openPullRequestOnRemote.ts @@ -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; @@ -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)); } diff --git a/src/git/remotes/provider.ts b/src/git/remotes/provider.ts index 68e73ef..ce31611 100644 --- a/src/git/remotes/provider.ts +++ b/src/git/remotes/provider.ts @@ -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'; @@ -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 {