Skip to content

Commit

Permalink
Fix how GitHub detected versions are handled
Browse files Browse the repository at this point in the history
  • Loading branch information
jasperla committed Apr 15, 2017
1 parent c1b67a2 commit ca6af08
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
11 changes: 2 additions & 9 deletions Portroach/SiteHandler/GitHub.pm
Original file line number Diff line number Diff line change
Expand Up @@ -120,21 +120,14 @@ sub GetFiles
$response = $ua->request(HTTP::Request->new(GET => $query));

if ($response->is_success) {
# TODO: To generate proper URLs in the frontend:
# If the project has done actual releases, (check the
# url), then look for the item with label "Source
# code" and use it's name field
#
# For now we take the filename part of the URI, add
# a recognized extension and treat it as a file.

$json = decode_json($response->decoded_content);

my $filename = (URI->new($json->{tarball_url})->path_segments)[-1];
_debug(" -> " . $filename);
$filename =~ s/^v//;
$projname =~ m/.*?\/(.*)/;
push(@$files, $1 . "-" . $filename . ".tar.gz");
# Use '%%' as a placeholder for easier splitting in FindNewestFile().
push(@$files, $1 . "%%" . $filename . ".tar.gz");
} else {
_debug('GET failed for /latest: ' . $response->status_line);
# Project didn't do any releases, so let's try tags instead.
Expand Down
28 changes: 21 additions & 7 deletions portroach.pl
Original file line number Diff line number Diff line change
Expand Up @@ -891,8 +891,14 @@ sub FindNewestFile
{
my $v = $port->{ver};
my $s = $port->{sufx};
my $old_v;
$github = 1 if ($site->clone =~ /https:\/\/github.com\//);

my $old_v = $v;
if ($github) {
$old_v = $distfile;
} else {
$old_v = $v;
}

my $skip = 0;

Expand Down Expand Up @@ -920,8 +926,6 @@ sub FindNewestFile
}
}

$github = 1 if ($site->clone =~ /https:\/\/github.com\//);

# Skip beta versions if requested

if ($port->{skipbeta}) {
Expand Down Expand Up @@ -976,13 +980,23 @@ sub FindNewestFile
# (formatted -> "just a number")
next if ($new_v !~ /\./ && $old_v =~ /\./);
} else {
# Github is "special" since the actual URI we get back from the
# handler isn't the same as what is actually being retrieved.
# So fall back on comparing tags instead.
# GitHub is "special" as the API gives us a non-${EXTRACT_SUFX}
# as filename (e.g. tarball/v0.25.1). The sitehandler uses the
# last part to stub a distname thru 'project%%$V.tar.gz'.
# The '%%' placeholder is used to make it easier here to extract
# the actual version.
# NB: The link in the webinterface is will still point to the
# previous tag as the recorded master site contains a
# hardcoded version. Little we can do at this point.
$version = $1 if $file =~ m/%%(.*)\.tar.gz/;

# Turn this into the real filename and set $new_v to the filename.
$file =~ s/%%/-/;
$new_v = $file;
$version = lc $new_v;
}

print STDERR "version:${version} new_v:${new_v} old_v:${old_v} file:${file}\n" if ($settings{debug});

# Skip any specific versions if requested
if ($port->{skipversions}) {
my $skip = 0;
Expand Down

0 comments on commit ca6af08

Please sign in to comment.