RunCommand() static private method

static private RunCommand ( bool sandboxed, string command, string args, StringBuilder output, StringBuilder error, int timeout ) : void
sandboxed bool
command string
args string
output StringBuilder
error StringBuilder
timeout int
return void
Ejemplo n.º 1
0
        IEnumerable <string> RunCommand(string gitDir, string cmd, StringBuilder log)
        {
            if (log != null)
            {
                log.AppendLine("> git " + cmd);
            }
            LogService.WriteLine("> git " + cmd);
            StringBuilder output = new StringBuilder();
            StringBuilder error  = new StringBuilder();

            try {
                BuildService.RunCommand(false, GitCommand, cmd, output, error, Timeout, gitDir);
            } catch (Exception ex) {
                throw new Exception(ex.Message + ": " + output.ToString() + " " + error.ToString());
            }
            if (log != null)
            {
                log.AppendLine(output.ToString());
            }
            LogService.WriteLine(output.ToString());

            List <string> lines = new List <string> ();
            StringReader  sr    = new StringReader(output.ToString());
            string        line;

            while ((line = sr.ReadLine()) != null)
            {
                lines.Add(line);
            }
            return(lines);
        }
Ejemplo n.º 2
0
        public override void Fetch(BuildContext ctx, int sourceId, SourceTagInfo stag, StringBuilder output, StringBuilder error)
        {
            string command;
            string args;
            string targetPath = GetSourceTagPath(ctx, sourceId, stag.Id);

            Util.ResetFolder(targetPath);
            command = SubversionCommand;
            args    = "export --force " + stag.Url + " \"" + targetPath + "\"";

            output.AppendLine(command + " " + args);
            BuildService.RunCommand(false, command, args, output, error, Timeout);
        }
Ejemplo n.º 3
0
        public override IEnumerable <SourceTagInfo> GetChildUrls(BuildContext ctx, SourceInfo source)
        {
            StringBuilder output = new StringBuilder();
            StringBuilder error  = new StringBuilder();
            string        url    = source.Url;

            if (!url.EndsWith("/*"))
            {
                BuildService.RunCommand(false, SubversionCommand, "info --xml " + url, output, error, Timeout);
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(output.ToString());
                XmlElement elem = (XmlElement)doc.SelectSingleNode("/info/entry");
                if (elem == null)
                {
                    elem = (XmlElement)doc.SelectSingleNode("/info");
                    if (elem != null)
                    {
                        throw new Exception(elem.InnerText);
                    }
                    else if (error.Length > 0)
                    {
                        throw new Exception(error.ToString());
                    }
                    else
                    {
                        throw new Exception("Error while getting repository information");
                    }
                }
                yield return(new SourceTagInfo()
                {
                    Url = url, Name = elem.GetAttribute("path"), LastRevision = elem.GetAttribute("revision")
                });
            }
            else
            {
                url = url.Substring(0, url.Length - 2);
                BuildService.RunCommand(false, SubversionCommand, "ls --xml " + url, output, error, Timeout);
                XmlDocument doc = new XmlDocument();
                try {
                    doc.LoadXml(output.ToString());
                }
                catch {
                    if (error.Length > 0)
                    {
                        throw new Exception(error.ToString());
                    }
                    else
                    {
                        throw new Exception("Error while getting repository information");
                    }
                }
                foreach (XmlElement elem in doc.SelectNodes("/lists/list/entry"))
                {
                    string name     = elem["name"].InnerText;
                    string revision = elem["commit"].GetAttribute("revision");
                    yield return(new SourceTagInfo()
                    {
                        Url = url + "/" + name, Name = name, LastRevision = revision
                    });
                }
            }
        }