project: reorganize the structure of the project.

* remove dotnet-tool.json because the project does not rely on any dotnet tools.
* remove Directory.Build.props because the solution has only one project.
* move src/SourceGit to src. It's not needed to put all sources into a subfolder of src since there's only one project.
This commit is contained in:
leo 2024-04-02 20:00:33 +08:00
parent 96e60da7ad
commit 96d4150d26
319 changed files with 37 additions and 53 deletions

49
src/Models/Remote.cs Normal file
View file

@ -0,0 +1,49 @@
using System.Text.RegularExpressions;
namespace SourceGit.Models
{
public partial class Remote
{
[GeneratedRegex(@"^http[s]?://([\w\-]+@)?[\w\.\-]+(\:[0-9]+)?/[\w\-]+/[\w\-\.]+\.git$")]
private static partial Regex regex1();
[GeneratedRegex(@"^[\w\-]+@[\w\.\-]+(\:[0-9]+)?:[\w\-]+/[\w\-\.]+\.git$")]
private static partial Regex regex2();
[GeneratedRegex(@"^ssh://([\w\-]+@)?[\w\.\-]+(\:[0-9]+)?/[\w\-]+/[\w\-\.]+\.git$")]
private static partial Regex regex3();
private static readonly Regex[] URL_FORMATS = [
regex1(),
regex2(),
regex3(),
];
public string Name { get; set; }
public string URL { get; set; }
public static bool IsSSH(string url)
{
if (string.IsNullOrWhiteSpace(url))
return false;
for (int i = 1; i < URL_FORMATS.Length; i++)
{
if (URL_FORMATS[i].IsMatch(url))
return true;
}
return false;
}
public static bool IsValidURL(string url)
{
foreach (var fmt in URL_FORMATS)
{
if (fmt.IsMatch(url))
return true;
}
return false;
}
}
}