Exemplo n.º 1
0
 public void Merge_RemovedBuildStatus_Retained()
 {
     var oldStatus = new[] {new BuildStatus {BuildDefinitionId = "1", BuildStatusEnum = BuildStatusEnum.Working}};
     var newStatuses = new BuildStatus[] {};
     var result = BuildStatusUtil.Merge(oldStatus, newStatuses);
     Assert.AreEqual(1, result.Count());
 }
Exemplo n.º 2
0
 private static BuildStatus AddCommentsToBuildStatus(BuildStatus buildStatus, MyChangeset changeset)
 {
     if (changeset == null) return null;
     buildStatus.Comment = changeset.Comment;
     buildStatus.BuildId = changeset.ChangesetId.ToString(CultureInfo.InvariantCulture);
     return buildStatus;
 }
Exemplo n.º 3
0
 public void Write(BuildStatus buildStatus, SirenOfShameSettings settings, bool disableWritingToSosDb)
 {
     if (!disableWritingToSosDb)
     {
         AppendToFile(buildStatus);
     }
     UpdateStatsInSettings(buildStatus, settings);
 }
Exemplo n.º 4
0
        public IEnumerable<AchievementLookup> CalculateNewAchievements(SirenOfShameSettings settings, BuildStatus build)
        {
            List<BuildStatus> allActiveBuildDefinitionsOrderedChronoligically = _sosDb
                .ReadAll(settings.GetAllActiveBuildDefinitions())
                .OrderBy(i => i.StartedTime)
                .ToList();

            return CalculateNewAchievements(settings, build, allActiveBuildDefinitionsOrderedChronoligically);
        }
Exemplo n.º 5
0
 public void Merge_NewBuildStatus_Added()
 {
     var oldStatus = new BuildStatus[] {};
     var newStatuses = new[] {new BuildStatus {BuildDefinitionId = "1", BuildStatusEnum = BuildStatusEnum.Working}};
     var result = BuildStatusUtil.Merge(oldStatus, newStatuses);
     Assert.AreEqual(1, result.Count());
     Assert.AreEqual("1", result[0].BuildDefinitionId);
     Assert.AreEqual(BuildStatusEnum.Working, result[0].BuildStatusEnum);
 }
Exemplo n.º 6
0
 private static BuildStatus AddCommentsToBuildStatus(BuildStatus buildStatus, MyChangeset changeset)
 {
     if (changeset == null)
     {
         return(null);
     }
     buildStatus.Comment = changeset.Comment;
     buildStatus.BuildId = changeset.ChangesetId.ToString(CultureInfo.InvariantCulture);
     return(buildStatus);
 }
Exemplo n.º 7
0
 private static void UpdateStatsInSettings(BuildStatus buildStatus, SirenOfShameSettings settings)
 {
     if (string.IsNullOrEmpty(buildStatus.RequestedBy)) return;
     var personSetting = settings.FindAddPerson(buildStatus.RequestedBy);
     if (buildStatus.BuildStatusEnum == BuildStatusEnum.Broken)
     {
         personSetting.FailedBuilds++;
     }
     personSetting.TotalBuilds++;
     settings.Save();
 }
Exemplo n.º 8
0
 private void AppendToFile(BuildStatus buildStatus)
 {
     string[] items = new[]
     {
         buildStatus.StartedTime == null ? "" : buildStatus.StartedTime.Value.Ticks.ToString(CultureInfo.InvariantCulture),
         buildStatus.FinishedTime == null ? "" : buildStatus.FinishedTime.Value.Ticks.ToString(CultureInfo.InvariantCulture),
         ((int) buildStatus.BuildStatusEnum).ToString(CultureInfo.InvariantCulture),
         buildStatus.RequestedBy
     };
     string contents = string.Join(",", items) + "\r\n";
     string location = GetBuildLocation(buildStatus);
     Write(location, contents);
 }
