Permalink
Browse files

Add logging to queueing.

  • Loading branch information...
1 parent 291419e commit 9cf0bed012a987e251101a2768d51fe1d236e9eb Matt Colyer committed Mar 31, 2011
Showing with 16 additions and 4 deletions.
  1. +1 −1 lib/cijoe.rb
  2. +15 −3 lib/cijoe/queue.rb
View
@@ -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
View
@@ -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
@@ -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
@@ -36,6 +44,10 @@ def waiting?
end
protected
+ def log(msg)
+ puts msg if @verbose
+ end
+
def enabled?
@enabled
end

0 comments on commit 9cf0bed

Please sign in to comment.