Hash :
d09b2d10
Author :
Thomas de Grivel
Date :
2023-02-26T02:59:01
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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
#!/usr/bin/env ruby
load "#{File.dirname(File.dirname(__FILE__))}/lib/rbpkg.rb"
$ARGS = ARGV
def shift
usage if $ARGS == []
arg = $ARGS[0]
$ARGS = $ARGS[1..] || []
arg
end
verbose_level = 2 # print command output
case $ARGS[0]
when "-v"
verbose_level = 3 # print all messages
shift
when "-q"
verbose_level = 1 # print commands
shift
when "-qq"
verbose_level = 0 # print nothing
shift
end
Rbpkg.init("rbpkg_ci", verbose_level, Rbpkg.ci_log_dir, Rbpkg.ci_status_dir)
Rbpkg.ci_init
def usage()
STDERR.puts "Usage: #{File.basename($0)} REPO BRANCH COMMIT"
exit 1
end
def rbpkg_ci
case $ARGS[0]
when "--clean"
cmd = "rm -rf #{sh_quote(Rbpkg.ci_dir)}"
verbose(1, cmd)
raise "command failed: #{cmd.inspect}" unless system(cmd)
Rbpkg.ci_init
Rbpkg::Log.ok_all
exit 0
when "-h"
usage
when "--help"
usage
when "--upgrade"
Rbpkg.upgrade_self
shift
end
repo = shift
branch = $ARGS[0] ? shift : nil
commit = $ARGS[0] ? shift : nil
usage unless $ARGS == []
Rbpkg::Repos.repo(repo).ci(branch, commit)
Rbpkg::Log.ok_all
end
begin
rbpkg_ci
rescue => error
verbose(-1, error.backtrace.reverse.join("\n"))
verbose(-1, "#{error.class.name}: #{error.message}")
exit 1
end