Exemplo n.º 9
0
 public void AsBuildStatusListViewItem_InProgressNoPreviousDuration_DurationCountsUp()
 {
     BuildStatus buildStatus = new BuildStatus
     {
         BuildDefinitionId = "MyBuild",
         LocalStartTime = new DateTime(2010, 1, 1, 1, 1, 1),
         BuildStatusEnum = BuildStatusEnum.InProgress
     };
     var now = new DateTime(2010, 1, 1, 1, 2, 2);
     var previousWorkingOrBrokenBuildStatus = new Dictionary<string, BuildStatus>();
     var settings = new SirenOfShameSettingsFake();
     var result = buildStatus.AsBuildStatusDto(now, previousWorkingOrBrokenBuildStatus, settings);
     Assert.AreEqual("1:01", result.Duration);
 }
Exemplo n.º 10
0
 private MyChangeset GetCommentsForBuild(MyTfsBuildDefinition buildDefinition, BuildStatus buildStatus)
 {
     var newBuildHash = buildStatus.GetBuildDataAsHash();
     CommentAndHash cachedChangeset;
     bool haveEverGottenCommentsForThisBuildDef = CachedCommentsByBuildDefinition.TryGetValue(buildDefinition.Name, out cachedChangeset);
     bool areCacheCommentsStale = false;
     if (haveEverGottenCommentsForThisBuildDef)
     {
         string oldBuildHash = cachedChangeset.BuildStatusHash;
         areCacheCommentsStale = oldBuildHash != newBuildHash;
     }
     if (!haveEverGottenCommentsForThisBuildDef || areCacheCommentsStale)
     {
         MyChangeset latestChangeset = buildDefinition.GetLatestChangeset();
         CachedCommentsByBuildDefinition[buildDefinition.Name] = new CommentAndHash(newBuildHash, latestChangeset);
     }
     return CachedCommentsByBuildDefinition[buildDefinition.Name].Changeset;
 }
Exemplo n.º 11
0
 public BuildStatus GetBuildStatus()
 {
     BuildStatus buildStatus = null;
     this.Invoke(() =>
         {
             buildStatus = new BuildStatus
             {
                 Name = ProjectName,
                 BuildDefinitionId = ProjectId,
                 BuildStatusEnum = _buildStatus,
                 Comment = _comment.Text,
                 FinishedTime = _finishedTime,
                 StartedTime = _startedTime,
                 RequestedBy = _requestedBy.Text,
                 BuildId = _startedTime.HasValue ? _startedTime.Value.Ticks.ToString(CultureInfo.InvariantCulture) : null,
                 Url = "http://www.google.com"
             };
         });
     return buildStatus;
 }
Exemplo n.º 12
0
 public void AsBuildStatusListViewItem_InProgressPreviousRunOneMinuteBuildJustStarted_DurationCountsDown()
 {
     BuildStatus buildStatus = new BuildStatus
     {
         BuildDefinitionId = "MyBuild",
         LocalStartTime = new DateTime(2010, 1, 1, 1, 1, 1),
         BuildStatusEnum = BuildStatusEnum.InProgress
     };
     var now = new DateTime(2010, 1, 1, 1, 1, 1);
     var previousWorkingOrBrokenBuildStatus = new Dictionary<string, BuildStatus>
     {
         { "MyBuild", new BuildStatus
         {
             StartedTime = new DateTime(2010, 1, 1, 1, 1, 0),
             FinishedTime = new DateTime(2010, 1, 1, 1, 2, 0)
         } }
     };
     var settings = new SirenOfShameSettingsFake();
     var result = buildStatus.AsBuildStatusDto(now, previousWorkingOrBrokenBuildStatus, settings);
     Assert.AreEqual("1:00", result.Duration); // would have been 0:00 if counting up
 }
Exemplo n.º 13
0
        private BuildStatus CreateBuildStatus(IBuildDetail buildDetail, IEnumerable <MyTfsBuildDefinition> allBuildDefinitions, bool applyBuildQuality)
        {
            BuildStatusEnum buildStatus  = GetBuildStatusEnum(buildDetail.Status);
            var             buildQuality = GetBuildStatusEnum(buildDetail.Quality);

            if (applyBuildQuality && buildStatus == BuildStatusEnum.Working)
            {
                buildStatus = buildQuality;
            }

            var result = new BuildStatus
            {
                BuildStatusEnum = buildStatus,
                StartedTime     = buildDetail.StartTime == DateTime.MinValue ? (DateTime?)null : buildDetail.StartTime,
                FinishedTime    = buildDetail.FinishTime == DateTime.MinValue ? (DateTime?)null : buildDetail.FinishTime,
            };

            var matchedBuildDefinition = allBuildDefinitions.FirstOrDefault(i => i.Uri == buildDetail.BuildDefinitionUri);

            if (matchedBuildDefinition != null)
            {
                result.Name = matchedBuildDefinition.Name;
                result.BuildDefinitionId = matchedBuildDefinition.Id;
            }
            else
            {
                _log.Error("The server appeared to return a build definition that we are not watching: " + buildDetail.BuildDefinitionUri);
            }

            result.BuildId = buildDetail.Uri.Segments.LastOrDefault();

            SetCheckinInfo(buildDetail, applyBuildQuality, result, buildQuality, matchedBuildDefinition);

            result.Url = _tfsProject.ConvertTfsUriToUrl(buildDetail.Uri);

            return(result);
        }
Exemplo n.º 14
0
        public void AsBuildStatusListViewItem_InProgressBuildRunningOverPreviousRunDuration_DurationCountsUpOvertime()
        {
            // current duration: 2 minute, 1 second
            BuildStatus buildStatus = new BuildStatus
            {
                BuildDefinitionId = "MyBuild",
                LocalStartTime = new DateTime(2010, 1, 1, 1, 1, 1),
                BuildStatusEnum = BuildStatusEnum.InProgress
            };
            var now = new DateTime(2010, 1, 1, 1, 3, 2);

            // previous duration 1 minute
            var previousWorkingOrBrokenBuildStatus = new Dictionary<string, BuildStatus>
            {
                { "MyBuild", new BuildStatus
                {
                    StartedTime = new DateTime(2010, 1, 1, 1, 1, 0),
                    FinishedTime = new DateTime(2010, 1, 1, 1, 2, 0)
                } }
            };
            var settings = new SirenOfShameSettingsFake();
            var result = buildStatus.AsBuildStatusDto(now, previousWorkingOrBrokenBuildStatus, settings);
            Assert.AreEqual("OT: 1:01", result.Duration);
        }
Exemplo n.º 15
0
 public bool IsBackToBackWithNextBuild(BuildStatus nextBuild, int seconds)
 {
     if (nextBuild.StartedTime == null || FinishedTime == null) return false;
     double secondsBetweenBuilds = (nextBuild.StartedTime.Value - FinishedTime.Value).TotalSeconds;
     return secondsBetweenBuilds > 0 && secondsBetweenBuilds < seconds;
 }
Exemplo n.º 16
0
 private static void SetValue(BuildStatus changedBuildStatus, IDictionary<string, BuildStatus> dictionary)
 {
     if (!dictionary.ContainsKey(changedBuildStatus.BuildDefinitionId))
         dictionary.Add(changedBuildStatus.BuildDefinitionId, changedBuildStatus);
     else
         dictionary[changedBuildStatus.BuildDefinitionId] = changedBuildStatus;
 }
