[Bps-public-commit] smokingit branch, master, updated. d7ecb0112f4f7e7ff652e94cb39e1319b43e36c3

Alex Vandiver alexmv at bestpractical.com
Wed Mar 14 14:19:56 EDT 2012


The branch, master has been updated
       via  d7ecb0112f4f7e7ff652e94cb39e1319b43e36c3 (commit)
       via  376a0718d681a2e809bb7413689a117bdd9ced82 (commit)
       via  41968a9bbe97fdb55951324966151562d1c27f1d (commit)
       via  d112d1cc5eb2dc861fe78e2c819d0d38c0accac9 (commit)
       via  29366b32648ede517adf6947b21283da3580cb9a (commit)
       via  49b477233deb4965657310a5338f032ac91227ef (commit)
       via  efdbd86635307fc2827eef4887ed83a4739f2e2f (commit)
       via  d718d5ca7787e50544f6f168fa4412f4f84d814b (commit)
       via  b0af9bb239bc4d177ca3f5805b4e1bcdcc0bb481 (commit)
       via  9203b7f7f1d424fb7610cf67d915d17349eaba32 (commit)
       via  f879e1ef4e9bfe20a028d46214eb50d477d508f2 (commit)
       via  546000e48ce504250562ec41a19a7083b294a5d8 (commit)
       via  6f601d78ae1efeeeb87a38b0534b735bc85c185b (commit)
      from  2528b53783b1dd0468e33f21a9b925f490b462e4 (commit)

Summary of changes:
 bin/local_updates                    |  206 ++++++++++++----------------------
 lib/Smokingit.pm                     |   17 +++
 lib/Smokingit/Action/UpdateBranch.pm |   14 ++-
 lib/Smokingit/Model/Commit.pm        |   12 ++
 lib/Smokingit/Model/Project.pm       |   21 +++-
 lib/Smokingit/Model/SmokeResult.pm   |   74 +++++++++++-
 6 files changed, 196 insertions(+), 148 deletions(-)

- Log -----------------------------------------------------------------
commit 6f601d78ae1efeeeb87a38b0534b735bc85c185b
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Mon Mar 12 23:53:31 2012 -0400

    Factor out check_queue into Smokingit.pm

diff --git a/bin/local_updates b/bin/local_updates
index 096d2b2..f26e500 100755
--- a/bin/local_updates
+++ b/bin/local_updates
@@ -15,21 +15,12 @@ use TAP::Parser::Aggregator;
 my $worker = Gearman::Worker->new(
     job_servers => Jifty->config->app('job_servers'),
 );
