当前位置: 首页>>代码示例>>C#>>正文


C# GitModule.RunGitCmd方法代码示例

本文整理汇总了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 + "\"");
 }
开发者ID:Carbenium,项目名称:gitextensions,代码行数:7,代码来源:CommitHelper.cs

示例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);
        }
开发者ID:Carbenium,项目名称:gitextensions,代码行数:36,代码来源:CommitData.cs

示例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;
        }
开发者ID:semi836,项目名称:gitextensions,代码行数:38,代码来源:CommitInformation.cs

示例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;
        }
开发者ID:Carbenium,项目名称:gitextensions,代码行数:40,代码来源:FileHelper.cs

示例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();
        }
开发者ID:pcworld,项目名称:gitextensions,代码行数:35,代码来源:FormCommit.cs

示例6: GetConfigSvnRemoteFetch

 public static string GetConfigSvnRemoteFetch(GitModule aModule)
 {
     return aModule.RunGitCmd("config svn-remote.svn.fetch");
 }
开发者ID:PaulGardens,项目名称:gitextensions,代码行数:4,代码来源:GitSvnCommandHelpers.cs

示例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);
            }
开发者ID:Carbenium,项目名称:gitextensions,代码行数:7,代码来源:FormVerify.LostObject.cs

示例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;
        }
开发者ID:vasily-kirichenko,项目名称:gitextensions,代码行数:42,代码来源:CommitData.cs

示例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);
        }
开发者ID:semi836,项目名称:gitextensions,代码行数:13,代码来源:CommitInformation.cs

示例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;
 }
开发者ID:kunigaku,项目名称:gitextensions,代码行数:19,代码来源:FileHelper.cs


注:本文中的GitCommands.GitModule.RunGitCmd方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。