microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.67k stars 29.07k forks source link

Use `PULL_REQUEST_TEMPLATE.md` to create `Pr` if `PULL_REQUEST_TEMPLATE.md` exists in `.github` directory (a feature of `Github` extension). #143083

Closed zys864 closed 2 years ago

zys864 commented 2 years ago

Use PULL_REQUEST_TEMPLATE.md to create Pr if PULL_REQUEST_TEMPLATE.md exists in .github directory.

Not just using latest commit to create Pr.

gjsjohnmurray commented 2 years ago

Are you using an extension which adds the ability to create a PR? If so, please report the issue on the extension repo. The Report Issue dialog from VS Code's Help menu may be able to assist you.

/needsMoreInfo

zys864 commented 2 years ago

Are you using an extension which adds the ability to create a PR? If so, please report the issue on the extension repo. The Report Issue dialog from VS Code's Help menu may be able to assist you.

/needsMoreInfo

Yes, after recheck,it's a feature of Github extension,which seems to be a builtin VsCode exttension.

joaomoreno commented 2 years ago

Yes, after recheck,it's a feature of Github extension,which seems to be a builtin VsCode exttension.

Can you give me the full name of the extension? Maybe a screenshot of it in the product? Or the view where you can create a PR?

zys864 commented 2 years ago

Can you give me the full name of the extension? Maybe a screenshot of it in the product? Or the view where you can create a PR?

The full name is exactly github

drawing

Here is I create Pr

Screenshot_20220218_151738

babakks commented 2 years ago

@joaomoreno I'd like to fix it. Any leads are appreciated.

joaomoreno commented 2 years ago

Sure, this would be a great starting point: https://github.com/microsoft/vscode/blob/4a130c40ed876644ed8af2943809d08221375408/extensions/github/src/pushErrorHandler.ts#L91

joaomoreno commented 2 years ago

Verification:

  1. Run Git: Clone and clone https://github.com/joaomoreno/test-pr-templates/
  2. Create a branch
  3. Make a change to README.md and commit
  4. Attempt to push/publish that branch. Code should tell you you can't push to that repo and will offer to fork the repository, accept.
  5. Code should then ask you whether you'd like to create a PR, accept.

You should get shown exactly 9 PR templates to choose from.

Reference: https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/creating-a-pull-request-template-for-your-repository

babakks commented 2 years ago

@joaomoreno I tried but after selecting a repository to fork (which then successfully creates a fork on Github) nothing is pushed without any error message. However, the developer console and the Git extension logs show this: Screenshot from 2022-04-27 15-26-46

It seems the source of the problem lies here when calling addRemote:

// Issue: what if there's already an `upstream` repo?
await repository.renameRemote(remote.name, 'upstream');

// Issue: what if there's already another `origin` repo?
await repository.addRemote('origin', ghRepository.clone_url);

Maybe no rename occurs when calling renameRemote (with no exception thrown).

joaomoreno commented 2 years ago

Very strange, can you easily reproduce? Delete your fork and try again.

babakks commented 2 years ago

Yes. I checked it several times and the results were the same.

joyceerhl commented 2 years ago

I did get the list of PR templates: image

However, I had no way to get back to the picker after taking that screenshot (which dismissed the picker). At minimum I feel we should use ignoreFocusOut: true, since the Create PR functionality is not exposed as a command palette command, I am stuck.

Additionally, after I selected a template to create the PR, nothing happened.

Finally, it was unexpected that I get two popups to create a PR when the GitHub Pull Requests and Issues extension is installed: image

babakks commented 2 years ago

@joyceerhl You mean no PR was created, right? Nonetheless, I think the Github extension needs more visible error messages (e.g., via notifications).

joyceerhl commented 2 years ago

@babakks Yes, no PR was created (I checked on GitHub).

joaomoreno commented 2 years ago

Created two issues from the discoveries. 👌 Thanks!

joaomoreno commented 2 years ago

Actually three. Creating a PR just doesn't work at all anymore: https://github.com/microsoft/vscode/issues/148326

rzhao271 commented 2 years ago

For step 4, when I try publishing the branch, I get the error "Git: remote: Permission to joaomoreno/test-pr-templates.git denied to rzhao271." There is no option to create a fork: Screenshot showing modal dialog. None of the options are to create a fork

joaomoreno commented 2 years ago

@rzhao271 Is the Github extension enabled for you?

rzhao271 commented 2 years ago

Just confirmed that it's enabled for me.

joaomoreno commented 2 years ago

Can you file a separate issue? 👌

joyceerhl commented 2 years ago

Verification of this issue fails since the user is no longer prompted to create a PR as found in https://github.com/microsoft/vscode/issues/143083#issuecomment-1113597175 :/

joaomoreno commented 2 years ago

Verification of this issue fails since the user is no longer prompted to create a PR as found in #143083 (comment) :/

Wait you hit this too? I totally can't repro, that's why I asked to follow up with a separate issue. We can move this to May just for verification sake.

joyceerhl commented 2 years ago

Yeah I hit the same thing as @rzhao271

stuartleeks commented 2 years ago

I just tried testing this:

On pushing the new branch, I get image

and then: image

TylerLeonhardt commented 2 years ago

Reopening due to @stuartleeks's comment but @joaomoreno feel free to do what you want with this

connor4312 commented 2 years ago

I got the same issue on the latest Insiders

image

Command output:

> git push -u origin test-branch
ERROR: Permission to joaomoreno/test-pr-templates.git denied to connor4312.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Remote URL:

> git config --get remote.origin.url
git@github.com:joaomoreno/test-pr-templates.git
joaomoreno commented 2 years ago

@connor4312, this is https://github.com/microsoft/vscode/issues/148568

joaomoreno commented 2 years ago

Moving verification to July to account for https://github.com/microsoft/vscode/issues/148568#issuecomment-1173021392