Adds GitLens integration for creating a PR - #2386
Conversation
Alows the "compare" branch to be different than the current branch
Rachel Macfarlane (RMacfarlane)
left a comment
There was a problem hiding this comment.
This is great!
| 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? |
There was a problem hiding this comment.
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 => { |
| @@ -0,0 +1,55 @@ | |||
| 'use strict'; | |||
There was a problem hiding this comment.
microsoft header?
There was a problem hiding this comment.
Should it have one? As its from GitLens not MS
| commands.executeCommand('pr.create', { repoPath: context.repoPath, compareBranch: context.branch.name }); | ||
| } | ||
| }), | ||
| // api.registerActionRunner('openPullRequest', { |
There was a problem hiding this comment.
remove this for now?
There was a problem hiding this comment.
Yeah, I'm planning on finishing it before we merge
| 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? |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
| this._disposables.push(vscode.window.registerWebviewViewProvider(CreatePullRequestViewProvider.viewType, this._createPRViewProvider)); | ||
| } | ||
|
|
||
| // TODO@eamodio ensure compareBranch matches the current provider |
There was a problem hiding this comment.
meaning if create is called again but with a different compareBranch?
4ef13f1 to
f74f009
Compare
| name: 'GitHub Pull Requests and Issues', | ||
| label: 'Create Pull Request', | ||
| run: function (context: CreatePullRequestActionContext) { | ||
| // For now only work with branches that aren't remote |
There was a problem hiding this comment.
should there be any kind of notification to let the user know this?
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.