Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

launch hook in project_path define

  • Loading branch information...
commit d16b3ea244c1abd4d3e7f6e4039a1390e52010ca 1 parent e25cd35
Cyril Mougel shingara authored defunkt committed
Showing with 11 additions and 10 deletions.
  1. +5 −4 lib/cijoe.rb
  2. +4 −4 lib/cijoe/build.rb
  3. +2 −2 lib/cijoe/commit.rb
9 lib/cijoe.rb
View
@@ -101,7 +101,7 @@ def build
# leave anyway because a current build runs
return
end
- @current_build = Build.new(@user, @project)
+ @current_build = Build.new(@project_path, @user, @project)
write_build 'current', @current_build
Thread.new { build! }
end
@@ -172,7 +172,7 @@ def git_branch
# massage our repo
def run_hook(hook)
- if File.exists?(file=".git/hooks/#{hook}") && File.executable?(file)
+ if File.exists?(file=path_in_project(".git/hooks/#{hook}")) && File.executable?(file)
data =
if @last_build && @last_build.commit
{
@@ -184,8 +184,9 @@ def run_hook(hook)
else
{}
end
+
data.each{ |k, v| ENV[k] = v }
- `sh #{file}`
+ `cd #{@project_path} && sh #{file}`
end
end
@@ -227,6 +228,6 @@ def repo_config
# load build info from file.
def read_build(name)
- Build.load(path_in_project(".git/builds/#{name}"))
+ Build.load(path_in_project(".git/builds/#{name}"), @project_path)
end
end
8 lib/cijoe/build.rb
View
@@ -1,7 +1,7 @@
require 'yaml'
class CIJoe
- class Build < Struct.new(:user, :project, :started_at, :finished_at, :sha, :status, :output, :pid)
+ class Build < Struct.new(:project_path, :user, :project, :started_at, :finished_at, :sha, :status, :output, :pid)
def initialize(*args)
super
self.started_at ||= Time.now
@@ -43,7 +43,7 @@ def clean_output
def commit
return if sha.nil?
- @commit ||= Commit.new(sha, user, project)
+ @commit ||= Commit.new(sha, user, project, project_path)
end
def dump(file)
@@ -52,9 +52,9 @@ def dump(file)
File.open(file, 'wb') { |io| io.write(data) }
end
- def self.load(file)
+ def self.load(file, project_path)
if File.exist?(file)
- config = YAML.load(File.read(file))
+ config = YAML.load(File.read(file)).unshift(project_path)
new *config
end
end
4 lib/cijoe/commit.rb
View
@@ -1,5 +1,5 @@
class CIJoe
- class Commit < Struct.new(:sha, :user, :project)
+ class Commit < Struct.new(:sha, :user, :project, :project_path)
def url
"http://github.com/#{user}/#{project}/commit/#{sha}"
end
@@ -17,7 +17,7 @@ def message
end
def raw_commit
- @raw_commit ||= `git show #{sha}`.chomp
+ @raw_commit ||= `cd #{project_path} && git show #{sha}`.chomp
end
def raw_commit_lines
Please sign in to comment.
Something went wrong with that request. Please try again.