Here is a patch that adds a link to any comment attachment that is a patch.
On drupal.org, the link path would be http://drupal.org/patch/apply :)
This would be an extremely useful feature on d.org, as I have lost count of the number of times this happens:
Poster: HALP! a bug!
Maintainer: Here is a patch. Please test.
Poster: What do I do with this file? (or: 'I put the file in my module directory and nothing happens', etc etc.
Maintainer: (has to link to http://drupal.org/patch/apply yet again....)
| Comment | File | Size | Author |
|---|---|---|---|
| #18 | With-help-4-new-users.png | 43.42 KB | mgifford |
| #18 | https-::drupal.org:files:issues:619650-2.drupalorg.patch-link-for-n00bs-619650-18.patch | 1.04 KB | mgifford |
Comments
Comment #1
joachim commentedI've spoken to dww on IRC and we're both thinking this might be better off in the Drupal.org infrastructure module.
Setting back to 'needs work'.
Comment #2
joachim commentedOops, wrong project.
Comment #3
joachim commentedPatch on the drupal.org module, 6--1 branch.
Comment #4
dwwYeah, much better to just have a trivial patch like this to hard-code it in drupalorg.module than trying to make this a generic feature of project_issue. However:
A) We should probably add this link for both .diff and .patch files.
B) This sure is weird:
Why the fun with the
</a>hackery? :( It'd be nice to have a more clear comment about what's going on here. Better yet, don't do this weird stuff. ;) Instead, just loop over all the attachments, and if we see any .patch or .diff, we append a description to the attachment table with the link in smaller help-text print. I don't see why we need N links if there are N patches.Thanks!
-Derek
Comment #5
joachim commentedThe hackery is necessary as far as I can tell, because there's no other way to get extra stuff into theme_comment_upload_attachments() / template_preprocess_comment_upload_attachments(). It's a while since I looked at this, but there wasn't a cleaner way.
And AFAIK there's no way of getting to the end of the attachments table. It's also fairly rare to have two patches on a single comment, so if anything putting the link after the table is just going to look odd on all the singletons.
See http://drupalcode.org/viewvc/drupal/contributions/modules/comment_upload...
Comment #6
joachim commentedHaving spoken on IRC, here's an alternative approach:
- add a description of the attachments table to comment_upload's template file (which alone does absolutely nothing).
- set that when there is at least one patch or diff file.
Would need some CSS in the site theme to make the link in the P smaller, maybe look like grey form description text?
Comment #7
damienmckenna+1 from me, this is a regular request on almost all project issue queues.
Comment #8
klonos...coming from #1308382: Add a "how to apply this patch" link next to uploaded patches.. I can't tell what this patch actually does to the d.o UI, but here's how things could look like:
Comment #9
joachim commentedThe above method is probably obsolete.
It was written before we had patch testing. pift_comment() gets extra links in by doing a preg_replace() to remove the original comment attachment table (!!!!).
I guess if we're already committed to using a preg_replace, we could have a module that does this and then invokes a hook to request extra links. Then pift would provide some and so would the drupalorg module.
Comment #10
klonos...setting back to active then?
Comment #11
klonos...and a better issue title ;)
Comment #12
joachim commentedYup, so to expand on my earlier post, I reckon the way to do this is:
- cope the preg_replace() technique from pift_comment into a new project_issue_comment().
- instead of just calling a theme function to make the table, this should invoke a new hook to request extra content to put into the comment upload table. Possibly drupal_alter() the table's data structure before it's passed to theme_table()?
- pift module then adds its information and links using this hook
- the Drupal.org customizations module also implements this hook to add the patch help link
Obviously quite a bit of work, so it would be good to get some sort of approval of the plan by the maintainers first :)
Comment #13
joachim commentedSorry, didn't mean to change the status.
Comment #14
mgiffordDuplicate?
Comment #15
markhalliwellHere's the screenshot of some quick DOM/style manipulation I did from the other issue:

Comment #16
joachim commentedThat looks super! :)
Comment #17
klonosPerfect! What's the next step? Do we actually code something or ask for usability reviews first?
Comment #18
mgiffordHow about we see if this works for folks.
It's up and running here:
http://search_api-drupal.redesign.devdrupal.org/node/2153891
It still needs some work though as it should only appear under files that have a patch (rather than an image, an interdiff, a text file or zip file.).
Comment #19
klonos...plus it should also appear below the files table located in the issue summary.
Comment #20
markhalliwellAgreed, it shouldn't be in nodechanges at all, but probably project_issue_file_test.
Comment #21
markhalliwellComment #22
markhalliwellActually I lied, sorry. It should remain in drupalorg. It contains a link that is specific to d.o. The code should be changed in the drupalorg_project sub-module.
Comment #23
damienmckennaSeeing as the patch is in Needs Work, I suggest adding a little bit of logic to verify there's an actual patch file before outputting it - it might add some confusion if an issue just has images attached and someone sees instructions for applying patches.
Comment #24
yesct commentedComment #25
joachim commented> I suggest adding a little bit of logic to verify there's an actual patch file before outputting it
There's that logic in patch #6, which can be reused.
Comment #26
joachim commentedIt looks like the way to do this without hacking nodechanges module would be to either implement the alter hook or do a theme preprocess:
-- that's in nodechanges_field_formatter_view().
Comment #27
drummPatches should not be uploaded now, and we won’t be able to add UI text to GitLab explaining patches when issues are migrated.