Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • G gitlabhq1
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 21
    • Issues 21
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 12
    • Merge requests 12
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Infrastructure Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • gpt
  • large_projects
  • gitlabhq1
  • Merge requests
  • !1424

Merged
Created Sep 10, 2012 by Administrator@rootOwner

FIX: Empty string in commit message

  • Overview 5
  • Commits 2
  • Changes 2

Created by: elvanja

Fixed commit title when commit message is an empty string and ensured that link_to_gfm helper doesn't break on empty body.

This one is related to https://github.com/gitlabhq/gitlabhq/pull/1343, it breaks the commits project page. The previous solution didn't cover the situation where commit message is an empty string. In that case, the #title decorator method would return nil for the title, and the link_to_gfm helper would break.

Unfortunately, the "empty string" messages are a remnant of TFS repositories being converted. But, it could also be an issue with new commits (-m "").

Wasn't sure on how to approach since empty string is not nil, should it be considered a commit message or not. Chose to make it a "non message". Maybe you can change the decorator like this too:

  def title
    return no_commit_message unless safe_message

    title_end = safe_message.index(/\n/)
    if (!title_end && safe_message.length > 80) || (title_end && title_end > 80)
      safe_message[0..69] << "&hellip;".html_safe
    else
      safe_message.split(/\n/, 2).first || ""
    end
  end

As for the helper, it is just a minor update, to ensure that at least it won't break if somehow empty/nil string is passed into it.

Assignee
Assign to
Reviewer
Request review from
Time tracking
Source branch: github/fork/elvanja/issue-1343-empty-string-fix