Skip to content

Commit 61dae58

Browse files
committed
feat: Store the short rev length
1 parent d042e3c commit 61dae58

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

src/lib/Hydra/Schema/Result/JobsetEvalInputs.pm

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ __PACKAGE__->table("jobsetevalinputs");
6666
data_type: 'text'
6767
is_nullable: 1
6868
69+
=head2 shortRevLength
70+
71+
data_type: 'number'
72+
is_nullable: 1
73+
6974
=head2 value
7075
7176
data_type: 'text'
@@ -102,6 +107,8 @@ __PACKAGE__->add_columns(
102107
{ data_type => "text", is_nullable => 1 },
103108
"revision",
104109
{ data_type => "text", is_nullable => 1 },
110+
"shortRevLength",
111+
{ data_type => "integer", is_nullable => 1 },
105112
"value",
106113
{ data_type => "text", is_nullable => 1 },
107114
"dependency",
@@ -190,7 +197,15 @@ sub frontend_revision() {
190197
if ($type eq 'svn' or $type eq 'svn-checkout' or $type eq 'bzr' or $type eq 'bzr-checkout') {
191198
return 'r' . $self->get_column('revision');
192199
} elsif ($type eq 'git') {
193-
return substr($self->get_column('revision'), 0, 12);
200+
# Find the longest revision length of this URI
201+
my $schema = $self->result_source->schema;
202+
my $maxLength = $schema
203+
->resultset('JobsetEvalInputs')
204+
->search({ uri => $self->get_column('uri')})
205+
->get_column('shortRevLength')
206+
->max;
207+
# Fall back to a fixed value if there was no value
208+
return substr($self->get_column('revision'), 0, $maxLength || 12);
194209
} elsif ($type eq 'bzr') {
195210
return substr($self->get_column('revision'), 0, 12);
196211
} else {

src/script/hydra-eval-jobset

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -891,6 +891,7 @@ sub checkJobsetWrapped {
891891
, type => $input->{type}
892892
, uri => $input->{uri}
893893
, revision => $input->{revision}
894+
, shortRevLength => length($input->{shortRev})
894895
, value => $input->{value}
895896
, dependency => $input->{id}
896897
, path => $input->{storePath} || "" # !!! temporary hack

src/sql/hydra.sql

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -487,11 +487,12 @@ create table JobsetEvalInputs (
487487
altNr integer not null,
488488

489489
-- Copied from the jobsetinputs from which the build was created.
490-
type text not null,
491-
uri text,
492-
revision text,
493-
value text,
494-
dependency integer, -- build ID of the input, for type == 'build'
490+
type text not null,
491+
uri text,
492+
revision text,
493+
shortRevLength smallint, -- length of a short revision at the time this was checked out
494+
value text,
495+
dependency integer, -- build ID of the input, for type == 'build'
495496

496497
path text,
497498

0 commit comments

Comments
 (0)