summaryrefslogtreecommitdiff
path: root/src/marlin.core/functional/IGitClient.cs
diff options
context:
space:
mode:
authorMelodi <62381002+Melodi17@users.noreply.github.com>2026-09-06 09:02:31 +1000
committerMelodi <62381002+Melodi17@users.noreply.github.com>2026-09-06 09:02:31 +1000
commita9bc03fb01b5d1ac41bf5592f384d22df5425aa4 (patch)
tree16ae13e19d2a3cd7488202c30790d09557559d70 /src/marlin.core/functional/IGitClient.cs
parentc00992ffad24212c4398736efd6d707d4cb0cc0d (diff)
feat: vcs and secret management support
Diffstat (limited to 'src/marlin.core/functional/IGitClient.cs')
-rw-r--r--src/marlin.core/functional/IGitClient.cs69
1 files changed, 4 insertions, 65 deletions
diff --git a/src/marlin.core/functional/IGitClient.cs b/src/marlin.core/functional/IGitClient.cs
index 04dc12a..69cffa3 100644
--- a/src/marlin.core/functional/IGitClient.cs
+++ b/src/marlin.core/functional/IGitClient.cs
@@ -1,71 +1,10 @@
namespace marlin.core.functional;
-using System.Diagnostics;
-
public interface IGitClient
{
Task<Dictionary<string, string>> GetRemoteRefs(string remote);
-}
-
-public class GitBinaryClient : IGitClient
-{
- public virtual async Task<Dictionary<string, string>> GetRemoteRefs(string remote)
- {
- var psi = this.CreateProcess(remote);
- var proc = Process.Start(psi)!;
-
- string stdout = await proc.StandardOutput.ReadToEndAsync();
- await proc.WaitForExitAsync();
-
- return ParseOutput(stdout);
- }
-
- private Dictionary<string, string> ParseOutput(string stdout)
- {
- return stdout
- .Split("\n", StringSplitOptions.RemoveEmptyEntries)
- .Select(x => x.Split('\t'))
- .ToDictionary(k => k[1], k => k[0]);
- }
-
- protected virtual ProcessStartInfo CreateProcess(string remote)
- {
- var psi = new ProcessStartInfo("git", $"ls-remote --heads --tags {remote}")
- {
- RedirectStandardOutput = true,
- RedirectStandardError = true,
- UseShellExecute = false,
- CreateNoWindow = true,
- Environment = { ["GIT_TERMINAL_PROMPT"] = "0" }
- };
-
- return psi;
- }
-
- /*private async Task SshAuth(string privateKeyPem)
- {
- string keyPath = Path.Combine(Path.GetTempPath(), $"key_{Guid.NewGuid():N}");
- await File.WriteAllTextAsync(keyPath, privateKeyPem);
- File.SetUnixFileMode(keyPath, UnixFileMode.UserRead | UnixFileMode.UserWrite);
-
- try
- {
- psi.Environment["GIT_SSH_COMMAND"] =
- $"ssh -i {keyPath} -o IdentitiesOnly=yes -o StrictHostKeyChecking=accept-new";
- // run ls-remote against the ssh:// or git@ URL
- }
- finally
- {
- File.Delete(keyPath);
- }
- }
-
- private async Task BasicAuth(string accessToken)
- {
- psi.Environment["GIT_CONFIG_COUNT"] = "1";
- psi.Environment["GIT_CONFIG_KEY_0"] = "http.extraheader";
- psi.Environment["GIT_CONFIG_VALUE_0"] =
- $"AUTHORIZATION: basic {Convert.ToBase64String(Encoding.UTF8.GetBytes($"x-access-token:{accessToken}"))}";
-
- }*/
+ Task Init(string repoPath);
+ Task FetchTrees(string repoPath, string remote, IEnumerable<string> refs, bool skipBlobs = false);
+ Task<string[]> ListTree(string repoPath, string hash, string filterPath = ".");
+ Task<byte[]> CatFile(string repoPath, string hash, string fileName);
} \ No newline at end of file