From 2db62e86e745d7a74414a1115382c0fbe9f9ab37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janne=20He=C3=9F?= Date: Sun, 4 Jan 2026 18:56:20 +0100 Subject: [PATCH] feat: Store the short rev length --- src/lib/Hydra/Schema/Result/JobsetEvalInputs.pm | 17 ++++++++++++++++- src/script/hydra-eval-jobset | 1 + src/sql/hydra.sql | 11 ++++++----- src/sql/upgrade-85.sql | 1 + 4 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 src/sql/upgrade-85.sql diff --git a/src/lib/Hydra/Schema/Result/JobsetEvalInputs.pm b/src/lib/Hydra/Schema/Result/JobsetEvalInputs.pm index acde8b43..465dbd28 100644 --- a/src/lib/Hydra/Schema/Result/JobsetEvalInputs.pm +++ b/src/lib/Hydra/Schema/Result/JobsetEvalInputs.pm @@ -66,6 +66,11 @@ __PACKAGE__->table("jobsetevalinputs"); data_type: 'text' is_nullable: 1 +=head2 shortRevLength + + data_type: 'number' + is_nullable: 1 + =head2 value data_type: 'text' @@ -102,6 +107,8 @@ __PACKAGE__->add_columns( { data_type => "text", is_nullable => 1 }, "revision", { data_type => "text", is_nullable => 1 }, + "shortRevLength", + { data_type => "integer", is_nullable => 1 }, "value", { data_type => "text", is_nullable => 1 }, "dependency", @@ -190,7 +197,15 @@ sub frontend_revision() { if ($type eq 'svn' or $type eq 'svn-checkout' or $type eq 'bzr' or $type eq 'bzr-checkout') { return 'r' . $self->get_column('revision'); } elsif ($type eq 'git') { - return substr($self->get_column('revision'), 0, 12); + # Find the longest revision length of this URI + my $schema = $self->result_source->schema; + my $maxLength = $schema + ->resultset('JobsetEvalInputs') + ->search({ uri => $self->get_column('uri')}) + ->get_column('shortRevLength') + ->max; + # Fall back to a fixed value if there was no value + return substr($self->get_column('revision'), 0, $maxLength || 12); } elsif ($type eq 'bzr') { return substr($self->get_column('revision'), 0, 12); } else { diff --git a/src/script/hydra-eval-jobset b/src/script/hydra-eval-jobset index 4b328ea5..00d1396f 100755 --- a/src/script/hydra-eval-jobset +++ b/src/script/hydra-eval-jobset @@ -891,6 +891,7 @@ sub checkJobsetWrapped { , type => $input->{type} , uri => $input->{uri} , revision => $input->{revision} + , shortRevLength => length($input->{shortRev}) , value => $input->{value} , dependency => $input->{id} , path => $input->{storePath} || "" # !!! temporary hack diff --git a/src/sql/hydra.sql b/src/sql/hydra.sql index e9457972..11b27013 100644 --- a/src/sql/hydra.sql +++ b/src/sql/hydra.sql @@ -487,11 +487,12 @@ create table JobsetEvalInputs ( altNr integer not null, -- Copied from the jobsetinputs from which the build was created. - type text not null, - uri text, - revision text, - value text, - dependency integer, -- build ID of the input, for type == 'build' + type text not null, + uri text, + revision text, + shortRevLength smallint, -- length of a short revision at the time this was checked out + value text, + dependency integer, -- build ID of the input, for type == 'build' path text, diff --git a/src/sql/upgrade-85.sql b/src/sql/upgrade-85.sql new file mode 100644 index 00000000..24a521cc --- /dev/null +++ b/src/sql/upgrade-85.sql @@ -0,0 +1 @@ +ALTER TABLE JobsetEvalInputs ADD COLUMN shortRevLength smallint;