コード例 #1
0
        private static void AssertOnChangeSet(string referenceExpression, int expectedRevision, List<string> references, List<string> changedFiles,
            int expectedLastRevision)
        {
            var reader = new TestableSvnReaderService();
            IEventManager eventManager = new EventManager();
            reader.Initialize(Config, eventManager, null);
            string expectedMessage = string.Format("{0} Exposed the Fronat API", string.Join(", ", references.ToArray()));
            var sourceOfExpected = new ChangeSetInfo("ExpectedAuthor", expectedMessage, new List<string>(), expectedRevision.ToString(), DateTime.Now, new List<string>());
            foreach(string reference in references) {
                sourceOfExpected.References.Add(reference);
            }
            foreach(string file in changedFiles) {
                sourceOfExpected.ChangedFiles.Add(file);
            }

            reader.LastRevisionNumber = expectedLastRevision;
            reader.TestProcessRevision(sourceOfExpected.RevisionAsInteger, sourceOfExpected.Author, sourceOfExpected.ChangeDate,
                sourceOfExpected.Message, sourceOfExpected.ChangedFiles, referenceExpression);

            ChangeSetInfo result = reader.LastChangeSet;

            Assert.AreEqual(sourceOfExpected.Author, result.Author);
            Assert.AreEqual(sourceOfExpected.ChangeDate, result.ChangeDate);
            Assert.AreEqual(sourceOfExpected.ChangedFiles.Count, result.ChangedFiles.Count, "ChangedFile cound does not match.");
            foreach(string file in sourceOfExpected.ChangedFiles) {
                Assert.IsTrue(result.ChangedFiles.Contains(file), "Result should contain changed file \"{0}\"", file);
            }

            Assert.AreEqual(sourceOfExpected.Message, result.Message);
            Assert.AreEqual(sourceOfExpected.References.Count, result.References.Count, "Reference Count does not match.");
            foreach(string reference in sourceOfExpected.References) {
                Assert.IsTrue(result.References.Contains(reference), "Result should contain reference \"{0}\".", reference);
            }

            Assert.AreEqual(sourceOfExpected.Revision, result.Revision);
            Assert.AreEqual(sourceOfExpected.Revision, reader.LastRevisionNumber.ToString());
        }
        private void ProcessChangeSetInfo(ChangeSetInfo info)
        {
            // Find related work items
            var work_items = new List<PrimaryWorkitem>();
            foreach (string refe in info.References)
            {
                var wi = _v1.Get.PrimaryWorkitemByDisplayID(refe);
                if (wi == null) {
                    // Let's see if this is a secondary work item
                    var sec_wi = _v1.Get.SecondaryWorkitemByDisplayID(refe);
                    if (sec_wi != null) {
                        wi = sec_wi.Parent;
                    } else {
                        // We can't find it, let's just get out of here
                        return;
                    }
                }
                work_items.Add(wi);
            }

            // Find or create the changeset asset
            var cs_filter = new ChangeSetFilter();
            cs_filter.Reference.Add(info.Revision);
            var change_sets = _v1.Get.ChangeSets(cs_filter);
            string cs_name = string.Format("'{0}' on '{1}' - {2}", info.Author, TimeZone.CurrentTimeZone.ToLocalTime(info.ChangeDate), info.Message);
            string cs_ref = string.Format("{0} - {1}", info.ReposName, info.Revision);
            if (change_sets.Count == 0)
            {
                change_sets = new List<ChangeSet>();
                var cs = _v1.Create.ChangeSet(info.Message, cs_ref);
                change_sets.Add(cs);
            }

            //Update changeset asset
            foreach (ChangeSet cs in change_sets)
            {
                foreach (var wi in work_items)
                {
                    cs.PrimaryWorkitems.Add(wi);
                    cs.Name = cs_name;
                    cs.Reference = cs_ref;
                }
            }

            // Find or create the links to the work item
            var link_url = string.Format(info.ReferenceUrl, info.Revision);
            var link_name = string.Format(_linkinfo.Name, info.Revision);
            var link_filter = new LinkFilter();
            link_filter.URL.Add(link_url);
            foreach (var wi in work_items)
            {
                var links = wi.GetLinks(link_filter);
                if (links.Count > 0)
                {
                    continue;
                }
                wi.CreateLink(link_name, link_url, true);
            }
        }
コード例 #3
0
 protected override void PublishChangeSet(ChangeSetInfo changeSet)
 {
     LastChangeSet = changeSet;
 }