Branch: refs/heads/master
  Home:   https://github.com/NixOS/hydra
  Commit: d350b935f2939fee7e6bda9e1f8ae3b4f281c07f
      
https://github.com/NixOS/hydra/commit/d350b935f2939fee7e6bda9e1f8ae3b4f281c07f
  Author: Eelco Dolstra <[email protected]>
  Date:   2012-04-17 (Tue, 17 Apr 2012)

  Changed paths:
    M src/lib/Hydra/Controller/Jobset.pm
    M src/lib/Hydra/Controller/JobsetEval.pm
    M src/lib/Hydra/Controller/Project.pm
    M src/lib/Hydra/Helper/CatalystUtils.pm

  Log Message:
  -----------
  Add validation for project and jobset names


diff --git a/src/lib/Hydra/Controller/Jobset.pm 
b/src/lib/Hydra/Controller/Jobset.pm
index 4dc9009..fa968ef 100644
--- a/src/lib/Hydra/Controller/Jobset.pm
+++ b/src/lib/Hydra/Controller/Jobset.pm
@@ -221,7 +221,7 @@ sub updateJobset {
     my ($c, $jobset) = @_;
 
     my $jobsetName = trim $c->request->params->{"name"};
-    error($c, "Invalid jobset name: $jobsetName") unless $jobsetName =~ 
/^[[:alpha:]][\w\-]*$/;
+    error($c, "Invalid jobset name: ‘$jobsetName’") if $jobsetName !~ 
/^$jobsetNameRE$/;
 
     my ($nixExprPath, $nixExprInput) = nixExprPathFromParams $c;
 
@@ -298,13 +298,13 @@ sub clone_submit : Chained('jobset') 
PathPart('clone/submit') Args(0) {
     requireProjectOwner($c, $jobset->project);
     requirePost($c);
 
-    my $newjobsetName = trim $c->request->params->{"newjobset"};
-    error($c, "Invalid jobset name: $newjobsetName") unless $newjobsetName =~ 
/^[[:alpha:]][\w\-]*$/;
+    my $newJobsetName = trim $c->request->params->{"newjobset"};
+    error($c, "Invalid jobset name: $newJobsetName") unless $newJobsetName =~ 
/^[[:alpha:]][\w\-]*$/;
 
-    my $newjobset;
+    my $newJobset;
     txn_do($c->model('DB')->schema, sub {
-        $newjobset = $jobset->project->jobsets->create(
-            { name => $newjobsetName
+        $newJobset = $jobset->project->jobsets->create(
+            { name => $newJobsetName
             , description => $jobset->description
             , nixexprpath => $jobset->nixexprpath
             , nixexprinput => $jobset->nixexprinput
@@ -314,14 +314,14 @@ sub clone_submit : Chained('jobset') 
PathPart('clone/submit') Args(0) {
             });
 
         foreach my $input ($jobset->jobsetinputs) {
-            my $newinput = $newjobset->jobsetinputs->create({name => 
$input->name, type => $input->type});
+            my $newinput = $newJobset->jobsetinputs->create({name => 
$input->name, type => $input->type});
             foreach my $inputalt ($input->jobsetinputalts) {
                 $newinput->jobsetinputalts->create({altnr => $inputalt->altnr, 
value => $inputalt->value});
             }
         }
     });
 
-    
$c->res->redirect($c->uri_for($c->controller('Jobset')->action_for("edit"), 
[$jobset->project->name, $newjobsetName]));
+    
$c->res->redirect($c->uri_for($c->controller('Jobset')->action_for("edit"), 
[$jobset->project->name, $newJobsetName]));
 }
 
 
diff --git a/src/lib/Hydra/Controller/JobsetEval.pm 
b/src/lib/Hydra/Controller/JobsetEval.pm
index 76c85fe..ebfc49b 100644
--- a/src/lib/Hydra/Controller/JobsetEval.pm
+++ b/src/lib/Hydra/Controller/JobsetEval.pm
@@ -32,13 +32,17 @@ sub view : Chained('eval') PathPart('') Args(0) {
     # Allow comparing this evaluation against the previous evaluation
     # (default), an arbitrary evaluation, or the latest completed
     # evaluation of another jobset.
-    if (defined $compare && $compare =~ /^\d+$/) {
-        $eval2 = $c->model('DB::JobsetEvals')->find($compare)
-            or notFound($c, "Evaluation $compare doesn't exist.");
-    } elsif (defined $compare && $compare =~ /^($jobNameRE)$/) {
-        my $j = $c->stash->{project}->jobsets->find({name => $compare})
-            or notFound($c, "Jobset $compare doesn't exist.");
-        $eval2 = getLatestFinishedEval($c, $j);
+    if (defined $compare) {
+        if ($compare =~ /^\d+$/) {
+            $eval2 = $c->model('DB::JobsetEvals')->find($compare)
+                or notFound($c, "Evaluation $compare doesn't exist.");
+        } elsif (defined $compare && $compare =~ /^($jobsetNameRE)$/) {
+            my $j = $c->stash->{project}->jobsets->find({name => $compare})
+                or notFound($c, "Jobset $compare doesn't exist.");
+            $eval2 = getLatestFinishedEval($c, $j);
+        } else {
+            notFound($c, "Unknown comparison source ‘$compare’.");
+        }
     } else {
         ($eval2) = $eval->jobset->jobsetevals->search(
             { hasnewbuilds => 1, id => { '<', $eval->id } },
diff --git a/src/lib/Hydra/Controller/Project.pm 
b/src/lib/Hydra/Controller/Project.pm
index 0b600d4..1859794 100644
--- a/src/lib/Hydra/Controller/Project.pm
+++ b/src/lib/Hydra/Controller/Project.pm
@@ -119,6 +119,8 @@ sub create_submit : Path('/create-project/submit') {
 
     my $projectName = trim $c->request->params->{name};
     
+    error($c, "Invalid project name: ‘$projectName’") if $projectName !~ 
/^$projectNameRE$/;
+
     txn_do($c->model('DB')->schema, sub {
         # Note: $projectName is validated in updateProject,
         # which will abort the transaction if the name isn't
@@ -152,6 +154,8 @@ sub create_jobset_submit : Chained('project') 
PathPart('create-jobset/submit') A
     
     my $jobsetName = trim $c->request->params->{name};
 
+    error($c, "Invalid jobset name: ‘$jobsetName’") if $jobsetName !~ 
/^$jobsetNameRE$/;
+
     txn_do($c->model('DB')->schema, sub {
         # Note: $jobsetName is validated in updateProject, which will
         # abort the transaction if the name isn't valid.
@@ -168,7 +172,7 @@ sub create_jobset_submit : Chained('project') 
PathPart('create-jobset/submit') A
 sub updateProject {
     my ($c, $project) = @_;
     my $projectName = trim $c->request->params->{name};
-    error($c, "Invalid project name: " . ($projectName || "(empty)")) unless 
$projectName =~ /^[[:alpha:]][\w\-]*$/;
+    error($c, "Invalid project name: ‘$projectName’") if $projectName !~ 
/^$projectNameRE$/;
     
     my $displayName = trim $c->request->params->{displayname};
     error($c, "Invalid display name: $displayName") if $displayName eq "";
diff --git a/src/lib/Hydra/Helper/CatalystUtils.pm 
b/src/lib/Hydra/Helper/CatalystUtils.pm
index 80c391a..a58c9c3 100644
--- a/src/lib/Hydra/Helper/CatalystUtils.pm
+++ b/src/lib/Hydra/Helper/CatalystUtils.pm
@@ -13,7 +13,7 @@ our @EXPORT = qw(
     requireLogin requireProjectOwner requireAdmin requirePost isAdmin 
isProjectOwner
     trim
     getLatestFinishedEval
-    $pathCompRE $relPathRE $relNameRE $jobNameRE $systemRE
+    $pathCompRE $relPathRE $relNameRE $projectNameRE $jobsetNameRE $jobNameRE 
$systemRE
     @buildListColumns
 );
 
@@ -181,12 +181,14 @@ sub getLatestFinishedEval {
 
 
 # Security checking of filenames.
-Readonly our $pathCompRE => "(?:[A-Za-z0-9-\+\._][A-Za-z0-9-\+\._]*)";
-Readonly our $relPathRE  => "(?:$pathCompRE(?:/$pathCompRE)*)";
-Readonly our $relNameRE  => "(?:[A-Za-z0-9-][A-Za-z0-9-\.]*)";
-Readonly our $attrNameRE => "(?:[A-Za-z_][A-Za-z0-9_]*)";
-Readonly our $jobNameRE  => "(?:$attrNameRE(?:\\.$attrNameRE)*)";
-Readonly our $systemRE   => "(?:[a-z0-9_]+-[a-z0-9_]+)";
+Readonly our $pathCompRE    => "(?:[A-Za-z0-9-\+\._][A-Za-z0-9-\+\._]*)";
+Readonly our $relPathRE     => "(?:$pathCompRE(?:/$pathCompRE)*)";
+Readonly our $relNameRE     => "(?:[A-Za-z0-9-][A-Za-z0-9-\.]*)";
+Readonly our $attrNameRE    => "(?:[A-Za-z_][A-Za-z0-9_]*)";
+Readonly our $projectNameRE => "(?:[A-Za-z_][A-Za-z0-9-_]*)";
+Readonly our $jobsetNameRE  => "(?:[A-Za-z_][A-Za-z0-9-_]*)";
+Readonly our $jobNameRE     => "(?:$attrNameRE(?:\\.$attrNameRE)*)";
+Readonly our $systemRE      => "(?:[a-z0-9_]+-[a-z0-9_]+)";
 
 
 1;


================================================================
  Commit: 896a47d9502fe6bcb79694a13f1a908d6eccc76b
      
https://github.com/NixOS/hydra/commit/896a47d9502fe6bcb79694a13f1a908d6eccc76b
  Author: Eelco Dolstra <[email protected]>
  Date:   2012-04-17 (Tue, 17 Apr 2012)

  Changed paths:
    M src/lib/Hydra/Controller/Build.pm
    M src/lib/Hydra/Helper/AddBuilds.pm

  Log Message:
  -----------
  Clear nrSucceeded when restarting a build


diff --git a/src/lib/Hydra/Controller/Build.pm 
b/src/lib/Hydra/Controller/Build.pm
index f9f1825..b3442f0 100644
--- a/src/lib/Hydra/Controller/Build.pm
+++ b/src/lib/Hydra/Controller/Build.pm
@@ -351,9 +351,9 @@ sub restart : Chained('build') PathPart Args(0) {
 
     requireProjectOwner($c, $build->project);
     
-    my $drvpath = $build->drvpath ;
+    my $drvpath = $build->drvpath;
     error($c, "This build cannot be restarted.")
-        unless $build->finished && -f $drvpath ;
+        unless $build->finished && -f $drvpath;
 
     restartBuild($c->model('DB')->schema, $build);
 
diff --git a/src/lib/Hydra/Helper/AddBuilds.pm 
b/src/lib/Hydra/Helper/AddBuilds.pm
index c6c7703..1e9bd0e 100644
--- a/src/lib/Hydra/Helper/AddBuilds.pm
+++ b/src/lib/Hydra/Helper/AddBuilds.pm
@@ -968,5 +968,11 @@ sub restartBuild {
             , busy => 0
             , locker => ""
            });
+
+        # Reset the stats for the evals to which this build belongs.
+        # !!! Should do this in a trigger.
+        foreach my $m ($build->jobsetevalmembers->all) {
+            $m->eval->update({nrsucceeded => undef});
+        }
     });
 }


================================================================
  Commit: 634d8c092fb48113a4434a344a2a34d730cc94cb
      
https://github.com/NixOS/hydra/commit/634d8c092fb48113a4434a344a2a34d730cc94cb
  Author: Eelco Dolstra <[email protected]>
  Date:   2012-04-17 (Tue, 17 Apr 2012)

  Changed paths:
    M src/root/build.tt

  Log Message:
  -----------
  Use <h3> for running/failed build steps


diff --git a/src/root/build.tt b/src/root/build.tt
index 47d3d19..a6b51c8 100644
--- a/src/root/build.tt
+++ b/src/root/build.tt
@@ -9,8 +9,6 @@
 [% job = build.job %]
 
 [% BLOCK renderBuildSteps %]
-
-       <h2 id="buildsteps">[% type %] build steps</h2>
        <table class="tablesorter table table-striped table-condensed">
          <thead>
            
<tr><th>Nr</th><th>What</th><th>Duration</th><th>Machine</th><th>Status</th></tr>
@@ -67,7 +65,7 @@
 
 
 [% IF flashMsg %]
-<p class="error">[% flashMsg %]</p>
+<p class="btn-info btn-large">[% flashMsg %]</p>
 [% END %]
 
        <ul id="tab" class="nav nav-tabs">
@@ -160,12 +158,14 @@
                        
                [% END %]
 
-        [% IF !build.finished && build.buildsteps.size > 0 %]
+        [% IF !build.finished %]
+            <h3>Running build steps</h3>
             [% INCLUDE renderBuildSteps type="Running" %]
        [% END %]
 
                [% IF build.finished %]
                        [% IF build.buildsteps && build.buildstatus != 0 && 
build.buildstatus != 6 %]
+                                <h3>Failed build steps</h3>
                                [% INCLUDE renderBuildSteps type="Failed" %]
                        [% END %]
 
@@ -416,9 +416,10 @@
         [% END %]
 
 [% IF build.buildsteps %]
-       <div id="tabs-buildsteps" class="tab-pane">
-               [% INCLUDE renderBuildSteps type="All" %]
-       </div>
+  <div id="tabs-buildsteps" class="tab-pane">
+    <h2>All build steps</h2>
+    [% INCLUDE renderBuildSteps type="All" %]
+  </div>
 [% END %]
        
 


================================================================
  Commit: ea4aba83c317d5ecac72bbd93280b376f82d1217
      
https://github.com/NixOS/hydra/commit/ea4aba83c317d5ecac72bbd93280b376f82d1217
  Author: Eelco Dolstra <[email protected]>
  Date:   2012-04-17 (Tue, 17 Apr 2012)

  Changed paths:
    M src/root/queue.tt

  Log Message:
  -----------
  Proper styling for flash message


diff --git a/src/root/queue.tt b/src/root/queue.tt
index 58a3d00..0ab13a0 100644
--- a/src/root/queue.tt
+++ b/src/root/queue.tt
@@ -6,7 +6,7 @@
 <p>[ <a href="[% c.uri_for('/status') %]">Running build steps</a> ]</p>
 
 [% IF flashMsg %]
-<p class="error">[% flashMsg %]</p>
+<p class="btn-info btn-large">[% flashMsg %]</p>
 [% END %]
 
 [% IF queue.size == 0 %]


================================================================
  Commit: db09760e8cde3454372f572c168a67fb3d004515
      
https://github.com/NixOS/hydra/commit/db09760e8cde3454372f572c168a67fb3d004515
  Author: Eelco Dolstra <[email protected]>
  Date:   2012-04-17 (Tue, 17 Apr 2012)

  Changed paths:
    M src/root/common.tt
    M src/root/topbar.tt

  Log Message:
  -----------
  Move the "Cancel build" button to the menu


diff --git a/src/root/common.tt b/src/root/common.tt
index bbf4ced..1f90028 100644
--- a/src/root/common.tt
+++ b/src/root/common.tt
@@ -273,11 +273,6 @@
     since [% INCLUDE renderDateTime timestamp = build.starttime %]
   [% ELSE %]
     <strong>Scheduled to be built</strong>
-    [% IF c.user_exists %]
-      <form action="[% c.uri_for('/build' build.id 'cancel') %]" method="post" 
class="inline">
-        <button id="cancel" type="submit">Cancel</button>
-      </form>
-    [% END %]
   [% END %] 
 [% END -%]
 
diff --git a/src/root/topbar.tt b/src/root/topbar.tt
index 6c82212..4f9e512 100644
--- a/src/root/topbar.tt
+++ b/src/root/topbar.tt
@@ -145,6 +145,9 @@
           [% INCLUDE makeLink
             uri = c.uri_for('/build' build.id 'restart')
             title = "Restart build" %]
+          [% INCLUDE makeLink
+            uri = c.uri_for('/build' build.id 'cancel')
+            title = "Cancel build" %]
       [% END %]
 
     [% END %]


================================================================
  Commit: 8f31935ffaa9fddddbd0250756eaa6b6c981fcba
      
https://github.com/NixOS/hydra/commit/8f31935ffaa9fddddbd0250756eaa6b6c981fcba
  Author: Eelco Dolstra <[email protected]>
  Date:   2012-04-17 (Tue, 17 Apr 2012)

  Changed paths:
    M src/script/hydra-evaluator

  Log Message:
  -----------
  Handle the case where there are no builds and no previous eval


diff --git a/src/script/hydra-evaluator b/src/script/hydra-evaluator
index 7e3fac6..1fc0d26 100755
--- a/src/script/hydra-evaluator
+++ b/src/script/hydra-evaluator
@@ -194,7 +194,7 @@ sub checkJobset {
             $ev->builds->update({iscurrent => 1});
         } else {
             print STDERR "  created cached eval ", $ev->id, "\n";
-            $prevEval->builds->update({iscurrent => 1});
+            $prevEval->builds->update({iscurrent => 1}) if defined $prevEval;
         }
     });
        


================================================================
Compare: https://github.com/NixOS/hydra/compare/90e0ba2...8f31935
_______________________________________________
nix-commits mailing list
[email protected]
http://lists.science.uu.nl/mailman/listinfo/nix-commits

Reply via email to