X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=launch_here.rb;h=b368f4c62b6149b231dbfba1db107ec529071fa5;hb=3b83d8870cc04a2b0eff4250dd8deef9ea1d697b;hp=6c48ae08f5cecbf15c994e4bab645816fdad7e1b;hpb=533c1e1dcf0b4b837728a4fc51265d8d20e9d076;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/launch_here.rb b/launch_here.rb index 6c48ae08..b368f4c6 100755 --- a/launch_here.rb +++ b/launch_here.rb @@ -1,23 +1,68 @@ -#!/usr/bin/ruby -# -# Load rbot from this directory. (No need to install it with setup.rb) -# - -BASEDIR = Dir.pwd - -#puts "Load path: #{$LOAD_PATH.inspect}" +#!/usr/bin/ruby +# +# Load rbot from this directory. (No need to install it with setup.rb) +# -def add_to_path(dir) - $LOAD_PATH.unshift dir +SCM_DIR = File.expand_path File.dirname(__FILE__) +puts "Running from #{SCM_DIR}" + +$:.unshift File.join(SCM_DIR, 'lib') + +$version = '0.9.11-git' + +pwd = Dir.pwd +begin + Dir.chdir SCM_DIR + + if File.exists? '.git' + begin + git_out = `git status` + git_out.match(/^# On branch (.*)\n/) + if $1 # git 1.5.x + branch = $1.dup || "unknown" + changed = git_out.match(/^# Change(.*)\n/) + rev = "revision " + git_out = `git log -1 --pretty=format:"%h%n%b%n%ct"`.split("\n") + rev << git_out.first + $version_timestamp = git_out.last.to_i + rev << "(svn #{$1})" if git_out[1].match(/^git-svn-id: \S+@(\d+)/) + rev << ", local changes" if changed + else # older gits + git_out = `git branch` + git_out.match(/^\* (.*)\n/) + branch = $1.dup rescue "unknown" + rev = "revision " + `git rev-parse HEAD`[0,6] + end + rescue => e + puts e.inspect + branch = "unknown branch" + rev = "unknown revision" + end + $version << " (#{branch} branch, #{rev})" + elsif File.directory? File.join(up, '.svn') + rev = " (unknown revision)" + begin + svn_out = `svn info` + rev = " (revision #{$1}" if svn_out =~ /Last Changed Rev: (\d+)/ + svn_st = `svn st #{up}` + rev << ", local changes" if svn_st =~ /^[MDA] / + rev << ")" + rescue => e + puts e.inspect + end + $version += rev + end +ensure + Dir.chdir pwd end - + module Irc - module PKGConfig - DATADIR = File.join BASEDIR, 'data/rbot' - COREDIR = File.join BASEDIR, 'lib/rbot/core' +class Bot + module Config + @@datadir = File.join SCM_DIR, 'data/rbot' + @@coredir = File.join SCM_DIR, 'lib/rbot/core' end -end - -add_to_path( File.join BASEDIR, 'lib' ) - -load( File.join BASEDIR, 'bin/rbot' ) +end +end + +load File.join(SCM_DIR, 'bin/rbot')