ruby: remove GIT_PAGER from environment
[git] / git-rb-setup.rb
1 #!/usr/bin/env ruby
2
3 def die(*args)
4   fmt = args.shift
5   $stderr.printf("fatal: %s\n" % fmt, *args)
6   exit 128
7 end
8
9 def sha1_to_hex(sha1)
10   sha1.unpack('H*').first
11 end
12
13 class CommandError < RuntimeError
14
15   def initialize(command)
16      @command = command
17   end
18
19   def to_s
20     Array(@command).join(' ').inspect
21   end
22
23 end
24
25 def run(cmd, *args)
26   system(*cmd, *args)
27   raise CommandError.new(cmd) unless $?.success?
28 end
29
30 class String
31   def skip_prefix(prefix)
32     return self[prefix.length..-1]
33   end
34 end