Exemple #1
0
        private void btnPull_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(ProjectPath))
            {
                return;
            }

            string pullCmdStr = "pull";

            bool isAsnc = true;

            if (isAsnc)
            {
                var cmdStream = GitCmd.RunStream(pullCmdStr, ProjectPath);

                Task <string> line;
                while ((line = cmdStream.ReadLineAsync()) != null)
                {
                    if (line.Result == null)
                    {
                        break;
                    }
                    AppendOutLog(line.Result);
                }
                cmdStream.Close();
            }
            else
            {
                string result = GitCmd.Run(pullCmdStr, ProjectPath);
                AppendOutLog(result);
            }
        }
Exemple #2
0
        public void Show()
        {
            var args = Parse(
                maxArgs: 1,
                minArgs: 1
                );

            var line = GitCmd.Execute($"ls-files -s {args[0]}").ReadToEnd();

            if (string.IsNullOrEmpty(line))
            {
                return;
            }

            var stageHash   = "stageHash";
            var stageNumber = "stageNumber";

            //"100644 176a458f94e0ea5272ce67c36bf30b6be9caf623 0\t.gitattributes": text: auto
            var pattern = $"^\\d*\\s(?<{stageHash}>[a-z0-9]*)\\s(?<{stageNumber}>\\d+)";
            var match   = Regex.Match(line, pattern, RegexOptions.IgnoreCase);
            var hash    = GitHash.Parse(match.Get(stageHash));

            var content = GitCmd.Execute($"cat-file -p {hash}").ReadToEnd();

            Console.Write(content);
        }
Exemple #3
0
 public static void Git(string arguments) => GitCmd.Execute(arguments);
Exemple #4
0
        private static void Git(string arguments)
        {
            var message = $">git {GitCmd.Execute(arguments).ReadToEnd()}";

            Console.WriteLine(message);
        }
Exemple #5
0
 public TempGitDir()
 {
     m_tempDir = new TempDir();
     GitCmd.Execute($"init");
 }