File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change 1
1
using System ;
2
2
using System . Collections . Generic ;
3
+ using System . Text . RegularExpressions ;
3
4
4
5
namespace SourceGit . Models
5
6
{
6
- public class CommitLink
7
+ public partial class CommitLink
7
8
{
8
9
public string Name { get ; set ; } = null ;
9
10
public string URLPrefix { get ; set ; } = null ;
@@ -14,6 +15,9 @@ public CommitLink(string name, string prefix)
14
15
URLPrefix = prefix ;
15
16
}
16
17
18
+ [ GeneratedRegex ( @"^(http|https)://[^/]*gitlab[^/]*(:[0-9]+)?.*$" ) ]
19
+ private static partial Regex REG_GITLAB ( ) ;
20
+
17
21
public static List < CommitLink > Get ( List < Remote > remotes )
18
22
{
19
23
var outs = new List < CommitLink > ( ) ;
@@ -28,7 +32,7 @@ public static List<CommitLink> Get(List<Remote> remotes)
28
32
29
33
if ( url . StartsWith ( "https://github.com/" , StringComparison . Ordinal ) )
30
34
outs . Add ( new ( $ "GitHub ({ trimmedUrl [ 19 ..] } )", $ "{ url } /commit/") ) ;
31
- else if ( url . StartsWith ( "https://gitlab." , StringComparison . Ordinal ) )
35
+ else if ( REG_GITLAB ( ) . IsMatch ( url ) )
32
36
outs . Add ( new ( $ "GitLab ({ trimmedUrl [ ( trimmedUrl [ 15 ..] . IndexOf ( '/' ) + 16 ) ..] } )", $ "{ url } /-/commit/") ) ;
33
37
else if ( url . StartsWith ( "https://gitee.com/" , StringComparison . Ordinal ) )
34
38
outs . Add ( new ( $ "Gitee ({ trimmedUrl [ 18 ..] } )", $ "{ url } /commit/") ) ;
Original file line number Diff line number Diff line change @@ -8,10 +8,13 @@ public partial class Remote
8
8
{
9
9
[ GeneratedRegex ( @"^https?://[^/]+/.+[^/\.]$" ) ]
10
10
private static partial Regex REG_HTTPS ( ) ;
11
+
11
12
[ GeneratedRegex ( @"^git://[^/]+/.+[^/\.]$" ) ]
12
13
private static partial Regex REG_GIT ( ) ;
14
+
13
15
[ GeneratedRegex ( @"^[\w\-]+@[\w\.\-]+(\:[0-9]+)?:([a-zA-z0-9~%][\w\-\./~%]*)?[a-zA-Z0-9](\.git)?$" ) ]
14
16
private static partial Regex REG_SSH1 ( ) ;
17
+
15
18
[ GeneratedRegex ( @"^ssh://([\w\-]+@)?[\w\.\-]+(\:[0-9]+)?/([a-zA-z0-9~%][\w\-\./~%]*)?[a-zA-Z0-9](\.git)?$" ) ]
16
19
private static partial Regex REG_SSH2 ( ) ;
17
20
You can’t perform that action at this time.
0 commit comments