| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Git::RemoteURL::Parse; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
387600
|
use 5.010; |
|
|
2
|
|
|
|
|
8
|
|
|
4
|
2
|
|
|
2
|
|
11
|
use strict; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
70
|
|
|
5
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
153
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
13
|
use Exporter 'import'; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
2621
|
|
|
8
|
|
|
|
|
|
|
our @EXPORT_OK = qw(parse_git_remote_url); |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub parse_git_remote_url { |
|
13
|
10
|
|
|
10
|
1
|
4331
|
my ($url) = @_; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# --- GitHub HTTPS URLs --- |
|
16
|
10
|
100
|
|
|
|
69
|
if ($url =~ m{^https:// |
|
|
|
100
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
(?:[^@]+@)? # optional user:token@ |
|
18
|
|
|
|
|
|
|
github\.com/ |
|
19
|
|
|
|
|
|
|
([\w.-]+) # username |
|
20
|
|
|
|
|
|
|
/([\w.-]+?) # repo |
|
21
|
|
|
|
|
|
|
(?:\.git)?$ |
|
22
|
|
|
|
|
|
|
}x |
|
23
|
|
|
|
|
|
|
) { |
|
24
|
2
|
|
|
|
|
10
|
return { service => 'github', user => $1, repo => $2 }; |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# --- GitHub SSH URLs --- |
|
28
|
|
|
|
|
|
|
elsif ($url =~ m{^git@ |
|
29
|
|
|
|
|
|
|
(github\.com|gh[-\w]+) # host: github.com or gh-alias |
|
30
|
|
|
|
|
|
|
: |
|
31
|
|
|
|
|
|
|
([\w.-]+) # username |
|
32
|
|
|
|
|
|
|
/([\w.-]+?) # repo |
|
33
|
|
|
|
|
|
|
(?:\.git)?$ |
|
34
|
|
|
|
|
|
|
}x |
|
35
|
|
|
|
|
|
|
) { |
|
36
|
2
|
|
|
|
|
9
|
return { service => 'github', user => $2, repo => $3 }; |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# --- GitLab HTTPS URLs --- |
|
40
|
6
|
100
|
|
|
|
36
|
if ($url =~ m{^https:// |
|
|
|
100
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
(?:[^@]+@)? # optional user:token@ |
|
42
|
|
|
|
|
|
|
gitlab\.com/ |
|
43
|
|
|
|
|
|
|
((?:[\w.-]+/)+) # group path (at least one level, trailing slash) |
|
44
|
|
|
|
|
|
|
([\w.-]+?) # repo |
|
45
|
|
|
|
|
|
|
(?:\.git)?$ |
|
46
|
|
|
|
|
|
|
}x |
|
47
|
|
|
|
|
|
|
) { |
|
48
|
2
|
|
|
|
|
6
|
my ($groups, $repo) = ($1, $2); |
|
49
|
2
|
|
|
|
|
8
|
$groups =~ s!/$!!; |
|
50
|
2
|
|
|
|
|
8
|
return { service => 'gitlab', group_path => $groups, repo => $repo }; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# --- GitLab SSH URLs --- |
|
54
|
|
|
|
|
|
|
elsif ($url =~ m{^git@ |
|
55
|
|
|
|
|
|
|
(gitlab\.com|gl[-\w]+) # host: gitlab.com or gl-alias |
|
56
|
|
|
|
|
|
|
: |
|
57
|
|
|
|
|
|
|
((?:[\w.-]+/)+) # group path with trailing slash |
|
58
|
|
|
|
|
|
|
([\w.-]+?) # repo |
|
59
|
|
|
|
|
|
|
(?:\.git)?$ |
|
60
|
|
|
|
|
|
|
}x |
|
61
|
|
|
|
|
|
|
) { |
|
62
|
2
|
|
|
|
|
6
|
my ($groups, $repo) = ($2, $3); |
|
63
|
2
|
|
|
|
|
8
|
$groups =~ s!/$!!; |
|
64
|
2
|
|
|
|
|
7
|
return { service => 'gitlab', group_path => $groups, repo => $repo }; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
2
|
|
|
|
|
4
|
return; # No match |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; # End of Git::RemoteURL::Parse |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
__END__ |