File: Github.pm

package info (click to toggle)
devscripts 2.26.5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,808 kB
  • sloc: perl: 28,350; sh: 12,878; python: 4,472; makefile: 382
file content (37 lines) | stat: -rw-r--r-- 1,389 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package Devscripts::Uscan::Templates::Github;

use strict;

sub transform {
    my $watchSource = shift;
    delete $watchSource->{template};
    my $owner   = delete $watchSource->{owner};
    my $project = delete $watchSource->{project};
    my $dist    = delete $watchSource->{dist};
    die 'Missing Owner/Project or Dist' unless $dist or ($owner and $project);
    if ($dist) {
        $dist =~ s#^.*?github\.com#https://api.github.com/repos#;
        $dist =~ s/\.git$//;
    } else {
        $dist = "https://api.github.com/repos/$owner/$project";
    }

    $watchSource->{source} ||= "$dist/git/matching-refs/"
      . ($watchSource->{releaseonly} ? 'release/' : 'tags/');
    $watchSource->{matchingpattern}
      ||= 'https://api.github.com/repos/[^/]+/[^/]+/git/refs/tags/(?>[^/]+(?<=(?:\D|alpha|beta|rc))\-)?'
      . $watchSource->{versiontype}
      . '(?:(?=")|$)';
    $watchSource->{downloadurlmangle}
      ||= 's%(api.github.com/repos/[^/]+/[^/]+)/git/refs/%$1/tarball/refs/%g';
    $watchSource->{filenamemangle} ||= (
        $watchSource->{component}
        ? 's%.*/(?:[^/]+(?<=(?:\D|alpha|beta|rc))\-)?@ANY_VERSION@%@PACKAGE@-@COMPONENT@-$1.tar.gz%'
        : 's%.*/(?:[^/]+(?<=(?:\D|alpha|beta|rc))\-)?@ANY_VERSION@%@PACKAGE@-$1.tar.gz%'
    );
    $watchSource->{searchmode} ||= 'plain';
    $watchSource->{pgpmode}    ||= 'none';
    return $watchSource;
}

1;