Skip to content

Commit 1908829

Browse files
authored
Feature: Added support for cloning GitLab repository URLs (#17509)
1 parent 3e8e07a commit 1908829

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Files.App/Utils/Git/GitHelpers.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -870,10 +870,11 @@ public static (string RepoUrl, string RepoName) GetRepoInfo(string url)
870870
if (!match.Success)
871871
return (string.Empty, string.Empty);
872872

873+
string platform = match.Groups["domain"].Value;
873874
string userOrOrg = match.Groups["user"].Value;
874875
string repoName = match.Groups["repo"].Value;
875876

876-
string repoUrl = $"https://github.com/{userOrOrg}/{repoName}";
877+
string repoUrl = $"https://{platform}.com/{userOrOrg}/{repoName}";
877878
return (repoUrl, repoName);
878879
}
879880

@@ -943,7 +944,7 @@ public static async Task CloneRepoAsync(string repoUrl, string repoName, string
943944
ReturnResult.Failed);
944945
}
945946

946-
[GeneratedRegex(@"^(?:https?:\/\/)?(?:www\.)?github\.com\/(?<user>[^\/]+)\/(?<repo>[^\/]+?)(?=\.git|\/|$)(?:\.git)?(?:\/)?", RegexOptions.IgnoreCase)]
947+
[GeneratedRegex(@"^(?:https?:\/\/)?(?:www\.)?(?<domain>github|gitlab)\.com\/(?<user>[^\/]+)\/(?<repo>[^\/]+?)(?=\.git|\/|$)(?:\.git)?(?:\/)?", RegexOptions.IgnoreCase)]
947948
private static partial Regex GitHubRepositoryRegex();
948949
}
949950
}

0 commit comments

Comments
 (0)