예제 #1
0
        bool IsEventOfValidTrackedBranch(BranchAttributeChangeEvent e, BotConfiguration botConfig)
        {
            if (!e.Repository.Equals(botConfig.Repository, StringComparison.InvariantCultureIgnoreCase))
            {
                return(false);
            }

            if (string.IsNullOrEmpty(botConfig.BranchPrefix))
            {
                return(true);
            }

            string branchName = Branch.GetShortName(e.BranchFullName);

            return(branchName.StartsWith(botConfig.BranchPrefix,
                                         StringComparison.InvariantCultureIgnoreCase));
        }
예제 #2
0
        void ProcessBranchAttributeChangedEvent(string message)
        {
            BranchAttributeChangeEvent e = EventParser.ParseBranchAttributeChangeEvent(message);

            if (!IsEventOfValidTrackedBranch(e, mBotConfig))
            {
                return;
            }

            if (!AreEqualIgnoreCase(e.AttributeName, mBotConfig.PlasticStatusAttrConfig.Name))
            {
                return;
            }

            lock (mSyncLock)
            {
                if (AreEqualIgnoreCase(e.AttributeValue, mBotConfig.PlasticStatusAttrConfig.MergedValue))
                {
                    if (!mReadyToMergeBranchesStorage.Contains(e.Repository, e.BranchId))
                    {
                        return;
                    }

                    mReadyToMergeBranchesStorage.RemoveBranch(e.Repository, e.BranchId);
                }

                if (AreEqualIgnoreCase(e.AttributeValue, mBotConfig.PlasticStatusAttrConfig.ResolvedValue))
                {
                    if (mResolvedBranchesStorage.Contains(e.Repository, e.BranchId))
                    {
                        return;
                    }

                    Branch branch = new Branch(e.Repository, e.BranchId, e.BranchFullName, e.BranchOwner, e.BranchComment);
                    mResolvedBranchesStorage.EnqueueBranch(branch);
                    return;
                }

                if (!mResolvedBranchesStorage.Contains(e.Repository, e.BranchId))
                {
                    return;
                }

                mResolvedBranchesStorage.RemoveBranch(e.Repository, e.BranchId);
            }
        }