Browse Source

Removes outdated clibboard error handling

main
Eric Amodio 4 years ago
parent
commit
9d8ff1cc36
4 changed files with 15 additions and 64 deletions
  1. +6
    -15
      src/commands/copyMessageToClipboard.ts
  2. +6
    -15
      src/commands/copyShaToClipboard.ts
  3. +2
    -18
      src/commands/openPullRequestOnRemote.ts
  4. +1
    -16
      src/git/remotes/provider.ts

+ 6
- 15
src/commands/copyMessageToClipboard.ts View File

@ -1,10 +1,5 @@
'use strict'; '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 { import {
ActiveEditorCommand, ActiveEditorCommand,
command, command,
@ -15,6 +10,11 @@ import {
isCommandContextViewNodeHasCommit, isCommandContextViewNodeHasCommit,
isCommandContextViewNodeHasTag, isCommandContextViewNodeHasTag,
} from './common'; } 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 { export interface CopyMessageToClipboardCommandArgs {
message?: string; message?: string;
@ -97,15 +97,6 @@ export class CopyMessageToClipboardCommand extends ActiveEditorCommand {
void (await env.clipboard.writeText(args.message)); void (await env.clipboard.writeText(args.message));
} catch (ex) { } 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'); Logger.error(ex, 'CopyMessageToClipboardCommand');
void Messages.showGenericErrorMessage('Unable to copy message'); void Messages.showGenericErrorMessage('Unable to copy message');
} }

+ 6
- 15
src/commands/copyShaToClipboard.ts View File

@ -1,10 +1,5 @@
'use strict'; '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 { import {
ActiveEditorCommand, ActiveEditorCommand,
command, command,
@ -15,6 +10,11 @@ import {
isCommandContextViewNodeHasCommit, isCommandContextViewNodeHasCommit,
isCommandContextViewNodeHasTag, isCommandContextViewNodeHasTag,
} from './common'; } 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 { export interface CopyShaToClipboardCommandArgs {
sha?: string; sha?: string;
@ -80,15 +80,6 @@ export class CopyShaToClipboardCommand extends ActiveEditorCommand {
void (await env.clipboard.writeText(args.sha)); void (await env.clipboard.writeText(args.sha));
} catch (ex) { } 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'); Logger.error(ex, 'CopyShaToClipboardCommand');
void Messages.showGenericErrorMessage('Unable to copy commit SHA'); void Messages.showGenericErrorMessage('Unable to copy commit SHA');
} }

+ 2
- 18
src/commands/openPullRequestOnRemote.ts View File

@ -1,10 +1,8 @@
'use strict'; 'use strict';
import { env, Uri, window } from 'vscode';
import { env, Uri } from 'vscode';
import { Command, command, CommandContext, Commands } from './common'; import { Command, command, CommandContext, Commands } from './common';
import { Container } from '../container'; import { Container } from '../container';
import { PullRequestNode } from '../views/nodes'; import { PullRequestNode } from '../views/nodes';
import { Logger } from '../logger';
import { Messages } from '../messages';
export interface OpenPullRequestOnRemoteCommandArgs { export interface OpenPullRequestOnRemoteCommandArgs {
clipboard?: boolean; clipboard?: boolean;
@ -46,21 +44,7 @@ export class OpenPullRequestOnRemoteCommand extends Command {
} }
if (args.clipboard) { 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 { } else {
void env.openExternal(Uri.parse(args.pr.url)); void env.openExternal(Uri.parse(args.pr.url));
} }

+ 1
- 16
src/git/remotes/provider.ts View File

@ -17,7 +17,6 @@ import { SyncedState, WorkspaceState } from '../../constants';
import { Container } from '../../container'; import { Container } from '../../container';
import { setKeysForSync } from '../../extension'; import { setKeysForSync } from '../../extension';
import { Logger } from '../../logger'; import { Logger } from '../../logger';
import { Messages } from '../../messages';
import { Account, GitLogCommit, IssueOrPullRequest, PullRequest, PullRequestState, Repository } from '../models/models'; import { Account, GitLogCommit, IssueOrPullRequest, PullRequest, PullRequestState, Repository } from '../models/models';
import { debug, gate, log, Promises } from '../../system'; import { debug, gate, log, Promises } from '../../system';
@ -120,21 +119,7 @@ export abstract class RemoteProvider {
const url = this.url(resource); const url = this.url(resource);
if (url == null) return; 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 { hasApi(): this is RichRemoteProvider {

Loading…
Cancel
Save