Пример #1
0
        void ProcessCodeReviewChangedEvent(string message)
        {
            CodeReviewChangeEvent e =
                ParseEvent.Parse <CodeReviewChangeEvent>(message);

            if (!ShouldBeProcessed(
                    e.Repository,
                    e.BranchFullName,
                    mTrunkBotConfig.Repository,
                    mTrunkBotConfig.BranchPrefix))
            {
                return;
            }

            Review review = new Review(
                e.Repository, e.CodeReviewId, e.BranchId, e.CodeReviewStatus, e.CodeReviewTitle);

            if (review.IsDeleted())
            {
                ReviewsStorage.DeleteReview(review, mCodeReviewsTrackedFilePath);

                if (!mTrunkBotConfig.Plastic.IsBranchAttrFilterEnabled)
                {
                    List <Review> remainingBranchReviews = ReviewsStorage.GetBranchReviews(
                        e.Repository, e.BranchId, mCodeReviewsTrackedFilePath);

                    if (remainingBranchReviews != null && remainingBranchReviews.Count > 0)
                    {
                        return;
                    }

                    lock (mSyncLock)
                    {
                        BranchesQueueStorage.RemoveBranch(
                            e.Repository, e.BranchId, mBranchesQueueFilePath);
                    }
                }
                return;
            }

            ReviewsStorage.WriteReview(review, mCodeReviewsTrackedFilePath);

            if (mTrunkBotConfig.Plastic.IsBranchAttrFilterEnabled)
            {
                return;
            }

            lock (mSyncLock)
            {
                EnqueueBranch(
                    mBranchesQueueFilePath,
                    e.Repository,
                    e.BranchId,
                    e.BranchFullName,
                    e.BranchOwner,
                    e.BranchComment);

                Monitor.Pulse(mSyncLock);
            }
        }
Пример #2
0
        void ProcessBranchAttributeChangedEvent(string message)
        {
            BranchAttributeChangeEvent e =
                ParseEvent.Parse <BranchAttributeChangeEvent>(message);

            if (!ShouldBeProcessed(
                    e.Repository,
                    e.BranchFullName,
                    mTrunkBotConfig.Repository,
                    mTrunkBotConfig.BranchPrefix))
            {
                return;
            }

            if (!IsRelevantAttribute(
                    e.AttributeName, mTrunkBotConfig.Plastic.StatusAttribute))
            {
                return;
            }

            lock (mSyncLock)
            {
                if (!IsAttributeValueResolved(
                        e.AttributeValue, mTrunkBotConfig.Plastic.StatusAttribute))
                {
                    BranchesQueueStorage.RemoveBranch(
                        e.Repository, e.BranchId, mBranchesQueueFilePath);
                    return;
                }

                EnqueueBranch(
                    mBranchesQueueFilePath,
                    e.Repository,
                    e.BranchId,
                    e.BranchFullName,
                    e.BranchOwner,
                    e.BranchComment);

                Monitor.Pulse(mSyncLock);
            }
        }