011-299-3222 平日9:00~18:00
Gitのブランチに日本語名をつけるとRedmineのリポジトリでエラーになる
2015.05.26

当社では、今のところGitHubは利用せず、Redmineと連携できるよう自社サーバに共有レポジトリを設置しているのですが、あるプロジェクトでRedmineからリポジトリ表示をすると500 Internal Errorが出るようになってしまいました。

環境:Redmine 3.0.2

これがRedmineのログです。


Started GET "/projects/xxxxxxxx/repository" for 124.27.47.87 at 2015-05-21 13:06:19 +0900
Processing by RepositoriesController#show as HTML
Parameters: {"id"=>"xxxxxxxx"}
Current user: techguy (id=4)
Rendered repositories/_navigation.html.erb (4.6ms)
Rendered repositories/show.html.erb within layouts/base (5.2ms)
Completed 500 Internal Server Error in 77ms (ActiveRecord: 3.9ms)

ActionView::Template::Error (incompatible character encodings: UTF-8 and ASCII-8BIT):
14: {:method => :get, :id => 'revision_selector'}) do -%>
15:
16: <% if !@repository.branches.nil? && @repository.branches.length > 0 -%>
17: | <%= l(:label_branch) %>:
18: <%= select_tag :branch, 19: options_for_select([''] + @repository.branches, @rev), 20: :id => 'branch' %>
app/views/repositories/_navigation.html.erb:17:in `block in _app_views_repositories__navigation_html_erb__700850824826937634_69911509794400'
app/views/repositories/_navigation.html.erb:9:in `_app_views_repositories__navigation_html_erb__700850824826937634_69911509794400'
app/views/repositories/show.html.erb:4:in `_app_views_repositories_show_html_erb__469836598202794006_69911509622880'
app/controllers/repositories_controller.rb:125:in `show'

どうやら、ブランチのselectタグ出力でエラーになっているようなので、ブランチを見てみるとブランチ名が日本語でつけられていました。
社内のGitクライアントはSourceTreeが主流で、その環境では問題なく運用できているのですが、Redmineとの連携のために、ブランチ名は英数にしてもらうことで対応しました。