예제 #1
0
        private async Task <int> GetNumberOfCommitsBetweenInternal(Milestone previousMilestone, Milestone currentMilestone, string user, string repository)
        {
            try
            {
                if (previousMilestone == null)
                {
                    _logger.Verbose("Getting commit count between base '{Base}' and head '{Head}'", "master", currentMilestone.Title);
                    var gitHubClientRepositoryCommitsCompare = await _gitHubClient.Repository.Commit.Compare(user, repository, "master", currentMilestone.Title).ConfigureAwait(false);

                    return(gitHubClientRepositoryCommitsCompare.AheadBy);
                }

                _logger.Verbose("Getting commit count between base '{Base}' and head '{Head}'", previousMilestone.Title, "master");
                var compareResult = await _gitHubClient.Repository.Commit.Compare(user, repository, previousMilestone.Title, "master").ConfigureAwait(false);

                return(compareResult.AheadBy);
            }
            catch (NotFoundException)
            {
                _logger.Warning("Unable to find tag for milestone, so commit count will be returned as zero");

                // If there is no tag yet the Compare will return a NotFoundException
                // we can safely ignore
                return(0);
            }
        }
예제 #2
0
        public async Task <List <Issue> > GetIssuesAsync(Milestone targetMilestone)
        {
            var githubMilestone = _mapper.Map <Octokit.Milestone>(targetMilestone);

            _logger.Verbose("Finding issues on milestone: {@Milestone}", githubMilestone);
            var allIssues = await _gitHubClient.AllIssuesForMilestone(githubMilestone).ConfigureAwait(false);

            return(_mapper.Map <List <Issue> >(allIssues.Where(x => x.State == ItemState.Closed).ToList()));
        }
예제 #3
0
        public Task <int> GetNumberOfCommitsBetween(Milestone previousMilestone, Milestone currentMilestone, string user, string repository)
        {
            if (currentMilestone is null)
            {
                throw new ArgumentNullException(nameof(currentMilestone));
            }

            return(GetNumberOfCommitsBetweenInternal(previousMilestone, currentMilestone, user, repository));
        }
예제 #4
0
        public string GetCommitsLink(string user, string repository, Milestone milestone, Milestone previousMilestone)
        {
            if (milestone is null)
            {
                throw new ArgumentNullException(nameof(milestone));
            }

            if (previousMilestone is null)
            {
                return(string.Format(CultureInfo.InvariantCulture, "https://github.com/{0}/{1}/commits/{2}", user, repository, milestone.Title));
            }

            return(string.Format(CultureInfo.InvariantCulture, "https://github.com/{0}/{1}/compare/{2}...{3}", user, repository, previousMilestone.Title, milestone.Title));
        }