diff --git a/src/lib/Hydra/Schema/Result/JobsetEvalInputs.pm b/src/lib/Hydra/Schema/Result/JobsetEvalInputs.pm index b3a0cf7e1..465dbd282 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", @@ -183,4 +190,28 @@ sub json_hint { return \%hint; } +# Revision to be rendered by the frontend +sub frontend_revision() { + my ($self) = @_; + my $type = $self->get_column('type'); + 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') { + # 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 { + return $self->get_column('revision'); + } + +} + 1; diff --git a/src/root/common.tt b/src/root/common.tt index b18d33f74..65fbf90b6 100644 --- a/src/root/common.tt +++ b/src/root/common.tt @@ -411,7 +411,7 @@ BLOCK renderInputDiff; %] [% ELSIF bi1.uri == bi2.uri && bi1.revision != bi2.revision %] [% IF bi1.type == "git" %] - [% HTML.escape(bi1.name) %][% INCLUDE renderDiffUri contents=(bi1.revision.substr(0, 12) _ ' to ' _ bi2.revision.substr(0, 12)) %] + [% HTML.escape(bi1.name) %][% INCLUDE renderDiffUri contents=(bi1.frontend_revision _ ' to ' _ bi2.frontend_revision) %] [% ELSE %] @@ -452,16 +452,10 @@ BLOCK renderPager %] BLOCK renderShortEvalInput; - IF input.type == "svn" || input.type == "svn-checkout" || input.type == "bzr" || input.type == "bzr-checkout" %] - r[% input.revision %] - [% ELSIF input.type == "git" %] - [% input.revision.substr(0, 7) | html %] - [% ELSIF input.type == "hg" %] - [% input.revision.substr(0, 12) | html %] - [% ELSIF input.type == "build" || input.type == "sysbuild" %] + IF input.type == "build" || input.type == "sysbuild" %] c.uri_for('/build' input.get_column('dependency'))) %]>[% HTML.escape(input.get_column('dependency')) %] [% ELSE %] - [% input.revision | html %] + [% input.frontend_revision | html %] [% END; END; diff --git a/src/root/reproduce.tt b/src/root/reproduce.tt index d8a77518f..8d44d8f32 100644 --- a/src/root/reproduce.tt +++ b/src/root/reproduce.tt @@ -117,7 +117,7 @@ else revCount="$(cat "$tmpDir/[% input.name %]/rev-count")" fi -args+=(--arg '[% input.name %]' "{ outPath = $inputDir; rev = \"[% input.revision %]\"; shortRev = \"[% input.revision.substr(0, 7) %]\"; revCount = $revCount; }") +args+=(--arg '[% input.name %]' "{ outPath = $inputDir; rev = \"[% input.revision %]\"; shortRev = \"[% input.frontend_revision %]\"; revCount = $revCount; }") [%+ ELSIF input.type == "hg" %] diff --git a/src/script/hydra-eval-jobset b/src/script/hydra-eval-jobset index 4b328ea5e..00d1396f0 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 e94579720..11b270138 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 000000000..24a521ccf --- /dev/null +++ b/src/sql/upgrade-85.sql @@ -0,0 +1 @@ +ALTER TABLE JobsetEvalInputs ADD COLUMN shortRevLength smallint;