From cd78e02096ffe210ede99f90d794ce4ba3f727c7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=A9my=20Coutable?= <remy@rymai.me>
Date: Tue, 22 Nov 2016 19:13:41 +0100
Subject: [PATCH] Ensure we sanitize branch names with path-unfriendly
 characters
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Rémy Coutable <remy@rymai.me>
---
 lib/gitlab/ee_compat_check.rb | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/gitlab/ee_compat_check.rb b/lib/gitlab/ee_compat_check.rb
index f4d1505ea91..c8e36d8ff4a 100644
--- a/lib/gitlab/ee_compat_check.rb
+++ b/lib/gitlab/ee_compat_check.rb
@@ -149,7 +149,7 @@ module Gitlab
     end
 
     def ce_patch_name
-      @ce_patch_name ||= "#{ce_branch}.patch"
+      @ce_patch_name ||= patch_name_from_branch(ce_branch)
     end
 
     def ce_patch_full_path
@@ -161,13 +161,17 @@ module Gitlab
     end
 
     def ee_patch_name
-      @ee_patch_name ||= "#{ee_branch}.patch"
+      @ee_patch_name ||= patch_name_from_branch(ee_branch)
     end
 
     def ee_patch_full_path
       @ee_patch_full_path ||= patches_dir.join(ee_patch_name)
     end
 
+    def patch_name_from_branch(branch_name)
+      branch_name.parameterize << '.patch'
+    end
+
     def step(desc, cmd = nil)
       puts "\n=> #{desc}\n"
 
-- 
GitLab