コード例 #1
0
        public CheckinInfo GetCheckinInfo(IBuildDetail buildDetail, BuildStatus buildStatus, MyTfsBuildDefinition buildDefinition)
        {
            // Start with some semi-reasonable defaults for comment and author, but we'll try a variety of things to make them better
            var result = new CheckinInfo(buildDetail);

            var changesets = buildDetail.Information.GetNodesByType(MyBuildServer.ASSOCIATED_CHANGESET);
            var commits = buildDetail.Information.GetNodesByType(MyBuildServer.ASSOCIATED_COMMIT);

            var anyGitChangesets = changesets.Any();
            var anyTfsCommits = commits.Any();

            if (anyGitChangesets)
            {
                // This path does not not require a network call. It is used when the build is not in progress and the project uses git source control
                result = SetInfoFromAssociatedChangesets(changesets);
            }
            else if (anyTfsCommits)
            {
                // This path does not not require a network call. It is used when the build is not in progress and the project uses tfs (non-git) source control
                result = SetInfoFromAssociatedCommits(commits);
            }
            else
            {
                // this path may require a network call, however we cache requests.  It is used the first time an in-progress build is found
                var latestChangeset = QueryServerForLatestChangesetButCache(buildDefinition, buildStatus);
                if (latestChangeset != null)
                {
                    result.Committer = latestChangeset.Committer;
                    result.Comment = latestChangeset.Comment;
                }
            }

            return result;
        }
コード例 #2
0
        public CheckinInfo GetCheckinInfo(IBuildDetail buildDetail, BuildStatus buildStatus, MyTfsBuildDefinition buildDefinition)
        {
            // Start with some semi-reasonable defaults for comment and author, but we'll try a variety of things to make them better
            var result = new CheckinInfo(buildDetail);

            var changesets = buildDetail.Information.GetNodesByType(MyBuildServer.ASSOCIATED_CHANGESET);
            var commits    = buildDetail.Information.GetNodesByType(MyBuildServer.ASSOCIATED_COMMIT);

            var anyGitChangesets = changesets.Any();
            var anyTfsCommits    = commits.Any();

            if (anyGitChangesets)
            {
                // This path does not not require a network call. It is used when the build is not in progress and the project uses git source control
                result = SetInfoFromAssociatedChangesets(changesets);
            }
            else if (anyTfsCommits)
            {
                // This path does not not require a network call. It is used when the build is not in progress and the project uses tfs (non-git) source control
                result = SetInfoFromAssociatedCommits(commits);
            }
            else
            {
                // this path may require a network call, however we cache requests.  It is used the first time an in-progress build is found
                var latestChangeset = QueryServerForLatestChangesetButCache(buildDefinition, buildStatus);
                if (latestChangeset != null)
                {
                    result.Committer = latestChangeset.Committer;
                    result.Comment   = latestChangeset.Comment;
                }
            }

            return(result);
        }
コード例 #3
0
 private static CheckinInfo QueryServerForLatestChangesetButCache(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)
     {
         CheckinInfo latestChangeset = buildDefinition.GetLatestChangeset();
         _cachedCommentsByBuildDefinition[buildDefinition.Name] = new CommentAndHash(newBuildHash, latestChangeset);
     }
     return _cachedCommentsByBuildDefinition[buildDefinition.Name].Changeset;
 }
コード例 #4
0
        private static CheckinInfo QueryServerForLatestChangesetButCache(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)
            {
                CheckinInfo latestChangeset = buildDefinition.GetLatestChangeset();
                _cachedCommentsByBuildDefinition[buildDefinition.Name] = new CommentAndHash(newBuildHash, latestChangeset);
            }
            return(_cachedCommentsByBuildDefinition[buildDefinition.Name].Changeset);
        }