RunExecutable() public method

Runs an exe, returns the output in a string. If error happens, prints stderr and returns null.
public RunExecutable ( string exeToRun, bool eatFirstLine, string commandLine ) : string
exeToRun string
eatFirstLine bool
commandLine string Command line to execute.
return string
Beispiel #1
0
        /// <summary>
        /// Gets the root directory of the repository, derived from the current directory and svn info
        /// </summary>
        /// <returns></returns>
        public string GetLocalRootDirectory()
        {
            Regex urlRegEx = new Regex(@"^(\s)*URL(\s)*:(\s)*(?<url>(\S)*)(\s)*$",
                RegexOptions.ExplicitCapture);

            ProcessReader procReader = new ProcessReader(LogOptions.None);
            string svnInfo = procReader.RunExecutable(ClientExe, false, "info");
            string url = null;

            if (svnInfo != null)
            {
                StringReader sr = new StringReader(svnInfo);
                while (url == null)
                {
                    string l = sr.ReadLine();
                    if (l == null)
                        break;

                    Match urlMatch = urlRegEx.Match(l);
                    if (urlMatch.Success)
                    {
                        url = urlMatch.Groups[1].Value;
                    }
                }
            }

            // the client is unused in Subversion, so generate our from the computer name
            return GetLocalRootDirectory(url);
        }
Beispiel #2
0
        private string RunClient(string commandLine, bool eatFirstLine)
        {
            if (SourceControl.ServerType != SourceControlType.SUBVERSION)
                return null;

            ProcessReader procReader = new ProcessReader(LogLevel);
            return procReader.RunExecutable(ClientExe, eatFirstLine, commandLine);
        }
Beispiel #3
0
        /// <summary>
        /// Gets the client settings.
        /// </summary>
        /// <returns></returns>
        public static SourceControlSettings GetSettings()
        {
            SourceControlSettings settings = new SourceControlSettings();

            settings.Port = Environment.GetEnvironmentVariable("SVNURL");

            string path = Environment.GetEnvironmentVariable("path").Replace("\"", "");
            string[] pathArray = path.Split(';');
            for (int i = 0; i < pathArray.Length; ++i)
            {
                string svn = Path.Combine(pathArray[i], "svn.exe");
                if (File.Exists(svn))
                {
                    settings.ClientExe = svn;
                    break;
                }
            }

            // get override settings from svn info output
            // Example:
            // D:\projects\Malevich\Malevich>svn info
            // Path: .
            // URL: https://malevich.svn.codeplex.com/svn/Malevich
            // Repository Root: https://malevich.svn.codeplex.com/svn
            // Repository UUID: 8ead0314-7f71-49e1-95c8-3147638646d4
            // Revision: 40756
            // Node Kind: directory
            // Schedule: normal
            // Last Changed Author: unknown
            // Last Changed Rev: 35869
            // Last Changed Date: 2010-01-10 23:37:13 -0800 (Sun, 10 Jan 2010)
            if (settings.ClientExe != null)
            {
                Regex portRegex = new Regex(@"^(\s)*Repository Root(\s)*:(\s)*(?<url>(\S)*)(\s)*$",
                    RegexOptions.ExplicitCapture);
                Regex urlRegEx = new Regex(@"^(\s)*URL(\s)*:(\s)*(?<url>(\S)*)(\s)*$",
                    RegexOptions.ExplicitCapture);

                ProcessReader procReader = new ProcessReader(LogOptions.None);
                string svnInfo = procReader.RunExecutable(settings.ClientExe, false, "info");
                string url = null;

                if (svnInfo != null)
                {
                    StringReader sr = new StringReader(svnInfo);
                    while (settings.Port == null || url == null)
                    {
                        string l = sr.ReadLine();
                        if (l == null)
                            break;

                        if (settings.Port == null)
                        {
                            Match portMatch = portRegex.Match(l);
                            if (portMatch.Success)
                            {
                                settings.Port = portMatch.Groups[1].Value;
                            }
                        }

                        Match urlMatch = urlRegEx.Match(l);
                        if (urlMatch.Success)
                        {
                            url = urlMatch.Groups[1].Value;
                        }
                    }
                }

                // the client is unused in Subversion, so generate our from the computer name
                string localRoot = GetLocalRootDirectory(url);
                if (localRoot != null)
                {
                    settings.Client = Environment.GetEnvironmentVariable("COMPUTERNAME") + "-" + localRoot;
                }
            }

            return settings;
        }