From 1875141a963a4238bda29011d8f7105839485253 Mon Sep 17 00:00:00 2001
From: Dale Hamel <dale.hamel@srvthe.net>
Date: Tue, 8 Oct 2013 13:36:16 -0500
Subject: [PATCH] Ensure directory exists before changing in popen

If the directory does not exist, we want to ensure that it does.

Forking repos will fail in some situations because of this issue.
---
 lib/gitlab/popen.rb | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/lib/gitlab/popen.rb b/lib/gitlab/popen.rb
index 2f30fde2078..369d6cc1f5d 100644
--- a/lib/gitlab/popen.rb
+++ b/lib/gitlab/popen.rb
@@ -1,9 +1,16 @@
+
+require 'fileutils'
+
 module Gitlab
   module Popen
     def popen(cmd, path)
       vars = { "PWD" => path }
       options = { chdir: path }
 
+      unless File.directory?(path)
+       FileUtils.mkdir_p(path)
+      end
+
       @cmd_output = ""
       @cmd_status = 0
       Open3.popen3(vars, cmd, options) do |stdin, stdout, stderr, wait_thr|
-- 
GitLab