Ejemplo n.º 1
0
        public static List <Review> GetBranchReviews(
            string branchRepository, string branchId, string filePath)
        {
            lock (mLock)
            {
                List <Review> result        = new List <Review>();
                List <Review> storedReviews = LoadReviews(filePath);
                foreach (Review stored in storedReviews)
                {
                    if (!RepositoryNameComparer.IsSameName(stored.Repository, branchRepository))
                    {
                        continue;
                    }

                    if (!stored.BranchId.Equals(branchId, StringComparison.InvariantCulture))
                    {
                        continue;
                    }

                    result.Add(stored);
                }

                return(result);
            }
        }
Ejemplo n.º 2
0
        public static void DeleteBranchReviews(
            string branchRepository, string branchId, string filePath)
        {
            lock (mLock)
            {
                List <Review> result        = new List <Review>();
                List <Review> storedReviews = LoadReviews(filePath);

                for (int i = storedReviews.Count - 1; i >= 0; i--)
                {
                    if (!RepositoryNameComparer.IsSameName(storedReviews[i].Repository, branchRepository))
                    {
                        continue;
                    }

                    if (!storedReviews[i].BranchId.Equals(branchId, StringComparison.InvariantCulture))
                    {
                        continue;
                    }

                    storedReviews.RemoveAt(i);
                }

                WriteReviews(storedReviews, filePath);
            }
        }
Ejemplo n.º 3
0
        static bool Exists(
            string reviewRepo,
            string reviewId,
            List <Review> storedReviews,
            out Review existingReview)
        {
            existingReview = null;

            if (storedReviews == null || storedReviews.Count == 0)
            {
                return(false);
            }

            foreach (Review candidate in storedReviews)
            {
                if (!RepositoryNameComparer.IsSameName(candidate.Repository, reviewRepo))
                {
                    continue;
                }

                if (!candidate.ReviewId.Equals(reviewId, StringComparison.InvariantCulture))
                {
                    continue;
                }

                existingReview = candidate;
                return(true);
            }

            return(false);
        }
            internal static int IndexOf(
                List <Branch> branches, string repository, string branchId)
            {
                for (int i = 0; i < branches.Count; i++)
                {
                    if (!RepositoryNameComparer.IsSameName(branches[i].Repository, repository))
                    {
                        continue;
                    }

                    if (!branches[i].Id.Equals(branchId))
                    {
                        continue;
                    }

                    return(i);
                }

                return(-1);
            }
Ejemplo n.º 5
0
        static bool ShouldBeProcessed(
            string eventRepository,
            string eventBranchFullName,
            string repoTracked,
            string branchPrefixTracked)
        {
            if (!RepositoryNameComparer.IsSameName(eventRepository, repoTracked))
            {
                return(false);
            }

            if (string.IsNullOrEmpty(branchPrefixTracked))
            {
                return(true);
            }

            string branchName = BranchSpec.GetName(eventBranchFullName);

            return(branchName.StartsWith(branchPrefixTracked,
                                         StringComparison.InvariantCultureIgnoreCase));
        }