Przeglądaj źródła

Adds create pull request notification

main
Eric Amodio 3 lat temu
rodzic
commit
72f1d8784d
5 zmienionych plików z 63 dodań i 1 usunięć
  1. +2
    -1
      CHANGELOG.md
  2. +5
    -0
      package.json
  3. +1
    -0
      src/config.ts
  4. +42
    -0
      src/git/models/repository.ts
  5. +13
    -0
      src/messages.ts

+ 2
- 1
CHANGELOG.md Wyświetl plik

@ -14,8 +14,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- Adds a new _Browse Repository from Before Here_ (`gitlens.browseRepoBeforeRevision`) and _Browse Repository from Before Here in New Window_ (`gitlens.browseRepoBeforeRevisionInNewWindow`) commands
- Adds _Repository from Before Here_ and _Repository from Before Here in New Window_ to the _Browse_ submenu of commits in the views
- Adds a new _Copy Current Branch Name_ (`gitlens.copyCurrentBranch`) command to copy the current branch name to the clipboard — closes [#1306](https://github.com/eamodio/vscode-gitlens/issues/1306) — thanks to [PR #1307](https://github.com/eamodio/vscode-gitlens/pull/1307) by Ken Hom ([@kh0m](https://github.com/kh0m))
- Adds a `gitlens.advanced.abbreviateShaOnCopy` setting to specify to whether to copy full or abbreviated commit SHAs to the clipboard. Abbreviates to the length of `gitlens.advanced.abbreviatedShaLength` — closes [#1062](https://github.com/eamodio/vscode-gitlens/issues/1062) — thanks to [PR #1316](https://github.com/eamodio/vscode-gitlens/pull/1316) by Brendon Smith ([@br3ndonland](https://github.com/br3ndonland))
- Adds a _Switch to Text_ button on the _Interactive Rebase Editor_ to open the text rebase todo file — note that closing either document will start the rebase
- Adds a notification which asks if you want to create a pull request after publishing a new branch
- Adds a `gitlens.advanced.abbreviateShaOnCopy` setting to specify to whether to copy full or abbreviated commit SHAs to the clipboard. Abbreviates to the length of `gitlens.advanced.abbreviatedShaLength` — closes [#1062](https://github.com/eamodio/vscode-gitlens/issues/1062) — thanks to [PR #1316](https://github.com/eamodio/vscode-gitlens/pull/1316) by Brendon Smith ([@br3ndonland](https://github.com/br3ndonland))
- Adds a `gitlens.advanced.externalDiffTool` setting to specify an optional external diff tool to use when comparing files. Must be a configured [Git difftool](https://git-scm.com/docs/git-config#Documentation/git-config.txt-difftool).
- Adds a `gitlens.advanced.externalDirectoryDiffTool` setting to specify an optional external diff tool to use when comparing directories. Must be a configured [Git difftool](https://git-scm.com/docs/git-config#Documentation/git-config.txt-difftool).

+ 5
- 0
package.json Wyświetl plik

@ -2428,6 +2428,7 @@
"default": {
"suppressCommitHasNoPreviousCommitWarning": false,
"suppressCommitNotFoundWarning": false,
"suppressCreatePullRequestPrompt": false,
"suppressFileNotUnderSourceControlWarning": false,
"suppressGitDisabledWarning": false,
"suppressGitVersionWarning": false,
@ -2444,6 +2445,10 @@
"type": "boolean",
"default": false
},
"suppressCreatePullRequestPrompt": {
"type": "boolean",
"default": false
},
"suppressFileNotUnderSourceControlWarning": {
"type": "boolean",
"default": false

+ 1
- 0
src/config.ts Wyświetl plik

@ -296,6 +296,7 @@ export interface AdvancedConfig {
messages: {
suppressCommitHasNoPreviousCommitWarning: boolean;
suppressCommitNotFoundWarning: boolean;
suppressCreatePullRequestPrompt: boolean;
suppressFileNotUnderSourceControlWarning: boolean;
suppressGitDisabledWarning: boolean;
suppressGitVersionWarning: boolean;

+ 42
- 0
src/git/models/repository.ts Wyświetl plik

@ -13,6 +13,8 @@ import {
workspace,
WorkspaceFolder,
} from 'vscode';
import { CreatePullRequestActionContext } from '../../api/gitlens';
import { executeActionCommand } from '../../commands';
import { BranchSorting, configuration, TagSorting } from '../../configuration';
import { Starred, WorkspaceState } from '../../constants';
import { Container } from '../../container';
@ -597,6 +599,10 @@ export class Repository implements Disposable {
return Container.git.getRebaseStatus(this.path);
}
async getRemote(remote: string): Promise<GitRemote | undefined> {
return (await this.getRemotes()).find(r => r.name === remote);
}
getRemotes(_options: { sort?: boolean } = {}): Promise<GitRemote[]> {
if (this._remotes == null || !this.supportsChangeEvents) {
if (this._providers == null) {
@ -722,6 +728,41 @@ export class Repository implements Disposable {
));
}
private async showCreatePullRequestPrompt(remoteName: string, branch: GitBranchReference) {
if (!Container.actionRunners.count('createPullRequest')) return;
if (!(await Messages.showCreatePullRequestPrompt(branch.name))) return;
const remote = await this.getRemote(remoteName);
const remoteInfo =
remote != null
? {
name: remote.name,
provider:
remote.provider != null
? {
id: remote.provider.id,
name: remote.provider.name,
domain: remote.provider.domain,
}
: undefined,
url: remote.url,
}
: { name: remoteName };
void executeActionCommand<CreatePullRequestActionContext>('createPullRequest', {
repoPath: this.path,
remote: remoteInfo,
branch: {
name: branch.name,
isRemote: branch.remote,
upstream: branch.tracking,
remote: remoteInfo,
repoPath: this.path,
},
});
}
private async pushCore(
options: {
force?: boolean;
@ -738,6 +779,7 @@ export class Repository implements Disposable {
if (options.publish != null) {
await repo?.push(options.publish.remote, options.reference.name, true);
void this.showCreatePullRequestPrompt(options.publish.remote, options.reference);
} else {
const branch = await this.getBranch(options.reference.name);
if (branch == null) return;

+ 13
- 0
src/messages.ts Wyświetl plik

@ -7,6 +7,7 @@ import { Logger } from './logger';
export enum SuppressedMessages {
CommitHasNoPreviousCommitWarning = 'suppressCommitHasNoPreviousCommitWarning',
CommitNotFoundWarning = 'suppressCommitNotFoundWarning',
CreatePullRequestPrompt = 'suppressCreatePullRequestPrompt',
FileNotUnderSourceControlWarning = 'suppressFileNotUnderSourceControlWarning',
GitDisabledWarning = 'suppressGitDisabledWarning',
GitVersionWarning = 'suppressGitVersionWarning',
@ -39,6 +40,18 @@ export class Messages {
);
}
static async showCreatePullRequestPrompt(branch: string): Promise<boolean> {
const create = { title: 'Create Pull Request...' };
const result = await Messages.showMessage(
'info',
`Would you like to create a Pull Request for branch '${branch}'?`,
SuppressedMessages.CreatePullRequestPrompt,
{ title: "Don't Show Again" },
create,
);
return result === create;
}
static async showGenericErrorMessage(message: string): Promise<MessageItem | undefined> {
const actions: MessageItem[] = [{ title: 'Open Output Channel' }];
const result = await Messages.showMessage(

Ładowanie…
Anuluj
Zapisz