示例#1
0
            private static Version getVersion()
            {
                try
                {
                    IEnumerable <string> stdOut =
                        ExternalProcess.Start("git", "--version", true, String.Empty).StdOut;
                    if (!stdOut.Any())
                    {
                        throw new UnknownVersionException(null);
                    }

                    Match m = gitVersion_re.Match(stdOut.First());
                    if (!m.Success || m.Groups.Count < 3 ||
                        !m.Groups["major"].Success || !m.Groups["minor"].Success || !m.Groups["build"].Success ||
                        !int.TryParse(m.Groups["major"].Value, out int major) ||
                        !int.TryParse(m.Groups["minor"].Value, out int minor) ||
                        !int.TryParse(m.Groups["build"].Value, out int build))
                    {
                        throw new UnknownVersionException(null);
                    }

                    return(new Version(major, minor, build));
                }
                catch (ExternalProcessException ex)
                {
                    throw new UnknownVersionException(ex);
                }
            }
示例#2
0
        private static void setConfigKeyValueUnsafe(ConfigScope scope, string key, string value, string path)
        {
            string mode        = value == null ? "unset" : "";
            string scopeString = scope.ToString().ToLower();
            string config      = String.Format("config --{0} --{1} {2} {3}", scopeString, mode, key, value ?? "");

            ExternalProcess.Start("git", config, true, path);
        }
示例#3
0
 public static IEnumerable <string> GetRemotePointsAt(string path, string sha)
 {
     try
     {
         string arguments = String.Format("branch --format=%(refname:short) --remote --points-at \"{0}\"", sha);
         return(ExternalProcess.Start("git", arguments, true, path).StdOut);
     }
     catch (ExternalProcessException)
     {
         return(Array.Empty <string>());
     }
 }
示例#4
0
 private static string getRemoteUrl(string path)
 {
     try
     {
         IEnumerable <string> stdOut =
             ExternalProcess.Start("git", "config --get remote.origin.url", true, path).StdOut;
         return(stdOut.Any() ? stdOut.First() : null);
     }
     catch (ExternalProcessException)
     {
         return(null);
     }
 }
示例#5
0
 public static IEnumerable <string> GetConfigKeyValue(ConfigScope scope, string key, string path = "")
 {
     try
     {
         string scopeString            = scope.ToString().ToLower();
         string config                 = String.Format("config --{0} {1}", scopeString, key);
         ExternalProcess.Result result = ExternalProcess.Start("git", config, true, path);
         return(result.StdOut);
     }
     catch (ExternalProcessException)
     {
         return(Array.Empty <string>());
     }
 }
        private void cancelOperation(ExternalProcess.AsyncTaskDescriptor descriptor)
        {
            if (descriptor == null)
            {
                return;
            }

            descriptor.Cancelled = true;
            try
            {
                ExternalProcess.Cancel(descriptor.Process);
            }
            catch (InvalidOperationException)
            {
                // process already exited
            }
        }
示例#7
0
 public static void TraceGitConfiguration()
 {
     try
     {
         foreach (string arguments in
                  new string[] { "--version", "config --global --list", "config --system --list" })
         {
             IEnumerable <string> stdOut = ExternalProcess.Start("git", arguments, true, String.Empty).StdOut;
             if (stdOut.Any())
             {
                 Trace.TraceInformation(String.Format("git {0} ==>\n{1}", arguments, String.Join("\n", stdOut)));
             }
         }
     }
     catch (ExternalProcessException ex)
     {
         ExceptionHandlers.Handle("Cannot trace git configuration", ex);
     }
 }
示例#8
0
 private static string getRemoteUrl(string path)
 {
     try
     {
         IEnumerable <string> stdOut =
             ExternalProcess.Start("git", "config --get remote.origin.url", true, path).StdOut;
         return(stdOut.Any() ? stdOut.First() : null);
     }
     catch (Exception ex)
     {
         if (ex is ExternalProcessFailureException || ex is ExternalProcessSystemException)
         {
             return(null);
         }
         else
         {
             throw;
         }
     }
 }
 /// Throws ExternalProcessSystemException
 public ExternalProcess.AsyncTaskDescriptor CreateDescriptor(
     string name, string arguments, string path, Action <string> onProgressChange, int[] successCodes)
 {
     return(ExternalProcess.StartAsync(name, arguments, path, onProgressChange, _synchronizeInvoke, successCodes));
 }