Problem/Motivation
When posting a patch in the issue queue It might be useful to get a suggested name for the patch file.
Proposed resolution
This could be done similarly to the suggested commit message documented on: Advanced patch contributor guide
The format describe there is [project_name]-[short-description]-[issue-number]-[comment-number].patch
The button can be placed next to the 'Attach a file' button.

Remaining tasks
- all lower case (?)
- how many characters to use for the filename? now 60 from title
- input field instead of an window.input?
should this work for a new issue too? Yes- Get project shortname, from breadcrumb link? On the preview page this is not available
User interface changes
Button next to 'Attach a file' button.
Original report by helmo
When posting a patch in the issue queue it might be useful to get a suggested filename.
This could be done similarly to the suggested commit message.
The format is documented on: Advanced patch contributor guide
| Comment | File | Size | Author |
|---|---|---|---|
| #38 | dreditor.user-interface.1294662-38.patch | 7.89 KB | yesct |
| #38 | interdiff-37-38.txt | 740 bytes | yesct |
| #38 | please_use_this_value.png | 332.75 KB | yesct |
| #38 | core.png | 149.37 KB | yesct |
| #37 | dreditor.user-interface.1294662-37.patch | 7.89 KB | helmo |
Comments
Comment #0.0
clemens.tolboomUpdated issue summary.
Comment #1
clemens.tolboomComment #1.0
clemens.tolboomInserted issue summary template
Comment #2
helmo commentedThe button text doesn't feel intuitive, could include 'suggest'..
And isn't filename own word?
I propose: Suggest filename
Comment #3
clemens.tolboomThis is about a patch name suggestion so how about moving it on top.
I clicked the button already so the name is placed to the right. It's behaviour should be the same as from 'Create commit message'
Maybe "Show patch name" is better.
Comment #4
helmo commentedLooks nice, I'd love to see a patch for this.
Comment #5
clemens.tolboomAttached patch is a first stab.
Comment #6
helmo commentedI've removed the trailing underscore and let Drupal.behaviors.dreditorCommitMessage reuse your Drupal.dreditor.issueTitle() funtion.
Thanks for the push privilege on your sandbox.
The desired format has changed on us, we now also need the project short name. I havn't been able to find that in the dom tree... :(
New version from http://drupal.org/node/1054616:
[project_name]-[short-description]-[issue-number]-[comment-number].patch
I'll update the issue summary.
Comment #6.0
helmo commentedAdded image
Comment #7
clemens.tolboomPlease add a new screenshot to the issue summary and a patch to this issue :)
Comment #8
helmo commentedComment #8.0
helmo commentedformat changed on http://drupal.org/node/1054616
Comment #9
helmo commentedI just re-pushed a branch called patchname-1294662 to http://drupalcode.org/sandbox/clemenstolboom/1125712.git/shortlog/refs/h...
It's rebased on the latest master
Comment #9.0
helmo commentedAdded an extra remaining task
Comment #10
yesct commentedI'm not experienced with sandboxes, can we get a patch posted here?
I was just about to open an issue asking for this and I'm happy to see there is already progress!
Comment #11
helmo commentedSure, here's a patch.
Another way to get it is: http://drupalcode.org/sandbox/clemenstolboom/1125712.git/commitdiff_plai...
Comment #12
yesct commentedthe patch in #11 does not seem to have the change to use the pattern mentioned in #6 (it's missing the project name)
For example, for this issue, I get a suggested patch name:
Suggest_filename_for_attachment_in_issue_comment-1294662-12.patch
ha! I see that the patch in 11, used the suggested patch name. :)
Comment #13
helmo commented@YesCTL That's true, it's still a Remaining task.
Please check the issue sumary. Suggestions are welcome to get this value.
Comment #14
yesct commentedoh, sorry, I miss read comment #6. Thanks for the clarification.
can we do some kind of searching and regular expression substring to get it from the breadcrumb?

