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 11using System ;
22using System . Collections . Generic ;
3+ using System . Text . RegularExpressions ;
34
45namespace SourceGit . Models
56{
6- public class CommitLink
7+ public partial class CommitLink
78 {
89 public string Name { get ; set ; } = null ;
910 public string URLPrefix { get ; set ; } = null ;
@@ -14,6 +15,9 @@ public CommitLink(string name, string prefix)
1415 URLPrefix = prefix ;
1516 }
1617
18+ [ GeneratedRegex ( @"^(http|https)://[^/]*gitlab[^/]*(:[0-9]+)?.*$" ) ]
19+ private static partial Regex REG_GITLAB ( ) ;
20+
1721 public static List < CommitLink > Get ( List < Remote > remotes )
1822 {
1923 var outs = new List < CommitLink > ( ) ;
@@ -28,7 +32,7 @@ public static List<CommitLink> Get(List<Remote> remotes)
2832
2933 if ( url . StartsWith ( "https://github.com/" , StringComparison . Ordinal ) )
3034 outs . Add ( new ( $ "GitHub ({ trimmedUrl [ 19 ..] } )", $ "{ url } /commit/") ) ;
31- else if ( url . StartsWith ( "https://gitlab." , StringComparison . Ordinal ) )
35+ else if ( REG_GITLAB ( ) . IsMatch ( url ) )
3236 outs . Add ( new ( $ "GitLab ({ trimmedUrl [ ( trimmedUrl [ 15 ..] . IndexOf ( '/' ) + 16 ) ..] } )", $ "{ url } /-/commit/") ) ;
3337 else if ( url . StartsWith ( "https://gitee.com/" , StringComparison . Ordinal ) )
3438 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
88 {
99 [ GeneratedRegex ( @"^https?://[^/]+/.+[^/\.]$" ) ]
1010 private static partial Regex REG_HTTPS ( ) ;
11+
1112 [ GeneratedRegex ( @"^git://[^/]+/.+[^/\.]$" ) ]
1213 private static partial Regex REG_GIT ( ) ;
14+
1315 [ GeneratedRegex ( @"^[\w\-]+@[\w\.\-]+(\:[0-9]+)?:([a-zA-z0-9~%][\w\-\./~%]*)?[a-zA-Z0-9](\.git)?$" ) ]
1416 private static partial Regex REG_SSH1 ( ) ;
17+
1518 [ GeneratedRegex ( @"^ssh://([\w\-]+@)?[\w\.\-]+(\:[0-9]+)?/([a-zA-z0-9~%][\w\-\./~%]*)?[a-zA-Z0-9](\.git)?$" ) ]
1619 private static partial Regex REG_SSH2 ( ) ;
1720
You can’t perform that action at this time.
0 commit comments