Skip to content

Adds GitLens integration for creating a PR - #2386

Merged
Rachel Macfarlane (RMacfarlane) merged 3 commits into
masterfrom
feature/gitlens
Jan 25, 2021
Merged

Adds GitLens integration for creating a PR#2386
Rachel Macfarlane (RMacfarlane) merged 3 commits into
masterfrom
feature/gitlens

Conversation

@eamodio

Copy link
Copy Markdown
Contributor

Here is the first pass at adding GitLens integration to hook into PR creation.

This also allows the "compare" branch to be different than the current branch. I haven't setup everything up yet to allow the compare branch to be changed in the view, but I don't think that will be much to add on.

Alows the "compare" branch to be different than the current branch

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great!

Comment thread src/github/createPRViewProvider.ts Outdated
private async create(message: IRequestMessage<OctokitCommon.PullsCreateParams>): Promise<void> {
try {
if (!this._folderRepositoryManager.repository.state.HEAD!.upstream) {
// TODO@eamodio Why do we assume this is a detached head? if the upstream is missing isn't it just unpublished?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this doesn't make sense, this check should just be completely removed. createPullRequest will check if there is an upstream and offer to publish if not. Thanks for catching!

}

const prRelatedUsersPromise = new Promise(async resolve => {
const prRelatedUsersPromise = new Promise<void>(async resolve => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -0,0 +1,55 @@
'use strict';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

microsoft header?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it have one? As its from GitLens not MS

Comment thread src/integrations/gitlens/gitlensImpl.ts Outdated
commands.executeCommand('pr.create', { repoPath: context.repoPath, compareBranch: context.branch.name });
}
}),
// api.registerActionRunner('openPullRequest', {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this for now?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm planning on finishing it before we merge

Comment thread src/view/createPullRequestHelper.ts Outdated
this._createPRViewProvider = new CreatePullRequestViewProvider(extensionUri, folderRepoManager, pullRequestDefaults, !!isDraft);
this._treeView = new CompareChangesTreeProvider(this.repository, pullRequestDefaults.owner, pullRequestDefaults.base, folderRepoManager);
const branch = (compareBranch ? await folderRepoManager.repository.getBranch(compareBranch) : undefined) ?? folderRepoManager.repository.state.HEAD;
// TODO@eamodio what should we do if there is no valid branch?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in what situations is HEAD undefined? I think it would be sane to error out here and show a notification, but we could look for any other local branches first

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a rebase -- but not sure what the our Git api does in that case. It probably won't be undefined but probably won't be a valid branch either. Another case is a repo that has no branches yet, but that's an edge case

Comment thread src/view/createPullRequestHelper.ts Outdated
this._disposables.push(vscode.window.registerWebviewViewProvider(CreatePullRequestViewProvider.viewType, this._createPRViewProvider));
}

// TODO@eamodio ensure compareBranch matches the current provider

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

meaning if create is called again but with a different compareBranch?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah

name: 'GitHub Pull Requests and Issues',
label: 'Create Pull Request',
run: function (context: CreatePullRequestActionContext) {
// For now only work with branches that aren't remote

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should there be any kind of notification to let the user know this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants