Пример #1
0
        async Task <SearchIssuesResult> SearchPullRequests(ItemState?state, DateRange searchDates, IList <string> repoNames, string jiraIssueNumber)
        {
            // Documentation: http://octokitnet.readthedocs.org/en/latest/search/
            SearchIssuesRequest request = new SearchIssuesRequest(jiraIssueNumber)
            {
                // only search pull requests
                Type    = IssueTypeQualifier.PR,
                State   = state,
                Updated = searchDates
            };

            // if you're searching for a specific term, you can
            // focus your search on specific criteria
            request.In = new[] {
                IssueInQualifier.Title,
                IssueInQualifier.Body
            };

            foreach (var repoName in repoNames)
            {
                request.Repos.Add(String.Format(@"{0}/{1}", _owner, repoName));
            }

            return(await Client.Search.SearchIssues(request));
        }
Пример #2
0
        private async Task <IList <ICEPullRequest> > SearchPullRequestsInternal(ItemState?state, IList <string> repositoryNames)
        {
            var result = new List <ICEPullRequest>();

            var searchResults = await _service.SearchPullRequests(state, repositoryNames);

            foreach (var item in searchResults.Items)
            {
                var cePullRequest = new CEPullRequest()
                {
                    Repo         = item.Repository.Name,
                    Sha          = item.PullRequest.Head.Sha,
                    Id           = item.PullRequest.Id,
                    Number       = item.PullRequest.Number,
                    Title        = item.PullRequest.Title,
                    Status       = item.PullRequest.State.ToString(),
                    IsLocked     = item.PullRequest.Locked,
                    IsMerged     = item.PullRequest.Merged,
                    CommentCount = item.PullRequest.Comments,
                    CommitCount  = item.PullRequest.Commits
                };
                result.Add(cePullRequest);
            }

            return(result);
        }
Пример #3
0
 public static Issue CreateIssue(string owner, string repo, int number, ItemState?itemState = ItemState.Open)
 {
     return(new Issue(
                $"https://api.github.com/repos/{owner}/{repo}/issues/{number}",
                $"https://github.com/{owner}/{repo}/issues/{number}",
                $"https://api.github.com/repos/{owner}/{repo}/issues/{number}/comments",
                $"https://api.github.com/repos/{owner}/{repo}/issues/{number}/events",
                number,
                itemState ?? ItemState.Open,
                "Issue Title",
                "Issue Body",
                null,
                CreateUser(owner),
                null,
                null,
                null,
                null,
                0,
                null,
                null,
                DateTimeOffset.MinValue,
                null,
                1,
                false,
                CreateRepository(owner, repo)
                ));
 }
Пример #4
0
 public TutorSearchQuery(string term, ItemState?state, int page, string country)
 {
     Term    = term;
     State   = state;
     Page    = page;
     Country = country;
 }
Пример #5
0
        public async void UpdatePullRequests(ItemState?state)
        {
            try
            {
                if (null == _gitHubRepoHelper)
                {
                    _gitHubRepoHelper = new GitHubRepo(Settings.Default.GitHubRepoOwner, Settings.Default.GitHubUserName, Settings.Default.GitHubToken);
                    _gitHubRepoHelper.GetPullRequestsComplete += CustReports_GetPullRequestComplete;
                }

                await Task.Run(() =>
                {
                    try
                    {
                        _gitHubRepoHelper.GetRequests(state, _daysBack, _repoNames);
                    }
                    catch (Exception ex)
                    {
                        ExceptionHandler(ex);
                    }
                });
            }
            catch (Exception ex)
            {
                ExceptionHandler(ex);
            }
        }
Пример #6
0
        async Task GetPullRequestViewsByJiraNumber(ItemState?state, DateRange searchDates, IList <string> repoNames, string jiraIssueNumber)
        {
            try
            {
                var hasNewRequests = false;

                var searchResults = await SearchPullRequests(state, searchDates, repoNames, jiraIssueNumber);

                // Gets general info on each Pull Request.
                var existingRequestIds = PullRequests.Select(r => r.Id).ToList();

                foreach (var request in searchResults.Items)
                {
                    var repositoryName = request.PullRequest.HtmlUrl.Segments[2].TrimEnd('/');

                    var pullRequest = PullRequests.FirstOrDefault(r => r.Id == request.Number);
                    if (null == pullRequest)
                    {
                        pullRequest = GetNewPullRequestView(request);
                        // Get detailed info on each Pull Request.
                        pullRequest = await GetPullRequestDetails(request, pullRequest);

                        PullRequests.Add(pullRequest);
                        if (pullRequest.State == ItemState.Open)
                        {
                            hasNewRequests = true;
                        }
                    }
                    else // already had a copy in our list.. update it
                    {
                        existingRequestIds.Remove(request.Number);
                        if (pullRequest.Updated != request.UpdatedAt.GetValueOrDefault())
                        {
                            pullRequest = await GetPullRequestDetails(request, pullRequest);
                        }
                        if (pullRequest.JiraIssues.Count == 0)
                        {
                            pullRequest = await GetPullRequestDetails(request, pullRequest);
                        }
                    }
                }

                foreach (var requestToRemove in PullRequests.Where(r => existingRequestIds.Contains(r.Id)).ToList())
                {
                    PullRequests.Remove(requestToRemove);
                }

                if (hasNewRequests)
                {
                    OnNewPullRequest();
                }

                OnGetPullRequestsComplete();
            }
            catch (Exception ex)
            {
                ExceptionHandler(ex);
            }
        }
