Skip to content

Commit

Permalink
Hacked it about a bit - a bit more refactoring needed for sure.
Browse files Browse the repository at this point in the history
  • Loading branch information
techbelly committed May 15, 2008
1 parent f96766d commit c556645
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
7 changes: 4 additions & 3 deletions app/models/project.rb
Expand Up @@ -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)
Expand Down Expand Up @@ -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 }
Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand Down
1 change: 0 additions & 1 deletion app/models/revision.rb
Expand Up @@ -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

Expand Down
17 changes: 11 additions & 6 deletions lib/git.rb
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit c556645

Please sign in to comment.