+
+# User task, synchronous
 $worker->register_function(
     check_queue => sub {
-        warn "In check_queue";
-        my $job = shift;
-        my $queued = Smokingit::Model::SmokeResultCollection->new;
-        $queued->limit(
-            column => "submitted_at",
-            operator => "IS",
-            value => "NULL",
-        );
-        my $restarted = 0;
-        while (my $smoke = $queued->next) {
-            $restarted += $smoke->run_smoke unless $smoke->gearman_status->known;
-        }
-        return $restarted;
+        my $restarted = Smokingit->check_queue;
+        return "Restarted $restarted tasks\n";
     },
 );
 $worker->register_function(
diff --git a/lib/Smokingit.pm b/lib/Smokingit.pm
index de96f7c..d2306a7 100644
--- a/lib/Smokingit.pm
+++ b/lib/Smokingit.pm
@@ -17,4 +17,21 @@ sub start {
 
 sub gearman   { $GEARMAN   }
 sub memcached { $MEMCACHED }
+
+sub check_queue {
+    my $job = shift;
+    my $queued = Smokingit::Model::SmokeResultCollection->new;
+    $queued->limit(
+        column => "submitted_at",
+        operator => "IS",
+        value => "NULL",
+    );
+    my $restarted = 0;
+    while (my $smoke = $queued->next) {
+        next if $smoke->gearman_status->known;
+        $restarted += $smoke->run_smoke;
+    }
+    return $restarted;
+}
+
 1;

commit 546000e48ce504250562ec41a19a7083b294a5d8
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Mon Mar 12 23:59:03 2012 -0400

    Factor out smoke submission into a method

diff --git a/bin/local_updates b/bin/local_updates
index f26e500..1f4fc32 100755
--- a/bin/local_updates
+++ b/bin/local_updates
@@ -6,12 +6,9 @@ use lib 'lib';
 
 use Jifty;
 BEGIN { Jifty->new; }
-use Storable qw/thaw/;
 use Benchmark qw/timestr/;
 
 use Gearman::Worker;
-use TAP::Parser::Aggregator;
-
 my $worker = Gearman::Worker->new(
     job_servers => Jifty->config->app('job_servers'),
 );
@@ -23,68 +20,15 @@ $worker->register_function(
         return "Restarted $restarted tasks\n";
     },
 );
+
+# Synchronous task, from worker
 $worker->register_function(
     post_results => sub {
         my $job = shift;
-        my %result = %{ thaw( $job->arg ) };
-
-        # Properties to extract from the aggregator
-        my @props =
-            qw/failed
-               parse_errors
-               passed
-               planned
-               skipped
-               todo
-               todo_passed
-               wait
-               exit/;
-
-        # Aggregator might not exist if we had a configure failure
-        my $a = $result{aggregator};
-        if ($a) {
-            $result{$_} = $a->$_ for @props;
-            $result{is_ok}      = not($a->has_problems);
-            $result{elapsed}    = $a->elapsed->[0];
-            $result{error}      = undef;
-        } else {
-            # Unset the existing data if there was a fail
-            $result{$_} = undef for @props, "is_ok", "elapsed";
-        }
-        $result{submitted_at} = Jifty::DateTime->now;
-
-        # Find the smoke
-        Jifty->handle->begin_transaction;
-        my $smokeid = delete $result{smoke_id};
         my $smoke = Smokingit::Model::SmokeResult->new;
-        $smoke->load( $smokeid );
-        if (not $smoke->id) {
-            warn "Invalid smoke ID: $smokeid\n";
-            return 0;
-        } elsif (not $smoke->gearman_process) {
-            warn "Smoke report on $smokeid which wasn't being smoked? (last report at @{[$smoke->submitted_at]})\n";
-            return 0;
-        }
-
-        # Update with the new data
-        for my $key (keys %result) {
-            my $method = "set_$key";
-            $smoke->$method($result{$key});
-        }
-        # Mark as no longer smoking
-        $smoke->set_gearman_process(undef);
-
-        # And commit all of that
-        Jifty->handle->commit;
-
-        warn "Test result for "
-            . $smoke->project->name
-            ." ". $smoke->commit->short_sha
-            ." using ". $smoke->configuration->name
-            ." on ". $smoke->branch_name
-            .": ".($smoke->is_ok ? "OK" : "NOT OK")."\n";
-
-        return 1;
+        my ($ok, $msg) = $smoke->post_result($job->arg);
+        warn "$msg\n";
+        return $ok;
     },
 );
 $worker->register_function(
diff --git a/lib/Smokingit/Model/SmokeResult.pm b/lib/Smokingit/Model/SmokeResult.pm
index 22abb06..e48fc52 100644
--- a/lib/Smokingit/Model/SmokeResult.pm
+++ b/lib/Smokingit/Model/SmokeResult.pm
@@ -4,7 +4,7 @@ use warnings;
 package Smokingit::Model::SmokeResult;
 use Jifty::DBI::Schema;
 
-use Storable qw/nfreeze/;
+use Storable qw/nfreeze thaw/;
 
 use Smokingit::Record schema {
     column project_id =>
@@ -130,5 +130,68 @@ sub status_cache_key {
     return "status-" . $self->commit->sha . "-" . $self->configuration->id;
 }
 
+sub post_result {
+    my $self = shift;
+    my ($arg) = @_;
+
+    my %result;
+    eval { %result = %{ thaw( $arg ) } };
+    return (0, "Thaw failed: $@") if $@;
+
+    # Properties to extract from the aggregator
+    my @props =
+        qw/failed
+           parse_errors
+           passed
+           planned
+           skipped
+           todo
+           todo_passed
+           wait
+           exit/;
+
+    # Aggregator might not exist if we had a configure failure
+    require TAP::Parser::Aggregator;
+    my $a = $result{aggregator};
+    if ($a) {
+        $result{$_} = $a->$_ for @props;
+        $result{is_ok}      = not($a->has_problems);
+        $result{elapsed}    = $a->elapsed->[0];
+        $result{error}      = undef;
+    } else {
+        # Unset the existing data if there was a fail
+        $result{$_} = undef for @props, "is_ok", "elapsed";
+    }
+    $result{submitted_at} = Jifty::DateTime->now;
+
+    # Find the smoke
+    Jifty->handle->begin_transaction;
+    my $smokeid = delete $result{smoke_id};
+    $self->load( $smokeid );
+    if (not $self->id) {
+        return (0, "Invalid smoke ID: $smokeid");
+    } elsif (not $self->gearman_process) {
+        return (0, "Smoke report on $smokeid which wasn't being smoked? (last report at @{[$self->submitted_at]})");
+    }
+
+    # Update with the new data
+    for my $key (keys %result) {
+        my $method = "set_$key";
+        $self->$method($result{$key});
+    }
+    # Mark as no longer smoking
+    $self->set_gearman_process(undef);
+
+    # And commit all of that
+    Jifty->handle->commit;
+
+    return (1, "Test result for "
+             . $self->project->name
+             ." ". $self->commit->short_sha
+             ." using ". $self->configuration->name
+             ." on ". $self->branch_name
+             .": ".($self->is_ok ? "OK" : "NOT OK"));
+}
+
 1;
 

commit f879e1ef4e9bfe20a028d46214eb50d477d508f2
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Tue Mar 13 00:18:13 2012 -0400

    Attempt to automatically determine which branch a commit is on

diff --git a/bin/local_updates b/bin/local_updates
index 1f4fc32..ee5973a 100755
--- a/bin/local_updates
+++ b/bin/local_updates
@@ -85,10 +85,11 @@ $worker->register_function(
     }
 );
 
+# User task, synchronous
 $worker->register_function(
     retest => sub {
         my $job = shift;
-        my ($sha,$configname,$branchname) = $job->arg =~ /^([0-9a-fA-F]+)(?:\s*\[(.*)\])?(?:\s*,\s*(.*))?/;
+        my ($sha,$configname) = $job->arg =~ /^([0-9a-fA-F]+)(?:\s*\[(.*)\])?/;
 
         my $commits = Smokingit::Model::CommitCollection->new;
         $commits->limit( column => "sha", operator => "like", value => "$sha%" );
@@ -97,10 +98,7 @@ $worker->register_function(
         my $commit = $commits->next;
         warn "Retesting @{[$commit->short_sha]}\n";
 
-        my $branch = Smokingit::Model::Branch->new;
-        $branch->load_by_cols( project_id => $commit->project->id, name => $branchname )
-            if $branchname;
-        warn "Invalid branch name $branchname given\n" if $branchname and not $branch->id;
+        my $branch;
 
         my $configs = $commit->project->configurations;
         $configs->limit( column => "name", operator => "MATCHES", value => $configname )
@@ -120,11 +118,20 @@ $worker->register_function(
                 $smoke->set_submitted_at(undef);
                 $smoke->set_gearman_process(undef);
                 $tests += $smoke->run_smoke;
-            } elsif ($branch->id) {
-                warn "Smoking new @{[$smoke->id]}\n";
-                $tests += $commit->run_smoke( $config, $branch );
             } else {
-                warn "No existing smoke for $sha found, and no branch given\n";
+                # Guess which branch
+                unless ($branch) {
+                    $branch = Smokingit::Model::Branch->new;
+                    my @branches = $commit->branches;
+                    $branch->load_by_cols( name => $branches[0], project_id => $commit->project->id)
+                        if @branches == 1;
+                }
+                if ($branch->id) {
+                    warn "Testing @{[$commit->short_sha]}[@{[$config->name]}]\n";
+                    $tests += $commit->run_smoke( $config, $branch );
+                } else {
+                    warn "No existing smoke for @{[$commit->short_sha]} found, and can't determine branch\n";
+                }
             }
         }
         return $tests;
diff --git a/lib/Smokingit/Model/Commit.pm b/lib/Smokingit/Model/Commit.pm
index 7d04866..f971566 100644
--- a/lib/Smokingit/Model/Commit.pm
+++ b/lib/Smokingit/Model/Commit.pm
@@ -213,6 +213,18 @@ sub parents {
     return map {$self->project->sha($_)} split ' ', $self->_value('parents');
 }
 
+sub branches {
+    my $self = shift;
+
+    my $sha = $self->sha;
+
+    local $ENV{GIT_DIR} = $self->project->repository_path;
+    my @branches = map {s/^\s*(\*\s*)?//;chomp;$_}
+        `git branch --contains $sha`;
+
+    return @branches;
+}
+
 sub status_cache_key {
     my $self = shift;
     return "status-" . $self->sha;

commit 9203b7f7f1d424fb7610cf67d915d17349eaba32
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Tue Mar 13 00:19:03 2012 -0400

    Because retesting is user-synchronous, provide better feedback

diff --git a/bin/local_updates b/bin/local_updates
index ee5973a..b2079b7 100755
--- a/bin/local_updates
+++ b/bin/local_updates
@@ -93,19 +93,22 @@ $worker->register_function(
 
         my $commits = Smokingit::Model::CommitCollection->new;
         $commits->limit( column => "sha", operator => "like", value => "$sha%" );
-        return 0 unless $commits->count == 1;
+        return "Unknown SHA\n"   if $commits->count == 0;
+        return "Ambiguous SHA\n" if $commits->count > 1;
+
+        my @msgs;
+        my $msg = sub { warn @_; push @msgs, @_ };
 
         my $commit = $commits->next;
-        warn "Retesting @{[$commit->short_sha]}\n";
 
         my $branch;
 
         my $configs = $commit->project->configurations;
         $configs->limit( column => "name", operator => "MATCHES", value => $configname )
             if defined $configname and length $configname;
-        warn "Found @{[$configs->count]} configs\n";
         my $tests = 0;
         while (my $config = $configs->next) {
+            my $summary = $commit->short_sha . "[" . $config->name ."]";
             my %lookup = (
                 project_id       => $commit->project->id,
                 configuration_id => $config->id,
@@ -114,7 +117,7 @@ $worker->register_function(
             my $smoke = Smokingit::Model::SmokeResult->new;
             $smoke->load_by_cols( %lookup );
             if ($smoke->id) {
-                warn "Re-testing @{[$smoke->id]}\n";
+                $msg->("Re-testing $summary\n");
                 $smoke->set_submitted_at(undef);
                 $smoke->set_gearman_process(undef);
                 $tests += $smoke->run_smoke;
@@ -127,14 +130,14 @@ $worker->register_function(
                         if @branches == 1;
                 }
                 if ($branch->id) {
-                    warn "Testing @{[$commit->short_sha]}[@{[$config->name]}]\n";
+                    $msg->("Testing $summary\n");
                     $tests += $commit->run_smoke( $config, $branch );
                 } else {
-                    warn "No existing smoke for @{[$commit->short_sha]} found, and can't determine branch\n";
+                    $msg->("No existing smoke for $summary found, and can't determine branch\n");
                 }
             }
         }
-        return $tests;
+        return join "", @msgs;
     },
 );
 

commit b0af9bb239bc4d177ca3f5805b4e1bcdcc0bb481
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Tue Mar 13 00:28:16 2012 -0400

    Change return type of local_updates to be more straightforward
    
    In doing so, correct a variable name in local_updates

diff --git a/bin/local_updates b/bin/local_updates
index b2079b7..a0626a0 100755
--- a/bin/local_updates
+++ b/bin/local_updates
@@ -55,10 +55,10 @@ $worker->register_function(
 
         # Sync up the branches
         Jifty->handle->begin_transaction;
-        my $tests = $project->sync_branches;
+        my @results = $project->sync_branches;
         Jifty->handle->commit;
 
-        return @{$tests} ? join("\n",@{$tests},"") : "No changes\n";
+        return @results ? join("\n", at results,"") : "No changes\n";
     },
 );
 $worker->register_function(
diff --git a/lib/Smokingit/Model/Project.pm b/lib/Smokingit/Model/Project.pm
index 809b822..3503c2b 100644
--- a/lib/Smokingit/Model/Project.pm
+++ b/lib/Smokingit/Model/Project.pm
@@ -198,7 +198,7 @@ sub sync_branches {
 
     my $tests = $self->schedule_tests;
     push @messages, "$tests commits scheduled for testing" if $tests;
-    return [map {$self->name.": $_"} @messages];
+    return map {$self->name.": $_"} @messages;
 }
 
 sub schedule_tests {

commit d718d5ca7787e50544f6f168fa4412f4f84d814b
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Tue Mar 13 00:30:54 2012 -0400

    Push more logic out of local_updates and into $project->sync

diff --git a/bin/local_updates b/bin/local_updates
index a0626a0..5d44599 100755
--- a/bin/local_updates
+++ b/bin/local_updates
@@ -31,33 +31,19 @@ $worker->register_function(
         return $ok;
     },
 );
+
+# User or background task
 $worker->register_function(
     sync_project => sub {
         my $job = shift;
         my $project_name = $job->arg;
-        warn "Sync $project_name";
 
         my $project = Smokingit::Model::Project->new;
         $project->load_by_cols( name => $project_name );
         return "No such project: $project_name\n"
             unless $project->id;
 
-        # Update or clone, as need be
-        if (-d $project->repository_path) {
-            warn "Updating $project_name\n";
-            $project->update_repository;
-        } else {
-            warn "Cloning $project_name\n";
-            system("git", "clone", "--quiet", "--mirror",
-                   $project->repository_url,
-                   $project->repository_path);
-        }
-
-        # Sync up the branches
-        Jifty->handle->begin_transaction;
-        my @results = $project->sync_branches;
-        Jifty->handle->commit;
-
+        my @results = $project->sync;
         return @results ? join("\n", at results,"") : "No changes\n";
     },
 );
diff --git a/lib/Smokingit/Model/Project.pm b/lib/Smokingit/Model/Project.pm
index 3503c2b..e7cb530 100644
--- a/lib/Smokingit/Model/Project.pm
+++ b/lib/Smokingit/Model/Project.pm
@@ -141,9 +141,24 @@ sub update_repository {
     `git fetch --all --prune --quiet`;
 }
 
-sub sync_branches {
+sub sync {
     my $self = shift;
 
+    # Start a txn
+    Jifty->handle->begin_transaction;
+
+    # Make sure we have a repository
+    if (-d $self->repository_path) {
+        warn "Updating " . $self->name ."\n";
+        $self->update_repository;
+    } else {
+        warn "Cloning " . $self->name."\n";
+        system("git", "clone", "--quiet", "--mirror",
+               $self->repository_url,
+               $self->repository_path);
+    }
+
+    # Sync up the branches
     local $ENV{GIT_DIR} = $self->repository_path;
 
     my %branches;
@@ -197,6 +212,8 @@ sub sync_branches {
     }
 
     my $tests = $self->schedule_tests;
+    Jifty->handle->commit;
+
     push @messages, "$tests commits scheduled for testing" if $tests;
     return map {$self->name.": $_"} @messages;
 }

commit efdbd86635307fc2827eef4887ed83a4739f2e2f
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Tue Mar 13 00:33:11 2012 -0400

    Reorder tasks in local_updates to group by type

diff --git a/bin/local_updates b/bin/local_updates
index 5d44599..e353a0d 100755
--- a/bin/local_updates
+++ b/bin/local_updates
@@ -21,56 +21,6 @@ $worker->register_function(
     },
 );
 
-# Synchronous task, from worker
-$worker->register_function(
-    post_results => sub {
-        my $job = shift;
-        my $smoke = Smokingit::Model::SmokeResult->new;
-        my ($ok, $msg) = $smoke->post_result($job->arg);
-        warn "$msg\n";
-        return $ok;
-    },
-);
-
-# User or background task
-$worker->register_function(
-    sync_project => sub {
-        my $job = shift;
-        my $project_name = $job->arg;
-
-        my $project = Smokingit::Model::Project->new;
-        $project->load_by_cols( name => $project_name );
-        return "No such project: $project_name\n"
-            unless $project->id;
-
-        my @results = $project->sync;
-        return @results ? join("\n", at results,"") : "No changes\n";
-    },
-);
-$worker->register_function(
-    plan_tests => sub {
-        my $job = shift;
-        my $project_name = $job->arg;
-
-        my $projects = Smokingit::Model::ProjectCollection->new;
-        if ($project_name) {
-            $projects->limit( column => "name", value => $project_name );
-        } else {
-            $projects->unlimit;
-        }
-        return 0 unless $projects->count;
-
-        my $tests = 0;
-        while (my $project = $projects->next) {
-            Jifty->handle->begin_transaction;
-            $tests += $project->schedule_tests;
-            Jifty->handle->commit;
-        }
-
-        return $tests;
-    }
-);
-
 # User task, synchronous
 $worker->register_function(
     retest => sub {
@@ -127,4 +77,56 @@ $worker->register_function(
     },
 );
 
+# User or background task
+$worker->register_function(
+    sync_project => sub {
+        my $job = shift;
+        my $project_name = $job->arg;
+
+        my $project = Smokingit::Model::Project->new;
+        $project->load_by_cols( name => $project_name );
+        return "No such project: $project_name\n"
+            unless $project->id;
+
+        my @results = $project->sync;
+        return @results ? join("\n", at results,"") : "No changes\n";
+    },
+);
+
+# Synchronous task, from worker
+$worker->register_function(
+    post_results => sub {
+        my $job = shift;
+        my $smoke = Smokingit::Model::SmokeResult->new;
+        my ($ok, $msg) = $smoke->post_result($job->arg);
+        warn "$msg\n";
+        return $ok;
+    },
+);
+
+# Background task
+$worker->register_function(
+    plan_tests => sub {
+        my $job = shift;
+        my $project_name = $job->arg;
+
+        my $projects = Smokingit::Model::ProjectCollection->new;
+        if ($project_name) {
+            $projects->limit( column => "name", value => $project_name );
+        } else {
+            $projects->unlimit;
+        }
+        return 0 unless $projects->count;
+
+        my $tests = 0;
+        while (my $project = $projects->next) {
+            Jifty->handle->begin_transaction;
+            $tests += $project->schedule_tests;
+            Jifty->handle->commit;
+        }
+
+        return $tests;
+    }
+);
+
 $worker->work while 1;

commit 49b477233deb4965657310a5338f032ac91227ef
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Tue Mar 13 01:46:08 2012 -0400

    Remove an old, unused import

diff --git a/bin/local_updates b/bin/local_updates
index e353a0d..7cc964e 100755
--- a/bin/local_updates
+++ b/bin/local_updates
@@ -6,7 +6,6 @@ use lib 'lib';
 
 use Jifty;
 BEGIN { Jifty->new; }
-use Benchmark qw/timestr/;
 
 use Gearman::Worker;
 my $worker = Gearman::Worker->new(

commit 29366b32648ede517adf6947b21283da3580cb9a
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Tue Mar 13 01:48:03 2012 -0400

    If a process fails to be sent to gearman, mark it as such
    
    Faking a gearman process is useful because it falls into the "unknown"
    state, rather than the "failed" state, by dint of the defaults in the
    "is_ok" column.  The next check_queue will hence fire it off again.

diff --git a/lib/Smokingit/Model/SmokeResult.pm b/lib/Smokingit/Model/SmokeResult.pm
index e48fc52..846171a 100644
--- a/lib/Smokingit/Model/SmokeResult.pm
+++ b/lib/Smokingit/Model/SmokeResult.pm
@@ -110,11 +110,8 @@ sub run_smoke {
         } ),
         { uniq => $self->id },
     );
-    unless ($job_id) {
-        warn "Unable to insert run_tests job!\n";
-        return 0;
-    }
-    $self->set_gearman_process($job_id);
+    warn "Unable to insert run_tests job!\n" unless $job_id;
+    $self->set_gearman_process($job_id || "failed");
     $self->set_queued_at( Jifty::DateTime->now );
 
     # If we had a result for this already, we need to clean its status
@@ -122,7 +119,7 @@ sub run_smoke {
     # as well as this smoke.
     Smokingit->memcached->delete( $self->commit->status_cache_key );
     Smokingit->memcached->delete( $self->status_cache_key );
-    return 1;
+    return $job_id ? 1 : 0;
 }
 
 sub status_cache_key {

commit d112d1cc5eb2dc861fe78e2c819d0d38c0accac9
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Tue Mar 13 01:49:44 2012 -0400

    Schedule some maintenance when the worker first starts

diff --git a/bin/local_updates b/bin/local_updates
index 7cc964e..1730a5a 100755
--- a/bin/local_updates
+++ b/bin/local_updates
@@ -128,4 +128,12 @@ $worker->register_function(
     }
 );
 
+# Schedule some basic maintenance
+Smokingit->gearman->dispatch_background( check_queue => 1 );
+
+my $projects = Smokingit::Model::ProjectCollection->new;
+$projects->unlimit;
+Smokingit->gearman->dispatch_background( sync_project => $_->name )
+    while $_ = $projects->next;
+
 $worker->work while 1;

commit 41968a9bbe97fdb55951324966151562d1c27f1d
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Tue Mar 13 02:15:27 2012 -0400

    Posting of results is done async now

diff --git a/bin/local_updates b/bin/local_updates
index 1730a5a..ed9b1cf 100755
--- a/bin/local_updates
+++ b/bin/local_updates
@@ -92,7 +92,7 @@ $worker->register_function(
     },
 );
 
-# Synchronous task, from worker
+# Background task, from worker
 $worker->register_function(
     post_results => sub {
         my $job = shift;

commit 376a0718d681a2e809bb7413689a117bdd9ced82
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Wed Mar 14 14:12:24 2012 -0400

    Only show autocompletions for commit authors if we have no owner/reviewer matches

diff --git a/lib/Smokingit/Action/UpdateBranch.pm b/lib/Smokingit/Action/UpdateBranch.pm
index 6dd6622..6ae8349 100644
--- a/lib/Smokingit/Action/UpdateBranch.pm
+++ b/lib/Smokingit/Action/UpdateBranch.pm
@@ -47,11 +47,6 @@ sub autocompleter {
         my $current = shift;
         my %results;
 
-        my $commits = Smokingit::Model::CommitCollection->new;
-        $commits->limit( column => 'project_id', value => $self->record->project->id );
-        $commits->limit( column => 'author', operator => 'MATCHES', value => $current );
-        $results{$_}++ for $commits->distinct_column_values("author");
-
         for my $column (qw/owner review_by/) {
             my $branches = Smokingit::Model::BranchCollection->new;
             $branches->limit(
@@ -63,6 +58,13 @@ sub autocompleter {
         }
         delete $results{$self->record->$skip};
 
+        unless (keys %results) {
+            my $commits = Smokingit::Model::CommitCollection->new;
+            $commits->limit( column => 'project_id', value => $self->record->project->id );
+            $commits->limit( column => 'author', operator => 'MATCHES', value => $current );
+            $results{$_}++ for $commits->distinct_column_values("author");
+        }
+
         my @results = sort keys %results;
         return if @results == 1 and $results[0] eq $current;
         return sort @results;

commit d7ecb0112f4f7e7ff652e94cb39e1319b43e36c3
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Wed Mar 14 14:13:34 2012 -0400

    Warning-proof the cases where the branch has no owner/reviewer yet

diff --git a/lib/Smokingit/Action/UpdateBranch.pm b/lib/Smokingit/Action/UpdateBranch.pm
index 6ae8349..3704864 100644
--- a/lib/Smokingit/Action/UpdateBranch.pm
+++ b/lib/Smokingit/Action/UpdateBranch.pm
@@ -56,7 +56,7 @@ sub autocompleter {
             );
             $results{$_}++ for $branches->distinct_column_values($column);
         }
-        delete $results{$self->record->$skip};
+        delete $results{$self->record->$skip} if $self->record->$skip;
 
         unless (keys %results) {
             my $commits = Smokingit::Model::CommitCollection->new;

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list