Welcome to mirror list, hosted at ThFree Co, Russian Federation.

run.rb « _support - gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e7d29a1e835d05bac43eedde496c7f905314ca1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
def run!(cmd, chdir='.')
  GitalySupport.print_cmd(cmd)
  unless system(*cmd, chdir: chdir)
    GitalySupport.fail_cmd!(cmd)
  end
end

def run2!(cmd, chdir: '.', out: 1)
  GitalySupport.print_cmd(cmd)
  unless system(*cmd, chdir: chdir, out: out)
    GitalySupport.fail_cmd!(cmd)
  end
end

def capture!(cmd, chdir='.')
  GitalySupport.print_cmd(cmd)
  output = IO.popen(cmd, chdir: chdir) { |io| io.read }
  GitalySupport.fail_cmd!(cmd) unless $?.success?
  output
end

module GitalySupport
  class << self
    def print_cmd(cmd)
      puts '-> ' + printable_cmd(cmd)
    end

    def fail_cmd!(cmd)
      abort "command failed: #{printable_cmd(cmd)}"
    end

    def printable_cmd(cmd)
      cmd.join(' ')
    end
  end
end