Exemplo n.º 17
0
        private IEnumerable<AchievementEnum> CalculateNewAchievementEnums(SirenOfShameSettings settings, BuildStatus build, List<BuildStatus> allActiveBuildDefinitionsOrderedChronoligically)
        {
            int reputation = GetReputation();

            List<BuildStatus> currentBuildDefinitionOrderedChronoligically = allActiveBuildDefinitionsOrderedChronoligically
                .Where(i => i.BuildDefinitionId == build.BuildDefinitionId)
                .ToList();

            if (build.FinishedTime != null && build.StartedTime != null)
            {
                TimeSpan? buildDuration = build.FinishedTime.Value - build.StartedTime.Value;
                MyCumulativeBuildTime = MyCumulativeBuildTime == null ? buildDuration : MyCumulativeBuildTime + buildDuration;
            }

            CalculateStats(allActiveBuildDefinitionsOrderedChronoligically);

            List<AchievementBase> possibleAchievements = new List<AchievementBase>
            {
                new Apprentice(this, reputation),
                new Neophyte(this, reputation),
                new Master(this, reputation),
                new GrandMaster(this, reputation),
                new Legend(this, reputation),
                new JonSkeet(this, reputation),
                new TimeWarrior(this),
                new ChronMaster(this),
                new ChronGrandMaster(this),
                new CiNinja(this),
                new Assassin(this),
                new LikeLightning(this, currentBuildDefinitionOrderedChronoligically),
                new ReputationRebound(this, allActiveBuildDefinitionsOrderedChronoligically),
                new ArribaArribaAndaleAndale(this),
                new SpeedDaemon(this),
                new InTheZone(this),
                new Terminator(this),
                new AndGotAwayWithIt(this, currentBuildDefinitionOrderedChronoligically),
                new Critical(this),
                new Perfectionist(this),
                new Macgyver(this, currentBuildDefinitionOrderedChronoligically),
                new Napoleon(this, settings.People),
                new ShamePusher(this, settings)
            };

            return possibleAchievements
                .Where(i => i.HasJustAchieved())
                .Select(i => i.AchievementEnum);
        }
Exemplo n.º 18
0
 private void ResetPreviousWorkingOrBrokenStatuses()
 {
     PreviousWorkingOrBrokenBuildStatus = new Dictionary<string, BuildStatus>();
     PreviousBuildStatus = new Dictionary<string, BuildStatus>();
     _previousBuildStatuses = new BuildStatus[] { };
 }
Exemplo n.º 19
0
 public void InvokeStatusChecked(BuildStatus args)
 {
     ((WatcherFake)CiEntryPointSetting.GetWatcher(Settings)).InvokeStatusChecked(new[] { args });
 }
Exemplo n.º 20
0
 public IEnumerable<AchievementLookup> CalculateNewAchievements(SirenOfShameSettings settings, BuildStatus build, List<BuildStatus> allActiveBuildDefinitionsOrderedChronoligically)
 {
     return from achievementEnum in CalculateNewAchievementEnums(settings, build, allActiveBuildDefinitionsOrderedChronoligically)
            join achievement in AchievementSetting.AchievementLookups on achievementEnum equals achievement.Id
            select achievement;
 }
Exemplo n.º 21
0
 public void Write(BuildStatus buildStatus, SirenOfShameSettings settings)
 {
     AppendToFile(buildStatus);
     UpdateStatsInSettings(buildStatus, settings);
 }
Exemplo n.º 22
0
 public void Write_Writes()
 {
     string expectedFileLocation = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Automated Architecture", "SirenOfShame", "BuildDefinitionId.txt");
     File.Delete(expectedFileLocation);
     var sosDb = new SosDb();
     BuildStatus buildStatus = new BuildStatus
     {
         BuildDefinitionId = "BuildDefinitionId",
         BuildStatusEnum = BuildStatusEnum.Working,
         Comment = "hi",
         FinishedTime = new DateTime(2010, 1, 1, 1, 1, 1),
         StartedTime = new DateTime(2010, 1, 1, 1, 1, 2),
         LocalStartTime = new DateTime(2010, 1, 1, 1, 1, 3),
         RequestedBy = "Lee",
         Name = "BuildName",
     };
     SirenOfShameSettingsFake fakeSettings = new SirenOfShameSettingsFake();
     sosDb.Write(buildStatus, fakeSettings);
     Assert.IsTrue(File.Exists(expectedFileLocation));
     string[] linesOutput = File.ReadAllLines(expectedFileLocation);
     Assert.AreEqual(1, linesOutput.Length);
     Assert.AreEqual("633979044620000000,633979044610000000,1,Lee", linesOutput[0]);
     File.Delete(expectedFileLocation);
 }
