Ejemplo n.º 1
0
        public async Task <RequestCollection> FindPullRequests(string location, bool useCache, IEnumerable <CommitInfo> commits)
        {
            var allIssues = await IssueCache.GetIssues(this.Client, location, useCache);

            var requests = new RequestCollection(allIssues);

            foreach (var commit in commits)
            {
                string prMatch = TryExpression(SquashExpression, commit);

                if (prMatch == null)
                {
                    prMatch = TryExpression(MergeExpression, commit);
                }

                if (prMatch != null && Int32.TryParse(prMatch, out int id))
                {
                    var matchPR = allIssues.FirstOrDefault(x => x.Number == id);

                    if (matchPR != null)
                    {
                        var labels = matchPR.Labels;
                        if (labels.Count == 0)
                        {
                            var backport = TryBodyExpression(BackportExpression, matchPR.Body);
                            if (backport != null && Int32.TryParse(backport, out int backportID))
                            {
                                var matchBackport = allIssues.FirstOrDefault(x => x.Number == backportID);
                                if (matchBackport != null)
                                {
                                    labels = matchBackport.Labels;
                                }
                            }
                        }
                        if (!labels.Any(x => x == "not-notes-worthy"))
                        {
                            requests.Add(new RequestInfo(matchPR.Number, string.Format("{0:MM/dd/yyyy}", matchPR.ClosedAt), commit.Title,
                                                         commit.Description, matchPR.Title, matchPR.Body, commit.Hash, commit.Author, matchPR.Url,
                                                         labels.Where(x => IsInterestingLabel(x)).ToList()));
                        }
                    }
                }
            }
            return(requests);
        }