Comment #15
helmo commentedSure we could, it feels a bit nasty though. And when in preview mode the breadcrumb is not included on the page.
I mentally postponed this to after Drupal.org migrates to D7. Unfortunately that seems to have stalled: https://drupal.org/project/issues/search/drupalorg?status[]=Open&issue_t...
Comment #16
yesct commented#1865822-5: Add new button 'Apply' beside existing 'Review' button is getting project name. might be helpful.
Comment #17
helmo commentedThanks for pointing me to that, I've included the breadcrumb parsing as a utility function.
Still with the caveat of not working in preview mode.
Comment #18
helmo commentedUpdated to let the code from #1865822: Add new button 'Apply' beside existing 'Review' button also use the new utility function.
Comment #19
attiks commentedLooking good and thanks for adding the helper functions.
Comment #20
yesct commentedI tested this too. it's working well.
Comment #21
helmo commentedOne more slight enhancement: Only add nid and comment number if that has a value.
Comment #22
sunNote that I had to commit a follow-up fix for the simplytest.me button, since JS on comment preview pages was completely broken.
But hm. I don't think I agree with this. Most people are using:
I personally prefer to use:
The literal issue title shouldn't be contained either way.
Unfortunately, we're not able to reliably determine the project shortname just on the HTML page output alone. We have JSON representations of issue nodes for quite some time already (e.g., http://drupal.org/node/1294662/project-issue/json), but apparently, that response is not cached at all - i.e., neither on the server, nor on the client-side - so it takes ~600 msecs to deliver that response, which in turn makes it unsuitable for usage in Dreditor.
So in the end, we could probably show a suggestion for
[nid]-[cid].patch, but I'm not sure whether that is worth the effort. It's not like anyone would actually care for the name of patch files to begin with...Comment #23
yesct commentedI think for the patch name, we should go with whatever it says in http://drupal.org/node/1054616
When that changes there, we can change dreditor.
People can still use any filename they want. At least what is in Advanced patch contributor guide is better over many things (which leave out the issue number).
We can open an issue to change what it recommends in the Advanced patch contributor guide.
Comment #24
helmo commented@sun: Thanks for the follow-up patch for simplytest.me, I had already merged it.
I agree that determining the project short name is not really reliable. But it's the best we can do for now. The json option would, besides being slow, also not work for new issues being created.
I'm totally with @YesCT on not duplicating the discussion that went into http://drupal.org/node/1054616
Comment #25
sunAt this point, I'm rather inclined to mark this issue won't fix — we have no reliable method to retrieve the project name, and the entire issue title definitely does not belong into a patch name; or at least, that should not be suggested as a recommended standard. In turn, that leaves us with the comment number and issue ID only (except that's not available on the issue creation form either) as the only reliable and sensible file name components. Additionally, there's no clarification that the suggested filename is only meant for .patch files, so there's a good chance for the intended novice audience to mistakenly upload interdiffs with the suggested filename, too.
All things combined, this change would add a lot of code (and possibly errors in edge-case scenarios) for a minor feature whose usefulness is questionable.
In case we want to investigate this further nevertheless, then I'd suggest to simplify the implementation and simply base the entire suggested patch filename on the available properties in the issue comment form; i.e., something like this:
With that, we'd end up with something alone the lines of this for Drupal core patches:
Could possibly use some additional component-massaging to strip away ".module" and " system" suffixes (and for contrib projects, we'd want to omit the standard "Code", "User interface", etc components entirely). Could also strip away the " core" suffix for the Drupal project.
Might even make sense to include the [major?] version number after the project (i.e., the first digit of the selected option label of the version field) to clarify whether a patch is against D8 or D7.
At the very least, such suggested filenames would be 100% more sensible and more appropriate.
Comment #26
yesct commentedre-reading the patch doc, it says:
[short-description]
is an 1-2 word summary about what the patch does with dashes between the words.
So, we could
a) limit the suggested patch name to ... 20 chars,
b) use a place holder the human would replace like -short_description-
c) leave it out, since I think the doc recommendation is meant to have a human put the short description there, and dreditor is not a human. so it cannot. :)
How about a) and hope that the humans put meaningful words there?
So, in core, the component is often the module in core, right? Let's use sun's suggestion.
that would yield something like:
drupal-core.toolbar.module-Add_something_to_fix-123456789-12.patch
The "button" is currently labeled "Patchname suggestion", so that might help communicating that it's a suggestion for patches.

