Skip to content

Commit

Permalink
Add logging to queueing.
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Colyer committed Mar 31, 2011
1 parent 291419e commit 9cf0bed
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/cijoe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def initialize(project_path)

@last_build = nil
@current_build = nil
@queue = Queue.new(!repo_config.buildqueue.empty?)
@queue = Queue.new(!repo_config.buildqueue.to_s.empty?, true)

trap("INT") { stop }
end
Expand Down
18 changes: 15 additions & 3 deletions lib/cijoe/queue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ class CIJoe
# builds.
class Queue
# enabled - determines whether builds should be queued or not.
def initialize(enabled)
def initialize(enabled, verbose=false)
@enabled = enabled
@verbose = verbose
@queue = []

log("Build queueing enabled") if enabled
end

# Public: Appends a branch to be built, unless it already exists
Expand All @@ -17,12 +20,17 @@ def initialize(enabled)
# Returns nothing
def append_unless_already_exists(branch)
return unless enabled?
@queue << branch unless @queue.include? branch
unless @queue.include? branch
@queue << branch
log "#{Time.now.to_i}: Queueing #{branch}"
end
end

# Returns a String of the next branch to build
def next_branch_to_build
@queue.shift
branch = @queue.shift
log "#{Time.now.to_i}: De-queueing #{branch}"
branch
end

# Returns true if there are requested builds waiting and false
Expand All @@ -36,6 +44,10 @@ def waiting?
end

protected
def log(msg)
puts msg if @verbose
end

def enabled?
@enabled
end
Expand Down

0 comments on commit 9cf0bed

Please sign in to comment.