refactor: Clone URL is now a Uri object

pull/201/head
Robert Dailey 1 year ago
parent c45860d280
commit c226097cb5

@ -4,7 +4,7 @@ namespace Recyclarr.TrashLib.Config.Settings;
public record TrashRepository
{
public string CloneUrl { get; [UsedImplicitly] init; } = "https://github.com/TRaSH-/Guides.git";
public Uri CloneUrl { get; [UsedImplicitly] init; } = new("https://github.com/TRaSH-/Guides.git");
public string Branch { get; [UsedImplicitly] init; } = "master";
public string? Sha1 { get; [UsedImplicitly] init; }
public string? GitPath { get; [UsedImplicitly] init; }

@ -81,12 +81,12 @@ public sealed class GitRepository : IGitRepository
await RunGitCmd("reset", "--hard", toBranchOrSha1);
}
public async Task SetRemote(string name, string newUrl)
public async Task SetRemote(string name, Uri newUrl)
{
await RunGitCmd("remote", "set-url", name, newUrl);
await RunGitCmd("remote", "set-url", name, newUrl.ToString());
}
public async Task Clone(string cloneUrl, string? branch = null)
public async Task Clone(Uri cloneUrl, string? branch = null)
{
var args = new List<string> {"clone"};
if (branch is not null)
@ -94,7 +94,7 @@ public sealed class GitRepository : IGitRepository
args.AddRange(new[] {"-b", branch});
}
args.AddRange(new[] {cloneUrl, _paths.RepoDirectory.FullName});
args.AddRange(new[] {cloneUrl.ToString(), _paths.RepoDirectory.FullName});
await RunGitCmd(args);
}
}

@ -15,7 +15,7 @@ public class GitRepositoryFactory : IGitRepositoryFactory
_log = log;
}
public async Task<IGitRepository> CreateAndCloneIfNeeded(string repoUrl, string repoPath, string branch)
public async Task<IGitRepository> CreateAndCloneIfNeeded(Uri repoUrl, string repoPath, string branch)
{
var repo = _repoFactory(repoPath);

@ -7,8 +7,8 @@ public interface IGitRepository : IDisposable
Task ForceCheckout(string branch);
Task Fetch(string remote = "origin");
Task ResetHard(string toBranchOrSha1);
Task SetRemote(string name, string newUrl);
Task SetRemote(string name, Uri newUrl);
IDirectoryInfo Path { get; }
Task Clone(string cloneUrl, string? branch = null);
Task Clone(Uri cloneUrl, string? branch = null);
Task Status();
}

@ -2,5 +2,5 @@ namespace Recyclarr.TrashLib.Repo.VersionControl;
public interface IGitRepositoryFactory
{
Task<IGitRepository> CreateAndCloneIfNeeded(string repoUrl, string repoPath, string branch);
Task<IGitRepository> CreateAndCloneIfNeeded(Uri repoUrl, string repoPath, string branch);
}

Loading…
Cancel
Save