本文整理汇总了C#中GitCommands.GitModule.RunGitCmd方法的典型用法代码示例。如果您正苦于以下问题:C# GitModule.RunGitCmd方法的具体用法?C# GitModule.RunGitCmd怎么用?C# GitModule.RunGitCmd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GitCommands.GitModule
的用法示例。
在下文中一共展示了GitModule.RunGitCmd方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
public void Execute(GitModule module)
{
if (Dto.Amend)
Dto.Result = module.RunGitCmd("commit --amend -m \"" + Dto.Message + "\"");
else
Dto.Result = module.RunGitCmd("commit -m \"" + Dto.Message + "\"");
}
示例2: UpdateCommitMessage
/// <summary>
/// Gets the commit info for submodule.
/// </summary>
public static void UpdateCommitMessage(CommitData data, GitModule module, string sha1, ref string error)
{
if (module == null)
throw new ArgumentNullException("module");
if (sha1 == null)
throw new ArgumentNullException("sha1");
//Do not cache this command, since notes can be added
string arguments = string.Format(CultureInfo.InvariantCulture,
"log -1 --pretty=\"format:" + ShortLogFormat + "\" {0}", sha1);
var info = module.RunGitCmd(arguments, GitModule.LosslessEncoding);
if (info.Trim().StartsWith("fatal"))
{
error = "Cannot find commit " + sha1;
return;
}
int index = info.IndexOf(sha1) + sha1.Length;
if (index < 0)
{
error = "Cannot find commit " + sha1;
return;
}
if (index >= info.Length)
{
error = info;
return;
}
UpdateBodyInCommitData(data, info, module);
}
示例3: GetAllBranchesWhichContainGivenCommit
/// <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="getRemote">Pass true to include remote branches</param>
/// <returns></returns>
public static IEnumerable<string> GetAllBranchesWhichContainGivenCommit(GitModule module, 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 = module.RunGitCmd("branch " + args, GitModule.SystemEncoding);
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;
}
示例4: IsBinaryAccordingToGitAttributes
/// <returns>null if no info in .gitattributes (or ambiguous). True if marked as binary, false if marked as text</returns>
private static bool? IsBinaryAccordingToGitAttributes(GitModule aModule, string fileName)
{
string[] diffvals = { "set", "astextplain", "ada", "bibtext", "cpp", "csharp", "fortran", "html", "java", "matlab", "objc", "pascal", "perl", "php", "python", "ruby", "tex" };
string cmd = "check-attr -z diff text crlf eol -- " + fileName;
string result = aModule.RunGitCmd(cmd);
var lines = result.Split(new[] { '\n', '\0' }, StringSplitOptions.RemoveEmptyEntries);
var attributes = new Dictionary<string, string>();
foreach (var line in lines)
{
var values = line.Split(':');
if (values.Length == 3)
attributes[values[1].Trim()] = values[2].Trim();
}
string val;
if (attributes.TryGetValue("diff", out val))
{
if (val == "unset")
return true;
if (diffvals.Contains(val))
return false;
}
if (attributes.TryGetValue("text", out val))
{
if (val != "unset" && val != "unspecified")
return false;
}
if (attributes.TryGetValue("crlf", out val))
{
if (val != "unset" && val != "unspecified")
return false;
}
if (attributes.TryGetValue("eol", out val))
{
if (val != "unset" && val != "unspecified")
return false;
}
return null;
}
示例5: generateListOfChangesInSubmodulesChangesToolStripMenuItem_Click
private void generateListOfChangesInSubmodulesChangesToolStripMenuItem_Click(object sender, EventArgs e)
{
var stagedFiles = Staged.AllItems;
Dictionary<string, string> modules = stagedFiles.Where(it => it.IsSubmodule).
Select(item => item.Name).ToDictionary(item => Module.GetSubmoduleNameByPath(item));
if (modules.Count == 0)
return;
StringBuilder sb = new StringBuilder();
sb.AppendLine("Submodule" + (modules.Count == 1 ? " " : "s ") +
String.Join(", ", modules.Keys) + " updated.");
sb.AppendLine();
foreach (var item in modules)
{
string diff = Module.RunGitCmd(
string.Format("diff --cached -z -- {0}", item.Value));
var lines = diff.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
const string subprojCommit = "Subproject commit ";
var from = lines.Single(s => s.StartsWith("-" + subprojCommit)).Substring(subprojCommit.Length + 1);
var to = lines.Single(s => s.StartsWith("+" + subprojCommit)).Substring(subprojCommit.Length + 1);
if (!String.IsNullOrEmpty(from) && !String.IsNullOrEmpty(to))
{
sb.AppendLine("Submodule " + item.Key + ":");
GitModule module = new GitModule(Module.WorkingDir + item.Value + Settings.PathSeparator);
string log = module.RunGitCmd(
string.Format("log --pretty=format:\" %m %h - %s\" --no-merges {0}...{1}", from, to));
if (log.Length != 0)
sb.AppendLine(log);
else
sb.AppendLine(" * Revision changed to " + to.Substring(0, 7));
sb.AppendLine();
}
}
Message.Text = sb.ToString().TrimEnd();
}
示例6: GetConfigSvnRemoteFetch
public static string GetConfigSvnRemoteFetch(GitModule aModule)
{
return aModule.RunGitCmd("config svn-remote.svn.fetch");
}
示例7: GetLostCommitLog
private static string GetLostCommitLog(GitModule aModule, string hash)
{
if (string.IsNullOrEmpty(hash) || !GitRevision.Sha1HashRegex.IsMatch(hash))
throw new ArgumentOutOfRangeException("hash", hash, "Hash must be a valid SHA1 hash.");
return aModule.RunGitCmd(string.Format(LogCommandArgumentsFormat, hash), GitModule.LosslessEncoding);
}
示例8: GetCommitData
/// <summary>
/// Gets the commit info for submodule.
/// </summary>
/// <param name="sha1">The sha1.</param>
/// <returns></returns>
public static CommitData GetCommitData(GitModule module, string sha1, ref string error)
{
if (module == null)
throw new ArgumentNullException("module");
if (sha1 == null)
throw new ArgumentNullException("sha1");
//Do not cache this command, since notes can be added
string info = module.RunGitCmd(
string.Format(
"log -1 --pretty=raw --show-notes=* {0}", sha1));
if (info.Trim().StartsWith("fatal"))
{
error = "Cannot find commit" + sha1;
return null;
}
info = RemoveRedundancies(info);
int index = info.IndexOf(sha1) + sha1.Length;
if (index < 0)
{
error = "Cannot find commit" + sha1;
return null;
}
if (index >= info.Length)
{
error = info;
return null;
}
CommitData commitInformation = CreateFromRawData(info);
return commitInformation;
}
示例9: GetAllTagsWhichContainGivenCommit
/// <summary>
/// Gets all tags which contain the given commit.
/// </summary>
/// <param name="sha1">The sha1.</param>
/// <returns></returns>
public static IEnumerable<string> GetAllTagsWhichContainGivenCommit(GitModule module, string sha1)
{
string info = module.RunGitCmd("tag --contains " + sha1, GitModule.SystemEncoding);
if (info.Trim().StartsWith("fatal") || info.Trim().StartsWith("error:"))
return new List<string>();
return info.Split(new[] { '\r', '\n', '*', ' ' }, StringSplitOptions.RemoveEmptyEntries);
}
示例10: IsBinaryAccordingToGitAttributes
/// <returns>null if no info in .gitattributes (or ambiguous). True if marked as binary, false if marked as text</returns>
private static bool? IsBinaryAccordingToGitAttributes(GitModule aModule, string fileName)
{
string cmd = "check-attr diff -z -- " + fileName;
string result = aModule.RunGitCmd(cmd);
var lines = result.Split(new[] { '\0' }, StringSplitOptions.RemoveEmptyEntries);
foreach (var line in lines)
{
var values = line.Split(':');
if (values.Length == 3 && values[1].Trim() == "diff")
{
if (values[2].Trim() == "unset")
return true;
if (values[2].Trim() == "set")
return false;
}
}
return null;
}