Skip to content
Snippets Groups Projects

Fix trailing space issue with merge requests and issues. Fixes #2514

Merged Drew Blessing requested to merge dblessing/gitlab-ce:fix_trailing_title_space into master

Fixes #2514 (closed) Strip whitespace from merge request and issue titles. Whitespace doesn't inherently cause problems for the title itself. However, in the event display we bold the title to show when it changes from x to y. This caused markdown to not display the event properly. See #2514 (closed) for an example of previous behavior.

Current behavior:

Screen_Shot_2015-10-08_at_3.16.18_PM

After proposed changes: (Since we strip whitespace I had to make an arbitrary change to the title to even generate an event. This is expected, though)

Screen_Shot_2015-10-08_at_3.17.28_PM

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Drew Blessing Added 879 commits:

    Added 879 commits:

    • 70b4bb90...680b6d88 - 878 commits from branch gitlab-org:master
    • 71b137b7 - Fix trailing space issue with merge requests and issues. Fixes #2514 (closed)
  • Author Maintainer

    @dzaporozhets Changed as requested

  • @dblessing do same refactoring for issue controller

  • Drew Blessing Added 1 commit:

    Added 1 commit:

    • 68e88222 - Fix trailing space issue with merge requests and issues. Fixes #2514 (closed)
  • @dblessing rebase, retrigger builds?

  • Author Maintainer

    @axil thanks for the ping. I rebased, added CHANGELOG entry, and hope tests pass. I will check back. If they pass will someone please merge? :) This is a nice easy fix that would be good to get merged and done.

  • Drew Blessing Added 653 commits:

    Added 653 commits:

    • 68e88222...193bc5fb - 652 commits from branch gitlab-org:master
    • 0f0f680a - Fix trailing space issue with merge requests and issues. Fixes #2514 (closed)
  • I assigned @dzaporozhets since he reviewed the code.

  • Author Maintainer

    @dzaporozhets In this way I'm getting undefined method strip!' for nil:NilClass. Is this how you meant it should work when you commented before? Thanks for helping me learn on this one.

    Edited by Drew Blessing
  • @dblessing its because title might not be present in params. Add extra check strip if title present

  • Author Maintainer

    @dzaporozhets Now I understand. I misunderstood your original instructions. I had 2 checks - if params[:merge_request] && params[:merge_request][:title] and you said moving it would eliminate the need for one of those. Thanks for clarifying.

  • @dblessing assign back to me when ready

  • @dblessing Did this fall through the cracks? I want to get this fixed!

  • Robert Speicher Milestone changed to 8.2

    Milestone changed to 8.2

  • Drew Blessing Added 111 commits:

    Added 111 commits:

    • 0f0f680a...ca25289b - 110 commits from branch gitlab-org:master
    • c070f993 - Fix trailing space issue with merge requests and issues. Fixes #2514 (closed)
  • Reassigned to @dblessing

  • Drew Blessing Title changed from Fix trailing space issue with merge requests and issues. Fixes #2514 (closed) to WIP: Fix trailing space issue with merge requests and issues. Fixes #2514 (closed)

    Title changed from Fix trailing space issue with merge requests and issues. Fixes #2514 (closed) to WIP: Fix trailing space issue with merge requests and issues. Fixes #2514 (closed)

  • Drew Blessing Added 1 commit:

    Added 1 commit:

    • 519581cb - Fix trailing space issue with merge requests and issues. Fixes #2514 (closed)
  • Author Maintainer

    Adding the strip! after the permit call results in ForbiddenAttributes error. I went back to the original which works. This is an example of how it was when I tried to put the strip after the permit. If I'm still doing it wrong, let me know.

    params.require(:merge_request).permit(
      :title, :assignee_id, :source_project_id, :source_branch,
      :target_project_id, :target_branch, :milestone_id,
      :state_event, :description, :task_num, label_ids: []
    )
    params[:merge_request][:title].strip! if params[:merge_request][:title].strip!
    params
    Edited by Drew Blessing
  • Drew Blessing Added 1 commit:

    Added 1 commit:

    • de53c6d7 - Fix trailing space issue with merge requests and issues. Fixes #2514 (closed)
  • Drew Blessing Title changed from WIP: Fix trailing space issue with merge requests and issues. Fixes #2514 (closed) to Fix trailing space issue with merge requests and issues. Fixes #2514 (closed)

    Title changed from WIP: Fix trailing space issue with merge requests and issues. Fixes #2514 (closed) to Fix trailing space issue with merge requests and issues. Fixes #2514 (closed)

  • Drew Blessing Added 1 commit:

    Added 1 commit:

  • Author Maintainer

    Now I figured it out. Makes total sense now. TIL

    Ready for review.

  • Author Maintainer

    Tests now passing

  • Author Maintainer

    Auto-retry would have been amazing here 😉

  • username-removed-444 Status changed to merged

    Status changed to merged

  • Please register or sign in to reply
    Loading