From 0fd997ecf4444c84715c7121e068287acbaafc39 Mon Sep 17 00:00:00 2001 From: Athos Ribeiro Date: Wed, 11 Nov 2015 18:05:15 -0200 Subject: [PATCH] add row for git stable-4.x branch --- lib/CoprStatus.pm | 23 ++++++++++++++++++----- t/app.t | 4 ++-- template.html.tt | 10 +++++++++- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/lib/CoprStatus.pm b/lib/CoprStatus.pm index 4f76410..83686e1 100644 --- a/lib/CoprStatus.pm +++ b/lib/CoprStatus.pm @@ -45,7 +45,19 @@ sub copr_info { my $release = $1 if $spec->decoded_content =~ /^Release:\s*([^\s]+)\s*$/m; $version = "$version-$release"; - $info->{$key}->{'git_version'} = $version; + $info->{$key}->{'git_version_master'} = $version; + } + + foreach my $key (keys %{$info}) { + my $spec = $ua->get("https://softwarepublico.gov.br/gitlab/softwarepublico/softwarepublico/raw/stable-4.x/src/pkg-rpm/$key/$key.spec"); + my $version = $1 if $spec->decoded_content =~ /^Version:\s*([^\s]+)\s*$/m; + if($version =~ /%\{version\}/) { + $version = $1 if $spec->decoded_content =~ /define version\s*([^\s]+)\s*$/m; + } + + my $release = $1 if $spec->decoded_content =~ /^Release:\s*([^\s]+)\s*$/m; + $version = "$version-$release"; + $info->{$key}->{'git_version_stable_4'} = $version; } return $info; @@ -55,7 +67,7 @@ sub compare_versions { my $info = copr_info(); my $match = {}; foreach my $key (keys %{$info}) { - if($info->{$key}->{'v5_version'} eq $info->{$key}->{git_version}) { + if($info->{$key}->{'v5_version'} eq $info->{$key}->{git_version_master}) { $match->{$key} = 1; } else { @@ -72,14 +84,14 @@ sub info2html { foreach my $key (keys %{$info}) { my $fill_v4_row; my $fill_v5_row; - if($info->{$key}->{'v4_version'} eq $info->{$key}->{git_version}) { + if($info->{$key}->{'v4_version'} eq $info->{$key}->{git_version_stable_4}) { $fill_v4_row = "success"; } else { $fill_v4_row = "danger"; } - if($info->{$key}->{'v5_version'} eq $info->{$key}->{git_version}) { + if($info->{$key}->{'v5_version'} eq $info->{$key}->{git_version_master}) { $fill_v5_row = "success"; } else { @@ -88,8 +100,9 @@ sub info2html { $table_entries .= " $key - $info->{$key}->{'git_version'} + $info->{$key}->{'git_version_stable_4'} $info->{$key}->{'v4_version'} + $info->{$key}->{'git_version_master'} $info->{$key}->{'v5_version'} "; } diff --git a/t/app.t b/t/app.t index ac67718..016cc26 100644 --- a/t/app.t +++ b/t/app.t @@ -8,12 +8,12 @@ my $info = CoprStatus::copr_info(); ok(ref($info), 'HASH'); foreach my $key (keys %{$info}) { ok(ref($info->{$key}), 'HASH'); - ok($info->{$key}->{'git_version'}); + ok($info->{$key}->{'git_version_master'}); ok($info->{$key}->{'v4_version'}); ok($info->{$key}->{'v5_version'}); like($info->{$key}->{'v4_version'}, qr/[[:ascii:]]+-[[:ascii:]]+/); like($info->{$key}->{'v5_version'}, qr/[[:ascii:]]+-[[:ascii:]]+/); - like($info->{$key}->{'git_version'}, qr/[[:ascii:]]+-[[:ascii:]]+/); + like($info->{$key}->{'git_version_master'}, qr/[[:ascii:]]+-[[:ascii:]]+/); } my $match = CoprStatus::compare_versions; diff --git a/template.html.tt b/template.html.tt index adb57db..bfeca1e 100644 --- a/template.html.tt +++ b/template.html.tt @@ -47,9 +47,17 @@
+ + + + + + + - + + {$table_entries} -- libgit2 0.21.2
Release 4Release 5
PACKAGEgitgit:stable-4.x softwarepublico/v4git:master softwarepublico/v5