Exemplo n.º 23
0
        private static void SetCheckinInfo(IBuildDetail buildDetail, bool applyBuildQuality, BuildStatus result, BuildStatusEnum buildQuality, MyTfsBuildDefinition buildDefinition)
        {
            var checkinInfoGetterService = new CheckinInfoGetterService();
            var checkinInfo = checkinInfoGetterService.GetCheckinInfo(buildDetail, result, buildDefinition);

            if (checkinInfo != null)
            {
                result.Comment     = checkinInfo.Comment;
                result.RequestedBy = checkinInfo.Committer;
            }

            if (applyBuildQuality && buildQuality == BuildStatusEnum.Broken)
            {
                result.Comment = "Build deployment or test failure. Please see test server or test results for details.\n" + result.Comment;
            }
        }
Exemplo n.º 24
0
 private string GetBuildLocation(BuildStatus buildStatus)
 {
     return GetBuildLocation(buildStatus.BuildDefinitionId);
 }
Exemplo n.º 25
0
        // e.g. if a build exists in newStatus but doesn't exit in oldStatus, return it.  If a build exists in
        //  oldStatus and in newStatus and the BuildStatusEnum is different then return it.
        private IList<BuildStatus> GetChangedBuildStatuses(BuildStatus[] allBuildStatuses)
        {
            var oldBuildStatus = _previousBuildStatuses;
            _previousBuildStatuses = allBuildStatuses;
            var changedBuildStatuses = from newStatus in allBuildStatuses
                                       from oldStatus in oldBuildStatus.Where(s => s.BuildDefinitionId == newStatus.BuildDefinitionId).DefaultIfEmpty()
                                       where DidBuildStatusChange(oldStatus, newStatus)
                                       select newStatus;

            Debug.Assert(changedBuildStatuses != null, "changedBuildStatuses should not be null");
            Debug.Assert(PreviousWorkingOrBrokenBuildStatus != null, "PreviousWorkingOrBrokenBuildStatus should never be null");
            Debug.Assert(PreviousBuildStatus != null, "PreviousBuildStatus should never be null");

            return changedBuildStatuses.ToList();
        }
Exemplo n.º 26
0
 private static void SetValue(BuildStatus changedBuildStatus, IDictionary<string, BuildStatus> dictionary)
 {
     try
     {
         if (!dictionary.ContainsKey(changedBuildStatus.BuildDefinitionId))
             dictionary.Add(changedBuildStatus.BuildDefinitionId, changedBuildStatus);
         else
             dictionary[changedBuildStatus.BuildDefinitionId] = changedBuildStatus;
     }
     catch (IndexOutOfRangeException)
     {
         _log.Error("Tried to update the cache from the thread '" + Thread.CurrentThread.Name + "' but failed because the cache was previously accessed from a different thread. This could cause errors in determining whether a build changed.");
     }
 }
Exemplo n.º 27
0
 public bool IsBackToBackWithNextBuild(BuildStatus nextBuild)
 {
     const int defaultSecondsForBackToBack = 10;
     return IsBackToBackWithNextBuild(nextBuild, defaultSecondsForBackToBack);
 }
Exemplo n.º 28
0
        private static bool DidBuildStatusChange(BuildStatus oldStatus, BuildStatus newStatus)
        {
            if (oldStatus == null) return true;

            bool startTimesUnequal = oldStatus.StartedTime != newStatus.StartedTime;
            bool buildStatusesUnequal = oldStatus.BuildStatusEnum != newStatus.BuildStatusEnum;
               bool buildChanged =
                startTimesUnequal || buildStatusesUnequal;

            if (buildChanged)
            {
                string message = string.Format(
                    "Detected a build status change. BuildDefinitionId: {0}; OldStartTime: {1}; NewStartTime: {2}; OldStatus: {3}; NewStatus: {4}; BuildId: {5}; RequestedBy: {6}",
                    newStatus.BuildDefinitionId,
                    oldStatus.StartedTime,
                    newStatus.StartedTime,
                    oldStatus.BuildStatusEnum,
                    newStatus.BuildStatusEnum,
                    newStatus.BuildId,
                    newStatus.RequestedBy
                    );
                _log.Debug(message);
            }

            return buildChanged;
        }
