public static void Log(ICakeContext context, GitToolSettings settings = null) { var builder = new ProcessArgumentBuilder(); builder.Append("log"); var tool = new GitTool(context); tool.RunGit(settings ?? new GitToolSettings(), builder); }
public static void Tag(ICakeContext context, string tagName, GitToolSettings settings = null) { var builder = new ProcessArgumentBuilder(); builder.Append("tag"); builder.AppendQuoted(tagName); var tool = new GitTool(context); tool.RunGit(settings ?? new GitToolSettings(), builder); }
public static void Add(ICakeContext context, string file, GitToolSettings settings = null) { var builder = new ProcessArgumentBuilder(); builder.Append("add"); builder.AppendQuoted(file); var tool = new GitTool(context); tool.RunGit(settings ?? new GitToolSettings(), builder); }
public static void CheckoutDetached(ICakeContext context, string branchName, GitToolSettings settings = null) { var builder = new ProcessArgumentBuilder(); builder.Append("checkout"); builder.Append("--detach"); builder.AppendQuoted(branchName); var tool = new GitTool(context); tool.RunGit(settings ?? new GitToolSettings(), builder); }
public static bool CheckUncommitedChanges(ICakeContext context, GitToolSettings settings = null) { var builder = new ProcessArgumentBuilder(); builder.Append("diff"); builder.Append("--quiet"); builder.Append("--exit-code"); var tool = new GitTool(context); return(tool.RunGitCheck(settings ?? new GitToolSettings(), builder) == 0); }
public static void Push(ICakeContext context, string remoteName, string branchName, GitToolSettings settings = null) { var builder = new ProcessArgumentBuilder(); builder.Append("push"); builder.AppendQuoted(remoteName); builder.AppendQuoted(branchName); var tool = new GitTool(context); tool.RunGit(settings ?? new GitToolSettings(), builder); }
public static bool CheckBranchExists(ICakeContext context, string branchName, GitToolSettings settings = null) { var builder = new ProcessArgumentBuilder(); builder.Append("show-ref"); builder.Append("--quiet"); builder.Append("--heads"); builder.AppendQuoted(branchName); var tool = new GitTool(context); return(tool.RunGitCheck(settings ?? new GitToolSettings(), builder) == 0); }
public static void CommitAmend(ICakeContext context, GitToolSettings settings = null) { var builder = new ProcessArgumentBuilder(); builder.Append("commit"); builder.Append("--amend"); builder.Append("-C"); builder.Append("HEAD"); var tool = new GitTool(context); tool.RunGit(settings ?? new GitToolSettings(), builder); }
public static void MergeOurs(ICakeContext context, string branchName, GitToolSettings settings = null) { var builder = new ProcessArgumentBuilder(); builder.Append("merge"); builder.Append("-s"); builder.Append("ours"); builder.AppendQuoted(branchName); var tool = new GitTool(context); tool.RunGit(settings ?? new GitToolSettings(), builder); }
public async Task RebuildIfCommitHashChanged(Func <Task> buildStep, string stateFile) { var resultCommitHash = await stateFile.ReadAllTextAsync(); var sourceHash = (await GitTool.Run("log", "-1", "--pretty=format:%H")).Output.Trim(); if (!string.Equals(resultCommitHash, sourceHash)) { await buildStep(); await stateFile.WriteAllTextAsync(sourceHash); } }
public int DownloadUpdate(ManagerSession session, IManagerCommandLogger logger, string topic) { //Pull new code from GIT GitTool git = new GitTool(GetGitPath(session), logger); int status = git.Pull(topic, $"[{name}] Pulling updated source from Git..."); //Loop through dependencies and update them foreach (var d in dependencies) { status += session.packages[d].DownloadUpdate(session, logger, topic); } return(status); }
public ManagerPackage AddPackage(ManagerAddPackage cmd, IManagerCommandLogger logger) { //Make sure the package doesn't already exist if (packages.ContainsKey(cmd.name)) { logger.FinishFail("The package requested already exists."); return(null); } //Make sure all requested dependencies exist foreach (var d in cmd.dependencies) { if (!packages.ContainsKey(d)) { logger.FinishFail($"The requested dependency \"{d}\" does not exist."); return(null); } } //Create package ManagerPackage package = new ManagerPackage { name = cmd.name, project_path = cmd.project_path, git_repo = cmd.git_repo, exec = cmd.exec, required_user_ports = cmd.required_user_ports, dependencies = cmd.dependencies }; //Clone GIT directory logger.Log("AddPackage", "Cloning source project files..."); int status = new GitTool(package.GetGitPath(this), logger).Clone(cmd.git_repo, "AddPackage", "Cloning..."); if (status != 0) { logger.FinishFail($"Failed to clone source project files. (Code {status}) Aborting!"); return(null); } //Add packages.Add(cmd.name, package); Save(); //Finish logger.FinishSuccess($"Successfully added package {package.name}."); return(package); }
public static void Checkout(ICakeContext context, string branchName, bool force = false, GitToolSettings settings = null) { var builder = new ProcessArgumentBuilder(); builder.Append("checkout"); builder.AppendQuoted(branchName); if (force) { builder.Append("-f"); } var tool = new GitTool(context); tool.RunGit(settings ?? new GitToolSettings(), builder); }
public static void Commit(ICakeContext context, string message, bool all = false, GitToolSettings settings = null) { var builder = new ProcessArgumentBuilder(); builder.Append("commit"); if (all) { builder.Append("-a"); } builder.Append("-m"); builder.AppendQuoted(message); var tool = new GitTool(context); tool.RunGit(settings ?? new GitToolSettings(), builder); }
public static void Merge(ICakeContext context, string branchName, bool allowFF = false, GitToolSettings settings = null) { var builder = new ProcessArgumentBuilder(); builder.Append("merge"); if (!allowFF) { builder.Append("--no-ff"); } builder.AppendQuoted(branchName); var tool = new GitTool(context); tool.RunGit(settings ?? new GitToolSettings(), builder); }
public static void Reset(ICakeContext context, int type = ResetTypeDefault, string id = null, GitToolSettings settings = null) { var builder = new ProcessArgumentBuilder(); builder.Append("reset"); if (type == ResetTypeHard) { builder.Append("--hard"); } else if (type == ResetTypeSoft) { builder.Append("--soft"); } if (!string.IsNullOrEmpty(id)) { builder.AppendQuoted(id); } var tool = new GitTool(context); tool.RunGit(settings ?? new GitToolSettings(), builder); }