Commit da34e008c3b67b4d06ecc8a06a102271157f3c13

Authored by Dmitriy Zaporozhets
2 parents 1080a9ba 6d7ced4a

Merge pull request #5294 from dalehamel/master

Ensure directory exists before changing in popen
Showing 1 changed file with 6 additions and 0 deletions   Show diff stats
lib/gitlab/popen.rb
  1 +require 'fileutils'
  2 +
1 module Gitlab 3 module Gitlab
2 module Popen 4 module Popen
3 def popen(cmd, path) 5 def popen(cmd, path)
4 vars = { "PWD" => path } 6 vars = { "PWD" => path }
5 options = { chdir: path } 7 options = { chdir: path }
6 8
  9 + unless File.directory?(path)
  10 + FileUtils.mkdir_p(path)
  11 + end
  12 +
7 @cmd_output = "" 13 @cmd_output = ""
8 @cmd_status = 0 14 @cmd_status = 0
9 Open3.popen3(vars, cmd, options) do |stdin, stdout, stderr, wait_thr| 15 Open3.popen3(vars, cmd, options) do |stdin, stdout, stderr, wait_thr|