We could add something in that pop up window like:
See the Advanced patch contributor guide http://drupal.org/node/1054616 for more details.
So that tests are not run on interdiffs, use the .txt extension, for example: interdiff.txt
Setting to needs work to get sun's concerns addressed.
Comment #27
sunNote: As soon as you automate something, "all hope is lost."
Therefore, a) and b) will not work out. People will click the button, copy the string, and use it literally.
Cutting the first words will also not work out - lots of issues start with "Allow to perform..." and similar wordings. Patch file names of
drupal.form.allow-to-perform.1029404-13.patchwould be senseless. ;)I'd be OK with moving on with a trivial and simple implementation à la #25; i.e., KISS:
whereas:
" core"suffix for Drupal project. And.replace(/[^a-zA-Z0-9]+/, '-').toLowerCase()..substring(1)..replace(/[^a-zA-Z0-9]+/, '-').toLowerCase().Comment #28
helmo commentedI've done some more groundwork.
* extra util functions
* Contained the util functions in: Drupal.dreditor.issue.*
* distinction between core and contrib (e.g. dreditor7.user-interface-.... would be misleading about the version.)
Comment #29
yesct commentedI started fixing some comment issues. But then I realized that this is broke in some ways.
when #28 is applied, the Create commit message does not work (it jumps to the beginning of the page).
Also, it does not work on core issues like http://drupal.org/node/1917212, for example, the patchname suggestion does not work there either.
I fixed the comments anyway.
I think it makes sense to take the title out of contrib patch suggestions too, for the same reasons as leaving it out from core ones.
I put a dot in as a divider between the component and the issue number... since the component has a dash in it, dash for the separator there is confusing.
We could change the component - to be _ ... but I dont think that's really the way to go.
Someone else will have to figure out the still broken parts, as I dont know how.
Comment #30
helmo commentedBoth should be fixed now. I also added some more comment about the version related functions
Comment #31
yesct commentedthe version is not working..
for example in #1294662: Suggest patchname in issue comment
drupal.x.language-system.365615-141.patch
Also, I dont know how careful we want to be with comments but...
beginning of comment block uses two stars like..
this happens several places in this patch.
Also, some sentences in a few places are missing period at the end.
Also, if you name the interdiff something like interdiff-X-Y.txt, then it will not get the simplytest.me button.. applying an interdiff to test does not really make sense. :)
those are nits, small things.
setting needs work for the version number for core though.
Comment #32
thejamesjones commentedi did a git clone of dreditor and saved the patch from #30. Then I did a git apply and got error patch failed dreditor.user.js:717
I am going to follow these instructions to reroll, http://drupal.org/patch/reroll.
Comment #33
thejamesjones commentedI have tried to reroll this patch with these instructions, http://drupal.org/patch/reroll and have found that the last two patched #29 and #30 did not apply.
YesCT and I are confused.
Comment #34
ZenDoodles commentedThe patches in #29 and #30 applied cleanly at 590d2ed, but there was a merge conflict with code committed later (probably febe205e).
These still need manual testing.
Comment #35
yesct commentedManual testing:
all my dreditor goodness is gone.
Comment #36
yesct commentedComment #37
helmo commented#34 seems to be missing the removal of a closing brace '}'.
I've included it's comment updates, but the other changes didn't make sense.
I've also fixed the comment blocks as mentioned in #31.
Comment #38
yesct commentedsmall fix to add punctuation to sentence.
also an extra newline removed.
here is an updated screenshot

here is what one looks like on core:
drupal8.configuration-system.1653026-52.patch
And when I change the value of the version (and/or component) in the dropdowns on the comment, the patch name suggestion changes to match too.
drupal7.configuration-system.1653026-52.patch
rtbc since my changes are two small comment fixes.
Maybe a follow-up to add a link to more info on patch names?
http://drupal.org/node/1054616
(mentioned in #26)
which can say See http://drupal.org/node/1054616 for more information on patch naming conventions including interdiff.txt and do-not-test.patch
Comment #39
yesct commented@sun I think this addressed your previous concerns. Anything that needs work here?
Would be helpful to get this in before the Get Involved Sprint at portland. :)
Comment #40
kristen polJust tested and works great! Woohoo :) RTBC++
Comment #41
yesct commentedI just checked, it applies with hunk offset ok, so dont need a reroll.
and it still works fine.
:)
Comment #42
markhalliwellFixed in commit 17bcb89.
Comment #43.0
(not verified) commentedupdated remaining todo's