Пример #7
0
 protected ItemDataModel(Item item)
 {
     Title       = item.Title;
     Description = item.Description;
     CompleteDue = item.CompleteDue;
     Priority    = item.Priority;
     State       = item.State;
 }
Пример #8
0
        private async Task <SearchIssuesResult> SearchPullRequestsInternal(ItemState?state, IList <string> repositorynames)
        {
            SearchIssuesRequest searchRequest = new SearchIssuesRequest()
            {
                Type  = IssueTypeQualifier.PullRequest,
                State = state
            };

            foreach (var repositoryName in repositorynames)
            {
                searchRequest.Repos.Add(String.Format(@"{0}/{1}", _owner, repositoryName));
            }

            return(await Client.Search.SearchIssues(searchRequest));
        }
Пример #9
0
        async Task <SearchIssuesResult> SearchPullRequests(ItemState?state, DateRange searchDates, IList <string> repoNames)
        {
            SearchIssuesRequest searchRequest = new SearchIssuesRequest()
            {
                // only search pull requests
                Type    = IssueTypeQualifier.PR,
                State   = state,
                Updated = searchDates
            };

            foreach (var repoName in repoNames)
            {
                searchRequest.Repos.Add(String.Format(@"{0}/{1}", _owner, repoName));
            }

            return(await Client.Search.SearchIssues(searchRequest));
        }
Пример #10
0
        private async Task <IReadOnlyList <PullRequest> > GetPullRequestsInBranch(ItemState?state, string repositoryName, string branchName)
        {
            var request = new PullRequestRequest
            {
                State = state.HasValue ? ((ItemStateFilter)state) : ItemStateFilter.All,
                Base  = branchName,
            };

            var options = new ApiOptions
            {
                PageCount = 1,
                StartPage = 1,
                PageSize  = 50
            };

            return(await GetPullRequestsInBranch(request, repositoryName, options));
        }
Пример #11
0
 public FtpConnection Clone(ItemState?itemState = null)
 {
     return(new FtpConnection
     {
         Id = Id,
         Name = Name,
         ConnectionImage = ConnectionImage,
         Address = Address,
         Port = Port,
         Username = Username,
         Password = Password,
         DefaultPath = DefaultPath,
         UsePassiveMode = UsePassiveMode,
         IsHttpAccessDisabled = IsHttpAccessDisabled,
         HttpUsername = HttpUsername,
         HttpPassword = HttpPassword,
         ItemState = itemState ?? ItemState
     });
 }
Пример #12
0
 public ItemProtectionContext()
 {
     _ProtectionState = ItemState.Protected;
 }
Пример #13
0
 public void Dispose()
 {
     _ProtectionState = null;
     _Origin          = null;
 }
Пример #14
0
 public void GetRequests(ItemState?state, IList <string> repoNames)
 {
     GetRequests(state, 0, repoNames);
 }
Пример #15
0
 public async Task <SearchIssuesResult> SearchPullRequests(ItemState?state, DateRange updatedDateRange, IList <string> repositoryNames)
 {
     return(await SearchPullRequestsInternal(state, updatedDateRange, repositoryNames));
 }
Пример #16
0
 public async Task <IReadOnlyList <PullRequest> > GetPullRequests(ItemState?state, string repositoryName, string branchName)
 {
     return(await GetPullRequestsInBranch(state, repositoryName, branchName));
 }
Пример #17
0
 public void GetRequests(ItemState?state, int daysBack, IList <string> repoNames)
 {
     GetRequests(state, new DateRange(DateTime.Now.AddDays(-1 * daysBack), SearchQualifierOperator.GreaterThanOrEqualTo), repoNames);
 }
Пример #18
0
 public void GetRequests(ItemState?state, DateRange searchDates, IList <string> repoNames)
 {
     var result = GetPullRequestViews(state, searchDates, repoNames);
 }
Пример #19
0
 public void SearchRequestsByJiraIssue(ItemState?state, DateRange searchDates, IList <string> repoNames, string jiraIssueNumber)
 {
     var result = GetPullRequestViewsByJiraNumber(state, searchDates, repoNames, jiraIssueNumber);
 }
Пример #20
0
 public void SearchRequestsByJiraIssue(ItemState?state, int daysBack, IList <string> repoNames, string jiraIssueNumber)
 {
     var result = GetPullRequestViewsByJiraNumber(state, new DateRange(DateTime.Now.AddDays(-1 * daysBack), SearchQualifierOperator.GreaterThanOrEqualTo), repoNames, jiraIssueNumber);
 }