summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/rbot51
-rwxr-xr-xlaunch_here.rb52
2 files changed, 49 insertions, 54 deletions
diff --git a/bin/rbot b/bin/rbot
index cee5974a..d2f53eb4 100755
--- a/bin/rbot
+++ b/bin/rbot
@@ -47,58 +47,9 @@ require 'etc'
require 'getoptlong'
require 'fileutils'
-$version="0.9.11-git"
+$version ||= "0.9.11-git"
$opts = Hash.new
-if $version =~ /git/
- if defined?(SCM_DIR) and File.exists?(File.join(SCM_DIR, '.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
- if git_out[1].match(/^git-svn-id: \S+@(\d+)/)
- rev << "(svn #{$1})"
- end
- 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})"
- else
- up = File.dirname(__FILE__) + "/.."
- rev = " (unknown revision)"
- begin
- svn_out = `svn info #{up}`
- if svn_out =~ /Last Changed Rev: (\d+)/
- rev = " (revision #{$1}"
- end
- svn_st = `svn st #{up}`
- if svn_st =~ /^[MDA] /
- rev << ", local changes"
- end
- rev << ")"
- rescue => e
- puts e.inspect
- end if File.directory?(File.join(up, '.svn'))
- $version += rev
- end
-end
-
orig_opts = ARGV.dup
opts = GetoptLong.new(
diff --git a/launch_here.rb b/launch_here.rb
index 95d383ba..b368f4c6 100755
--- a/launch_here.rb
+++ b/launch_here.rb
@@ -4,14 +4,58 @@
#
SCM_DIR = File.expand_path File.dirname(__FILE__)
-$0 = File.expand_path $0
-
-Dir.chdir SCM_DIR
-
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
class Bot
module Config