root/launch_here.rb

Revision e6a570257f2ccf7eff3f2055d695880a451320ac, 1.8 KB (checked in by Giuseppe Bilotta <giuseppe.bilotta@…>, 4 weeks ago)

Version 0.9.15

  • Property mode set to 100755
Line 
1#!/usr/bin/ruby
2#
3# Load rbot from this directory. (No need to install it with setup.rb)
4#
5
6SCM_DIR = File.expand_path File.dirname(__FILE__)
7puts "Running from #{SCM_DIR}"
8
9$:.unshift File.join(SCM_DIR, 'lib')
10
11$version = '0.9.15'
12
13pwd = Dir.pwd
14begin
15  Dir.chdir SCM_DIR
16
17  if File.exists? '.git'
18    begin
19      git_out = `git log -1 --pretty=raw | git name-rev --stdin`.split("\n")
20      commit, branch_spec = git_out.first.scan(/^commit (\S+)(?: \((\S+)\))?$/).first
21      $version_timestamp = git_out[4].split[-2].to_i
22      subject = git_out[6].strip rescue ""
23      subject[77..-1] = "..." if subject.length > 80
24      rev = "revision #{commit[0,7]}"
25      rev << " [#{subject}]" unless subject.empty?
26      changes = `git diff-index --stat HEAD`.split("\n").last.split(", ").first rescue nil
27      rev << ", #{changes.strip}" if changes
28      if branch_spec
29        tag, branch, offset = branch_spec.scan(/^(?:(tag)s\/)?(\S+?)(?:^0)?(?:~(\d+))?$/).first
30        tag ||= "branch"
31        branch << " #{tag}"
32        branch << "-#{offset}" if offset
33      else
34        branch = "unknown branch"
35      end
36    rescue => e
37      puts e.inspect
38      branch = "unknown branch"
39      rev = "unknown revision"
40    end
41    $version << " (#{branch}, #{rev})"
42  elsif File.directory? File.join(SCM_DIR, '.svn')
43    rev = " (unknown revision)"
44    begin
45      svn_out = `svn info`
46      rev = " (revision #{$1}" if svn_out =~ /Last Changed Rev: (\d+)/
47      svn_st = `svn st #{SCM_DIR}`
48      rev << ", local changes" if svn_st =~ /^[MDA] /
49      rev << ")"
50    rescue => e
51      puts e.inspect
52    end
53    $version += rev
54  end
55ensure
56  Dir.chdir pwd
57end
58
59module Irc
60class Bot
61  module Config
62    @@datadir = File.join SCM_DIR, 'data/rbot'
63    @@coredir = File.join SCM_DIR, 'lib/rbot/core'
64  end
65end
66end
67
68load File.join(SCM_DIR, 'bin/rbot')
Note: See TracBrowser for help on using the browser.