Exemplo n.º 1
0
        protected override bool ProcessLine(string line, out GitBranch result)
        {
            base.ProcessLine(line, out result);

            if (line == null)
            {
                return(false);
            }

            var proc = new LineParser(line);

            if (proc.IsAtEnd)
            {
                return(false);
            }

            try
            {
                string name;
                string trackingName = null;

                if (proc.Matches('*'))
                {
                    proc.MoveNext();
                }
                proc.SkipWhitespace();
                if (proc.Matches("(HEAD "))
                {
                    name = "detached";
                    proc.MoveToAfter(')');
                }
                else
                {
                    name = proc.ReadUntilWhitespace();
                }

                proc.ReadUntilWhitespaceTrim();
                if (proc.Matches(trackingBranchRegex))
                {
                    trackingName = proc.ReadChunk('[', ']');
                    var indexOf = trackingName.IndexOf(':');
                    if (indexOf != -1)
                    {
                        trackingName = trackingName.Substring(0, indexOf);
                    }
                }

                result = new GitBranch(name, trackingName);
                return(true);
            }
            catch (Exception ex)
            {
                Logger.Warning(ex, "Unexpected input when listing branches");
            }

            return(false);
        }
        public override void LineReceived(string line)
        {
            if (line == null)
            {
                return;
            }

            var proc = new LineParser(line);

            if (proc.IsAtEnd)
            {
                return;
            }

            try
            {
                string name;
                string trackingName = null;

                if (proc.Matches('*'))
                {
                    proc.MoveNext();
                }
                proc.SkipWhitespace();
                if (proc.Matches("(HEAD "))
                {
                    name = "detached";
                    proc.MoveToAfter(')');
                }
                else
                {
                    name = proc.ReadUntilWhitespace();
                }

                proc.ReadUntilWhitespaceTrim();
                if (proc.Matches(trackingBranchRegex))
                {
                    trackingName = proc.ReadChunk('[', ']');
                    var indexOf = trackingName.IndexOf(':');
                    if (indexOf != -1)
                    {
                        trackingName = trackingName.Substring(0, indexOf);
                    }
                }

                var branch = new GitBranch(name, trackingName);
                RaiseOnEntry(branch);
            }
            catch (Exception ex)
            {
                Logger.Warning(ex, "Unexpected input when listing branches");
            }
        }
Exemplo n.º 3
0
        protected override bool ProcessLine(string line, out int result)
        {
            base.ProcessLine(line, out result);

            //parses 2488 objects, 4237 kilobytes
            try
            {
                var proc = new LineParser(line);

                proc.MoveToAfter(',');
                var kilobytes = int.Parse(proc.ReadUntilWhitespaceTrim());

                result = kilobytes;
                return(true);
            }
            catch {}
            return(false);
        }