public static RunCmd ( string cmd, string arguments ) : string | ||
cmd | string | |
arguments | string | |
return | string |
/// <summary> /// Gets the commit info. /// </summary> /// <param name="sha1">The sha1.</param> /// <returns></returns> public static CommitInformation GetCommitInfo(string sha1) { //Do not cache this command, since notes can be added string info = GitCommandHelpers.RunCmd( Settings.GitCommand, string.Format( "show -s --pretty=raw --show-notes=* {0}", sha1)); if (info.Trim().StartsWith("fatal")) { return(new CommitInformation("Cannot find commit" + sha1, "")); } info = RemoveRedundancies(info); int index = info.IndexOf(sha1) + sha1.Length; if (index < 0) { return(new CommitInformation("Cannot find commit" + sha1, "")); } if (index >= info.Length) { return(new CommitInformation(info, "")); } CommitInformation commitInformation = CreateFromRawData(info); return(commitInformation); }
public IList <IGitSubmodule> GetSubmodules() { var submodules = GitCommandHelpers.RunCmd(Settings.GitCommand, "submodule status").Split('\n'); IList <IGitSubmodule> submoduleList = new List <IGitSubmodule>(); string lastLine = null; foreach (var submodule in submodules) { if (submodule.Length < 43) { continue; } if (submodule.Equals(lastLine)) { continue; } lastLine = submodule; submoduleList.Add(GitCommandHelpers.CreateGitSubmodule(submodule)); } return(submoduleList); }
/// <summary> /// Gets all tags which contain the given commit. /// </summary> /// <param name="sha1">The sha1.</param> /// <returns></returns> public static IEnumerable <string> GetAllTagsWhichContainGivenCommit(string sha1) { string info = GitCommandHelpers.RunCmd(Settings.GitCommand, "tag --contains " + sha1); if (info.Trim().StartsWith("fatal") || info.Trim().StartsWith("error:")) { return(new List <string>()); } return(info.Split(new[] { '\r', '\n', '*', ' ' }, StringSplitOptions.RemoveEmptyEntries)); }
public void Execute() { if (Dto.Amend) { Dto.Result = GitCommandHelpers.RunCmd(Settings.GitCommand, "commit --amend -m \"" + Dto.Message + "\""); } else { Dto.Result = GitCommandHelpers.RunCmd(Settings.GitCommand, "commit -m \"" + Dto.Message + "\""); } }
/// <summary> /// Gets branches which contain the given commit. /// If both local and remote branches are requested, remote branches are prefixed with "remotes/" /// (as returned by git branch -a) /// </summary> /// <param name="sha1">The sha1.</param> /// <param name="getLocal">Pass true to include local branches</param> /// <param name="getLocal">Pass true to include remote branches</param> /// <returns></returns> public static IEnumerable <string> GetAllBranchesWhichContainGivenCommit(string sha1, bool getLocal, bool getRemote) { string args = "--contains " + sha1; if (getRemote && getLocal) { args = "-a " + args; } else if (getRemote) { args = "-r " + args; } else if (!getLocal) { return new string[] {} } ; string info = GitCommandHelpers.RunCmd(Settings.GitCommand, "branch " + args); if (info.Trim().StartsWith("fatal") || info.Trim().StartsWith("error:")) { return(new List <string>()); } string[] result = info.Split(new[] { '\r', '\n', '*' }, StringSplitOptions.RemoveEmptyEntries); // Remove symlink targets as in "origin/HEAD -> origin/master" for (int i = 0; i < result.Length; i++) { string item = result[i].Trim(); int idx; if (getRemote && ((idx = item.IndexOf(" ->")) >= 0)) { item = item.Substring(0, idx); } result[i] = item; } return(result); }
public void Execute() { Dto.Result = GitCommandHelpers.RunCmd(Settings.GitCommand, "push"); }
public void Execute() { Dto.Result = GitCommandHelpers.RunCmd(Settings.GitCommand, "checkout " + Dto.Name); }
public void Execute() { Dto.Result = GitCommandHelpers.RunCmd(Settings.GitCommand, "diff -z \"" + Dto.From + "\"..\"" + Dto.To + "\" -- \"" + Dto.FileName + "\""); }
public string RunGit(string arguments) { return(GitCommandHelpers.RunCmd(Settings.GitCommand, arguments)); }