Exemplo n.º 29
0
        private TimeSpan? GetDuration(DateTime? startedTime, DateTime? finishedTime, BuildStatus previousStatus, DateTime now)
        {
            if (BuildStatusEnum != BuildStatusEnum.InProgress)
            {
                if (startedTime == null || finishedTime == null)
                {
                    _log.Warn("Start time or stop time was null for " + BuildDefinitionId + ", and the build was not in progress, this should only happen at startup");
                    return null;
                }
                return finishedTime.Value - startedTime.Value;
            }

            if (previousStatus == null || previousStatus.StartedTime == null || previousStatus.FinishedTime == null)
            {
                // count up
                return now - LocalStartTime;
            }

            // count down
            var previousDuration = previousStatus.FinishedTime.Value - previousStatus.StartedTime.Value;
            var currentDuration = now - LocalStartTime;
            return previousDuration - currentDuration;
        }
Exemplo n.º 30
0
        private static BuildStatusEnum? TryGetBuildStatus(BuildStatus changedBuildStatus, IDictionary<string, BuildStatus> dictionary)
        {
            BuildStatus previousWorkingOrBrokenBuildStatus;
            dictionary.TryGetValue(changedBuildStatus.BuildDefinitionId, out previousWorkingOrBrokenBuildStatus);

            return previousWorkingOrBrokenBuildStatus == null ? (BuildStatusEnum?)null : previousWorkingOrBrokenBuildStatus.BuildStatusEnum;
        }
Exemplo n.º 31
0
 private string GetDurationAsString(DateTime? finishedTime, DateTime? startedTime, DateTime now, BuildStatus previousStatus)
 {
     TimeSpan? duration = GetDuration(startedTime, finishedTime, previousStatus, now);
     if (duration == null) return "";
     if (duration.Value.Ticks < 0) return string.Format("OT: {0}:{1:00}", 0 - (int)duration.Value.TotalMinutes, 0 - duration.Value.Seconds);
     return string.Format("{0}:{1:00}", (int)duration.Value.TotalMinutes, duration.Value.Seconds);
 }
Exemplo n.º 32
0
        private BuildStatus CreateBuildStatus(IBuildDetail buildDetail, bool applyBuildQuality)
        {
            BuildStatusEnum status = BuildStatusEnum.Unknown;

            status = GetBuildStatusEnum(buildDetail.Status);
            if (applyBuildQuality && status == BuildStatusEnum.Working)
            {
                status = GetBuildStatusEnum(buildDetail.Quality);
            }

            var result = new BuildStatus
            {
                BuildDefinitionId = buildDetail.BuildDefinitionUri.Segments[buildDetail.BuildDefinitionUri.Segments.Length - 1].ToString(),
                BuildStatusEnum   = status,
                RequestedBy       = buildDetail.RequestedBy != null ? buildDetail.RequestedBy :
                                    buildDetail.RequestedFor != null ? buildDetail.RequestedFor : buildDetail.LastChangedBy,
                StartedTime  = buildDetail.StartTime == DateTime.MinValue ? (DateTime?)null : buildDetail.StartTime,
                FinishedTime = buildDetail.FinishTime == DateTime.MinValue ? (DateTime?)null : buildDetail.FinishTime,
            };

            if (buildDetail.BuildDefinition != null)
            {
                this._UriToName[buildDetail.BuildDefinitionUri.ToString()] = buildDetail.BuildDefinition.Name;
            }

            result.Name    = this._UriToName[buildDetail.BuildDefinitionUri.ToString()];
            result.BuildId = buildDetail.Uri.Segments[buildDetail.Uri.Segments.Length - 1].ToString();

            var changesets = buildDetail.Information.GetNodesByType("AssociatedChangeset");

            if (changesets.Count() > 0)
            {
                HashSet <String> users = new HashSet <String>();
                foreach (var changeset in changesets)
                {
                    users.Add(changeset.Fields["CheckedInBy"]);
                }

                if (users.Count() > 1)
                {
                    result.RequestedBy = "(Multiple Users)";
                }
                else
                {
                    result.RequestedBy = users.First();
                }

                if (changesets.Count() > 1)
                {
                    result.Comment = "(Multiple Changesets)";
                }
                else
                {
                    result.Comment = changesets.First().Fields["Comment"];
                }
            }
            else
            {
                result.Comment = buildDetail.Reason.ToString();
            }

            if (applyBuildQuality &&
                GetBuildStatusEnum(buildDetail.Quality) == BuildStatusEnum.Broken)
            {
                result.Comment =
                    "Build deployment or test failure. Please see test server or test results for details.\n" +
                    result.Comment;
            }

            result.Url = _tfsProject.ConvertTfsUriToUrl(buildDetail.Uri);

            return(result);
        }
