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

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2022-10-27 08:53:15 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2022-10-28 09:10:16 +0300
commit9f3a9eb9501d6b488be2cbef29f609d8a0bb249f (patch)
tree5a4341528f1d85a657d28f5ead2921ae733773ac
parent63ac3f44daa1ec965dfe63fe281d22194effb300 (diff)
tools/protogem: Merge helper script into `build-proto-gem`
The helper functions in `run.rb` had in the past been used by multiple different scripts. Nowadays there is only a single user though, so let's inline it.
-rwxr-xr-xtools/protogem/build-proto-gem32
-rw-r--r--tools/protogem/run.rb36
2 files changed, 30 insertions, 38 deletions
diff --git a/tools/protogem/build-proto-gem b/tools/protogem/build-proto-gem
index 0cfdd047a..ee5fc94df 100755
--- a/tools/protogem/build-proto-gem
+++ b/tools/protogem/build-proto-gem
@@ -4,8 +4,6 @@ require 'erb'
require 'fileutils'
require 'tmpdir'
-require_relative 'run.rb'
-
File.umask(0022)
SOURCE_DIR = File.absolute_path(File.join(__dir__, '..', '..'))
@@ -112,6 +110,36 @@ def write_ruby_requires(output_dir)
open(gem_root, 'w') { |f| f.write(gem_root_template.result(binding)) }
end
+def run!(cmd, chdir='.')
+ GitalySupport.print_cmd(cmd)
+ unless system(*cmd, chdir: chdir)
+ 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
+
unless ARGV.count == 1
warn "Usage: #{$0} OUTPUT_PATH"
abort
diff --git a/tools/protogem/run.rb b/tools/protogem/run.rb
deleted file mode 100644
index e7d29a1e8..000000000
--- a/tools/protogem/run.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-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