Commit 1875141a963a4238bda29011d8f7105839485253
Committed by
Dale Hamel
1 parent
358426d6
Exists in
spb-stable
and in
3 other branches
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.
Showing
1 changed file
with
7 additions
and
0 deletions
Show diff stats
lib/gitlab/popen.rb
1 | + | |
2 | +require 'fileutils' | |
3 | + | |
1 | 4 | module Gitlab |
2 | 5 | module Popen |
3 | 6 | def popen(cmd, path) |
4 | 7 | vars = { "PWD" => path } |
5 | 8 | options = { chdir: path } |
6 | 9 | |
10 | + unless File.directory?(path) | |
11 | + FileUtils.mkdir_p(path) | |
12 | + end | |
13 | + | |
7 | 14 | @cmd_output = "" |
8 | 15 | @cmd_status = 0 |
9 | 16 | Open3.popen3(vars, cmd, options) do |stdin, stdout, stderr, wait_thr| | ... | ... |