Exemplo n.º 33
0
 public void UpdateNameIfChanged(BuildStatus changedBuildStatus)
 {
     var changedName = CiEntryPointSettings
         .SelectMany(i => i.BuildDefinitionSettings)
         .FirstOrDefault(i => i.Id == changedBuildStatus.BuildDefinitionId && i.Name != changedBuildStatus.Name);
     if (changedName == null) return;
     changedName.Name = changedBuildStatus.Name;
     Save();
 }
Exemplo n.º 34
0
        public BuildStatus GetCommentsIntoBuildStatus(MyTfsBuildDefinition buildDefinition, BuildStatus buildStatus)
        {
            MyChangeset changeset = GetCommentsForBuild(buildDefinition, buildStatus);

            return(AddCommentsToBuildStatus(buildStatus, changeset));
        }
Exemplo n.º 35
0
 public void Write_InvalidCharacters_Removed()
 {
     const string uglyBuildDefinition = "\"M\"\\(a)/ry/ h**ad:>> a\\/:*?\"| li*tt|le|| la\"mb.?";
     string expectedFileLocation = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Automated Architecture", "SirenOfShame", "M(a)ry had a little lamb.txt");
     File.Delete(expectedFileLocation);
     var sosDb = new SosDb();
     BuildStatus buildStatus = new BuildStatus
     {
         BuildDefinitionId = uglyBuildDefinition,
         BuildStatusEnum = BuildStatusEnum.Working,
         Name = "BuildName",
     };
     SirenOfShameSettingsFake fakeSettings = new SirenOfShameSettingsFake();
     sosDb.Write(buildStatus, fakeSettings);
     Assert.IsTrue(File.Exists(expectedFileLocation));
     File.Delete(expectedFileLocation);
 }
Exemplo n.º 36
0
        private MyChangeset GetCommentsForBuild(MyTfsBuildDefinition buildDefinition, BuildStatus buildStatus)
        {
            var            newBuildHash = buildStatus.GetBuildDataAsHash();
            CommentAndHash cachedChangeset;
            bool           haveEverGottenCommentsForThisBuildDef = CachedCommentsByBuildDefinition.TryGetValue(buildDefinition.Name, out cachedChangeset);
            bool           areCacheCommentsStale = false;

            if (haveEverGottenCommentsForThisBuildDef)
            {
                string oldBuildHash = cachedChangeset.BuildStatusHash;
                areCacheCommentsStale = oldBuildHash != newBuildHash;
            }
            if (!haveEverGottenCommentsForThisBuildDef || areCacheCommentsStale)
            {
                MyChangeset latestChangeset = buildDefinition.GetLatestChangeset();
                CachedCommentsByBuildDefinition[buildDefinition.Name] = new CommentAndHash(newBuildHash, latestChangeset);
            }
            return(CachedCommentsByBuildDefinition[buildDefinition.Name].Changeset);
        }
Exemplo n.º 37
0
 private void ResetPreviousWorkingOrBrokenStatuses()
 {
     PreviousWorkingOrBrokenBuildStatus = new Dictionary <string, BuildStatus>();
     PreviousBuildStatus    = new Dictionary <string, BuildStatus>();
     _previousBuildStatuses = new BuildStatus[] { };
 }