public static async ValueTask SubModule(this GitPorcelainClient c, GitSubModuleArgs?options = null) { options?.Verify(); //var (_, txt) = await c.Repository.RunPorcelainCommandOut("help", new[] { "-i", a.Command! ?? a.Guide! }); await c.ThrowNotImplemented(); }
public static async ValueTask CheckOut(this GitPorcelainClient c, string branchOrCommit, string[]?targets, GitCheckOutArgs?options = null) { options ??= new(); options.Verify(); List <string> args = new(); if (options.Detach) { args.Add("--detach"); } if (!string.IsNullOrEmpty(branchOrCommit)) { args.Add(branchOrCommit); } if (targets?.Any() ?? false) { args.Add("--"); args.AddRange(targets); } else if (string.IsNullOrEmpty(branchOrCommit)) { throw new ArgumentNullException(nameof(branchOrCommit)); } await c.Repository.RunGitCommandAsync("checkout", args); }
public static async ValueTask GC(this GitPorcelainClient c, GitGCArgs?options = null) { options ??= new(); options.Verify(); List <string> args = new List <string>(); if (options.Aggressive) { args.Add("--aggressive"); } if (options.Auto) { args.Add("--auto"); } if (options.Force) { args.Add("--force"); } if (options.KeepLargestPack) { args.Add("--keep-largest-pack"); } if (options.PruneDate.HasValue) { args.Add($"--prune={options.PruneDate.Value.Date.ToString("yyyy-MM-dd")}"); } await c.Repository.RunGitCommandAsync("gc", args); Porcelain.GitPorcelain.RemoveReadOnlyIfNecessary(c.Repository); }
public static async ValueTask <Bucket> FastExport(this GitPorcelainClient c, GitFastExportArgs?options = null) { options?.Verify(); options ??= new(); var args = new List <string>(); if (options.All) { args.Add("--all"); } return(await c.Repository.RunGitCommandBucketAsync("fast-export", args)); }
public static async ValueTask Init(this GitPorcelainClient c, string path, GitInitArgs?options = null) { if (string.IsNullOrEmpty(path)) { throw new ArgumentNullException(nameof(path)); } options ??= new(); options.Verify(); List <string> args = new(); if (options.Bare) { args.Add("--bare"); } if (!string.IsNullOrEmpty(options.Branch)) { args.Add("--branch"); args.Add(options.Branch !); } if (!string.IsNullOrEmpty(options.TemplatePath)) { args.Add("--template"); args.Add(options.TemplatePath !); } if (options.IdType.HasValue) { args.Add("--object-format"); args.Add(options.IdType.Value.ToString().ToLowerInvariant()); } args.Add(path); await c.Repository.RunGitCommandAsync("init", args); }
public static ValueTask CheckOut(this GitPorcelainClient c, string branchOrCommit, GitCheckOutArgs?options = null) { return(CheckOut(c, branchOrCommit, null, options)); }