500 error on issue viewer when git repository is empty
Trying to open an issue on an empty repository (no code uploaded), I get a 500 error each time I try to view this specific issue. The body of the issue does not make any explicit reference on a commit hash but I think regex parsing assumes there is one and crashes at the end. The problem is verified in my gitlab installation and gitlab.com.
The log produced in my gitlab installation (6.9):
Started GET "/tolabaki/labaki-infrastructure/issues/4" for 91.140.91.50 at 2014-06-17 15:04:48 +0300
Processing by Projects::IssuesController#show as HTML
Parameters: {"project_id"=>"tolabaki/labaki-infrastructure", "id"=>"4"}
Completed 500 Internal Server Error in 77ms
ActionView::Template::Error (undefined method `sha' for nil:NilClass):
48: .description
49: .wiki
50: = preserve do
51: = markdown @issue.description
52: .context
53: %cite.cgray
54: = render partial: 'issue_context', locals: { issue: @issue }
app/helpers/gitlab_markdown_helper.rb:190:in `current_sha'
app/helpers/gitlab_markdown_helper.rb:171:in `file_exists?'
app/helpers/gitlab_markdown_helper.rb:147:in `relative_file_path'
app/helpers/gitlab_markdown_helper.rb:127:in `rebuild_path'
app/helpers/gitlab_markdown_helper.rb:72:in `block in create_relative_links'
app/helpers/gitlab_markdown_helper.rb:70:in `each'
app/helpers/gitlab_markdown_helper.rb:70:in `create_relative_links'
lib/redcarpet/render/gitlab_html.rb:52:in `preprocess'
app/helpers/gitlab_markdown_helper.rb:51:in `render'
app/helpers/gitlab_markdown_helper.rb:51:in `markdown'
app/views/projects/issues/show.html.haml:51:in `block in _app_views_projects_issues_show_html_haml__730927417537140019_55815820'
app/views/projects/issues/show.html.haml:50:in `_app_views_projects_issues_show_html_haml__730927417537140019_55815820'
app/controllers/projects/issues_controller.rb:58:in `show'
app/controllers/application_controller.rb:59:in `set_current_user_for_thread'
The body of the issue that is sufficient to reproduce this bug, even on gitlab.com ( check it here )
Jun 17 13:54:54 idea systemd[1]: sssd.service lacks ExecStart setting. Refusing.
I suppose that code tries to match git hashes found through markdown parsing but fails because there are no commits at all. Unfortunately I am not familiar with ruby to investigate further and provide a patch :( But I would love to see this fixed!