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....)

Comments

joachim’s picture

Project: Project issue tracking » Drupal.org infrastructure
Version: 6.x-1.x-dev »
Component: Comments » Drupal.org module
Status: Needs review » Needs work

I'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'.

joachim’s picture

Project: Drupal.org infrastructure » Drupal.org customizations
Component: Drupal.org module » Code

Oops, wrong project.

joachim’s picture

Status: Needs work » Needs review
StatusFileSize
new1.65 KB

Patch on the drupal.org module, 6--1 branch.

dww’s picture

Status: Needs review » Needs work

Yeah, 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:

+      $variables['attachments'][$id]['text'] .= '</a> - <a class="patch-help" href="' . DRUPALORG_PATCH_HANDBOOK_URL . '">Get help with patches';

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

joachim’s picture

The 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...

joachim’s picture

Status: Needs work » Needs review
StatusFileSize
new1.65 KB
new776 bytes

Having 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?

damienmckenna’s picture

Version: » 6.x-3.x-dev

+1 from me, this is a regular request on almost all project issue queues.

klonos’s picture

...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:

joachim’s picture

The 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.

klonos’s picture

Status: Needs review » Active

The above method is probably obsolete.

...setting back to active then?

klonos’s picture

Title: Provide a link to help with applying patches » Provide a link next to .patch attachments linking to help/documentation about applying patches.

...and a better issue title ;)

joachim’s picture

Status: Active » Needs review

Yup, 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 :)

joachim’s picture

Status: Needs review » Active

Sorry, didn't mean to change the status.

mgifford’s picture

Version: 6.x-3.x-dev » 7.x-3.x-dev
Issue summary: View changes
Related issues: +#2191271: Provide Shortcuts for Applying Patches

Duplicate?

markhalliwell’s picture

StatusFileSize
new68.62 KB

Here's the screenshot of some quick DOM/style manipulation I did from the other issue:

joachim’s picture

That looks super! :)

klonos’s picture

Perfect! What's the next step? Do we actually code something or ask for usability reviews first?

mgifford’s picture

How about we see if this works for folks.

It's up and running here:
http://search_api-drupal.redesign.devdrupal.org/node/2153891

Help for applying patch.

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.).

klonos’s picture

...plus it should also appear below the files table located in the issue summary.

markhalliwell’s picture

Project: Drupal.org customizations » Project issue file test
Version: 7.x-3.x-dev » 7.x-2.x-dev
Status: Needs review » Needs work

Agreed, it shouldn't be in nodechanges at all, but probably project_issue_file_test.

markhalliwell’s picture

Title: Provide a link next to .patch attachments linking to help/documentation about applying patches. » Add help text underneath files on how to apply patches that links to documentation
markhalliwell’s picture

Project: Project issue file test » Drupal.org customizations
Version: 7.x-2.x-dev » 7.x-3.x-dev

Actually 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.

damienmckenna’s picture

Seeing 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.

yesct’s picture

joachim’s picture

> 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.

joachim’s picture

It looks like the way to do this without hacking nodechanges module would be to either implement the alter hook or do a theme preprocess:

      if (!empty($files)) {
        $rows = _nodechanges_get_file_rows($files);
        $element = array(
          '#theme' => 'nodechanges_field_formatter_file_view',
          '#field_name' => $field_name,
          '#files' => $files,
          '#rows' => $rows,
          '#header' => array(t('Status'), t('File'), t('Size')),
        );
        drupal_alter('nodechanges_file_changes_element', $element, $context);
      }

-- that's in nodechanges_field_formatter_view().

drumm’s picture

Status: Needs work » Closed (outdated)

Patches should not be uploaded now, and we won’t be able to add UI text to GitLab explaining patches when issues are migrated.