Exemplo n.º 1
0
        public List<Entities.RevisionRange> Execute(Entities.Branch branch, string search, StringBuilder logMessages, List<Entities.RevisionRange> eligible)
        {
            if (logMessages == null)
            {
                logMessages = new StringBuilder();
            }

            List<Entities.RevisionRange> ranges = new List<RevisionRange>();

            Dictionary<string, string> settings = settingsBLL.Get();

            string userName = SettingsHelper.ValidateUsername(settings);
            string password = SettingsHelper.ValidatePassword(settings);

            System.Collections.ObjectModel.Collection<SharpSvn.SvnLogEventArgs> logEntries =
                new System.Collections.ObjectModel.Collection<SharpSvn.SvnLogEventArgs>();

            using (SharpSvn.SvnClient client = BusinessLogic.VersionControl.Svn.ClientHelper.Default())
            {
                client.Authentication.DefaultCredentials = new System.Net.NetworkCredential(userName, password);

                SharpSvn.SvnLogArgs args = new SharpSvn.SvnLogArgs();

                client.GetLog(new Uri(branch.Url), out logEntries);
            }

            foreach (var logEntry in logEntries)
            {
                if(logEntry.LogMessage.ToLower().Contains(search.ToLower() + " "))
                {
                    var range = new RevisionRange
                    {
                        StartRevision = (logEntry.Revision - 1).ToString(),
                        EndRevision = logEntry.Revision.ToString()
                    };

                    if(eligible.FindIndex(x => x.StartRevision == range.StartRevision && x.EndRevision == range.EndRevision) > -1)
                    {
                        logMessages.AppendLine(logEntry.LogMessage);
                        logMessages.AppendLine("................................");

                        ranges.Add(range);
                    }
                }
            }

            return ranges;
        }