From c55664520781b8ec155f0c4ff782c92043e4ac12 Mon Sep 17 00:00:00 2001 From: Ben Griffiths Date: Fri, 16 May 2008 00:36:46 +0100 Subject: [PATCH] Hacked it about a bit - a bit more refactoring needed for sure. --- app/models/project.rb | 7 ++++--- app/models/revision.rb | 1 - lib/git.rb | 17 +++++++++++------ 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/app/models/project.rb b/app/models/project.rb index 2e75f91..9b69f53 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -39,6 +39,7 @@ def initialize(name, scm = Subversion.new) @error_message = '' @triggers = [ChangeInSourceControlTrigger.new(self)] instantiate_plugins + scm.project = self if scm.respond_to? :project= end def source_control=(value) @@ -443,7 +444,7 @@ def order_builds(builds) def create_build_label(revision_number) revision_number = revision_number.to_s if revision_number.length > MAX_BUILD_LABEL_LENGTH - revision_number = revision_number[0, MAX_BUILD_LABEL_LENGTH] + '...' + revision_number = revision_number[0, MAX_BUILD_LABEL_LENGTH] + '...' end build_labels = builds.map { |b| b.label } @@ -490,7 +491,7 @@ def plugin_loader.load_plugin(plugin_path) plugin_is_directory = (plugin_file == 'init') plugin_name = plugin_is_directory ? File.basename(File.dirname(plugin_path)) : plugin_file - CruiseControl::Log.debug("Loading plugin #{plugin_name}") + CruiseControl::Log.info("Loading plugin #{plugin_name}") if RAILS_ENV == 'development' load plugin_path else @@ -515,7 +516,7 @@ def plugin_loader.load_all if File.file?(init_path) load_plugin(init_path) else - log.error("No init.rb found in plugin directory #{plugin}") + CruiseControl::Log.error("No init.rb found in plugin directory #{plugin}") end else # a path is neither file nor directory. whatever else it may be, let's ignore it. diff --git a/app/models/revision.rb b/app/models/revision.rb index 53df1e5..99edbf3 100644 --- a/app/models/revision.rb +++ b/app/models/revision.rb @@ -12,7 +12,6 @@ def to_s <<-EOL Revision #{number} committed by #{committed_by} on #{time.strftime('%Y-%m-%d %H:%M:%S') if time} #{message} -#{changeset ? changeset.collect { |entry| entry.to_s }.join("\n") : nil} EOL end diff --git a/lib/git.rb b/lib/git.rb index b32611b..49650c0 100644 --- a/lib/git.rb +++ b/lib/git.rb @@ -2,30 +2,31 @@ require 'grit' class GitRevision < Revision - attr_accessor :commit + attr_accessor :commit,:message def initialize(commit) @commit = commit end def number - @commit.id + @commit.id_abbrev end - def author + def committed_by @commit.author end def time @commit.authored_date end + end class Git include Grit include CommandLine - attr_accessor :url, :path, :username, :password, :branch + attr_accessor :url, :path, :username, :password, :branch, :project def initialize(options = {}) @url = options.delete(:url) @@ -44,7 +45,11 @@ def repo end def latest_revision - GitRevision.new(repo.commits.first) + revision = GitRevision.new(repo.commits.first) + build = Build.new(@project,revision.number) + last_build = @project.last_complete_build || build + revision.message = repo.git.log({},"--pretty=oneline --abbrev-commit #{last_build.revision}..#{build.revision}") + revision end def update_origin @@ -69,7 +74,7 @@ def update(revision = nil) def up_to_date?(reasons = [], revision_number = latest_revision.number) return true if update_origin.empty? reset_from_remote - reasons << "New revision #{latest_revision.number} detected" +# reasons << "New revision #{latest_revision.number} detected" reasons << latest_revision false end