Repository navigation
Allow choosing a blank issue/pr template - #950
Conversation
2de508f to
e8741b9
Compare
e8741b9 to
6effcd4
Compare
|
In testing this I noticed our bug fix template has no name (not an issue when we weren't previously displaying it in a select menu); I pushed a commit to give it a name. |
I had also noticed that, and was going to point it out, but then I think it slipped my mind 😅 |
dd4924c to
bd7790f
Compare
There was a problem hiding this comment.
This looks good to me, but I wonder whether we're still keeping parity with dotcom here.
When opening issues in web UI, users only get presented with a template picker + "open a blank issue" option when there are .github/ISSUE_TEMPLATE/*.md files only. When "blank issue" is chosen, a template from .github/ISSUE_TEMPLATE.md is used if it exists, or actually blank if not.
When opening pull requests in web UI, users never get presented with a template picker (as far as I know?), but users can pick a template by passing a ?template=<filename> query parameter. We deviate from web by showing a picker for .github/PULL_REQUEST_TEMPLATE/*.md files, and I think that's ok to keep.
But if we wanted to match what dotcom is doing, then .github/{ISSUE,PULL_REQUEST}_TEMPLATE.md files (i.e. templates that aren't grouped under a directory) should never show up in a picker, but should get used either A) by default (if there was no picker), or B) when the user has chosen "blank" from the picker.
Right. Seems the right way to go. |
|
Yes, please amend this PR! Thank you |
8fe22e9 to
01f272d
Compare
|
|
||
| // Find returns the list of template file paths | ||
| func Find(rootDir string, name string) []string { | ||
| // FindNonLegacy returns the list of template file paths from the template folder (according to the "upgraded multiple template builder") |
There was a problem hiding this comment.
GitHub refers to the original way of PULL_REQUEST_TEMPLATE.md and ISSUE_TEMPLATE.md files as 'legacy' and the new method of PULL_REQUEST_TEMPLATE and ISSUE_TEMPLATE folders containing the template files as "upgraded multiple template builder".
I have hence called them as legacy and nonlegacy
| url.QueryEscape(body), | ||
| ) | ||
| } else if len(templateFiles) > 1 { | ||
| } else if len(nonLegacyTemplateFiles) > 1 { |
There was a problem hiding this comment.
The /choose route is to be opened only if we have non-legacy templates. If there is a legacy template only, it is selected by default by GitHub
|
@AliabbasMerchant Thanks for the updates! Note for the future: it's easier for us to go through review cycles if you refrain from force-pushing the branch. In general, we avoid force-pushing while multiple people are either working on or reviewing a branch. After a force-push, it's hard for us to tell exactly which code is new since last review. When the PR is approved to merge, we can always clean up the history by doing a rebase before the big merge. |
9c6103c to
4fd051b
Compare
|
@mislav Right, sorry. I won't force push from now on. Will clean up the history only after the PR is approved. |
|
In accordance with @mislav 's suggestion, the new workflow is as follows:
When the NonLegacyTemplates are present, the user is given a prompt to choose from them and a blank template(which defaults to the LegacyTemplate, if it is there, or an empty body) There are currently no tests for template selection, but @vilmibm and I working on them in #986 |
mislav
left a comment
There was a problem hiding this comment.
Code looks good to me! I will need until next week to manually test to verify behavior, and perhaps I would shuffle some code around, but for now I don't have specific suggestions. Thank you for your hard work!
| } | ||
|
|
||
| if got := Find(tt.args.rootDir, tt.args.name); !reflect.DeepEqual(got, tt.want) { | ||
| if got := FindLegacy(tt.args.rootDir, tt.args.name); *got != tt.want { |
There was a problem hiding this comment.
How come you were able to remove DeepEqual comparison from here?
There was a problem hiding this comment.
Coz tt.want is just a string now, since we only have at most a since legacy template file
|
@mislav Did you get the chance to test this out? |
|
Any updates? |
|
I have tried this out and it works great for me! Thank you |
| if baseOverride == "" { | ||
| if rootDir, err := git.ToplevelDir(); err == nil { | ||
| // TODO: figure out how to stub this in tests | ||
| legacyTemplateFile = githubtemplate.FindLegacy(rootDir, "ISSUE_TEMPLATE") |
There was a problem hiding this comment.
I noticed that "ISSUE_TEMPLATE" string is used in multiple parts of the code. Could it be added to a constant?
|
@safv12 Thats a nice suggestion. I have noticed that there are a few more such constants also, lying around in the codebase, (some of which even had the TODO, to shift them to a constants file). |
template chooser tests will be addressed in a separate changeset
|
@AliabbasMerchant @safv12 Each |
Fixes #504