瀏覽代碼

Fixes #1222 - open associated pr wasnt implemented

main
Eric Amodio 4 年之前
父節點
當前提交
a66e5d8cd5
共有 4 個檔案被更改,包括 44 行新增18 行删除
  1. +1
    -0
      CHANGELOG.md
  2. +1
    -0
      src/commands.ts
  3. +39
    -0
      src/commands/openAssociatedPullRequestOnRemote.ts
  4. +3
    -18
      src/commands/openPullRequestOnRemote.ts

+ 1
- 0
CHANGELOG.md 查看文件

@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
### Fixed
- Fixes [#1222](https://github.com/eamodio/vscode-gitlens/issues/1222) - GitLens: Open Associated Pull Request doesn't work
- Fixes [#1223](https://github.com/eamodio/vscode-gitlens/issues/1223) - commit pane, ${tips} does not show tags
- Fixes [#1225](https://github.com/eamodio/vscode-gitlens/issues/1225) - Changes hover is wrong if the original/new line number doesn't match
- Fixes [#1045](https://github.com/eamodio/vscode-gitlens/issues/1045) - View File History not working - absolute path used — thanks to [PR #1209](https://github.com/eamodio/vscode-gitlens/pull/1209) by Mike Surcouf ([@mikes-gh](https://github.com/mikes-gh))

+ 1
- 0
src/commands.ts 查看文件

@ -20,6 +20,7 @@ export * from './commands/diffWithWorking';
export * from './commands/externalDiff';
export * from './commands/gitCommands';
export * from './commands/inviteToLiveShare';
export * from './commands/openAssociatedPullRequestOnRemote';
export * from './commands/openBranchesOnRemote';
export * from './commands/openBranchOnRemote';
export * from './commands/openChangedFiles';

+ 39
- 0
src/commands/openAssociatedPullRequestOnRemote.ts 查看文件

@ -0,0 +1,39 @@
'use strict';
import { TextEditor, Uri } from 'vscode';
import { ActiveEditorCommand, command, Commands, executeCommand, getCommandUri } from './common';
import { Container } from '../container';
import { Logger } from '../logger';
import { GitUri } from '../git/gitUri';
import { OpenPullRequestOnRemoteCommandArgs } from './openPullRequestOnRemote';
@command()
export class OpenAssociatedPullRequestOnRemoteCommand extends ActiveEditorCommand {
constructor() {
super(Commands.OpenAssociatedPullRequestOnRemote);
}
async execute(editor?: TextEditor, uri?: Uri) {
if (editor == null) return;
uri = getCommandUri(uri, editor);
if (uri == null) return;
const gitUri = await GitUri.fromUri(uri);
const blameline = editor.selection.active.line;
if (blameline < 0) return;
try {
const blame = await Container.git.getBlameForLine(gitUri, blameline);
if (blame == null) return;
await executeCommand<OpenPullRequestOnRemoteCommandArgs>(Commands.OpenPullRequestOnRemote, {
clipboard: false,
ref: blame.commit.sha,
repoPath: blame.commit.repoPath,
});
} catch (ex) {
Logger.error(ex, 'OpenAssociatedPullRequestOnRemoteCommand', `getBlameForLine(${blameline})`);
}
}
}

+ 3
- 18
src/commands/openPullRequestOnRemote.ts 查看文件

@ -1,13 +1,6 @@
'use strict';
import { env, Uri, window } from 'vscode';
import {
Command,
command,
CommandContext,
Commands,
isCommandContextViewNodeHasCommit,
isCommandContextViewNodeHasFileCommit,
} from './common';
import { Command, command, CommandContext, Commands } from './common';
import { Container } from '../container';
import { PullRequestNode } from '../views/nodes';
import { Logger } from '../logger';
@ -23,19 +16,11 @@ export interface OpenPullRequestOnRemoteCommandArgs {
@command()
export class OpenPullRequestOnRemoteCommand extends Command {
constructor() {
super([
Commands.OpenPullRequestOnRemote,
Commands.CopyRemotePullRequestUrl,
Commands.OpenAssociatedPullRequestOnRemote,
]);
super([Commands.OpenPullRequestOnRemote, Commands.CopyRemotePullRequestUrl]);
}
protected preExecute(context: CommandContext, args?: OpenPullRequestOnRemoteCommandArgs) {
if (context.command === Commands.OpenAssociatedPullRequestOnRemote) {
if (isCommandContextViewNodeHasCommit(context) || isCommandContextViewNodeHasFileCommit(context)) {
args = { ...args, ref: context.node.commit.sha, repoPath: context.node.commit.repoPath };
}
} else if (context.type === 'viewItem' && context.node instanceof PullRequestNode) {
if (context.type === 'viewItem' && context.node instanceof PullRequestNode) {
args = {
...args,
pr: { url: context.node.pullRequest.url },

Loading…
取消
儲存