Beispiel #1
0
        public string[] GetBranches(IGetBranchesArgs args)
        {
            var ab = new ArgBuilder();

            ab.Add(args.Current ? "branch" : "branches");

            IEnumerable <string> result = RunCommand(ab, args);

            if (!args.Current)
            {
                result = result.Select(r =>
                {
                    var m = Regex.Match(r, @"^(?<name>.*?)\s+[0-9]+:[a-f0-9]+(?<inactive> \(inactive\))?");
                    return(!m.Success ? null : m.Groups["name"].Value);
                });
            }
            return(result.Where(r => !String.IsNullOrEmpty(r)).ToArray());
        }
Beispiel #2
0
        public string[] GetBranches(IGetBranchesArgs args)
        {
            if (args.Permanent)
            {
                ThrowPermanentBranchException();
            }

            var ab = new ArgBuilder();

            ab.Add("branch");
            var branches = RunCommand(ab, args)
                           .Select(line => Regex.Match(line, @"^(?<active>\*)? *(?<name>.*)$"));

            if (args.Current)
            {
                branches = branches.Where(b => b.Groups["active"].Value == "*");
            }
            return(branches.Select(b => b.Groups["name"].Value).ToArray());
        }