public async Task Run() { var jiraResponse = await _lazyGitLogic.GetJiraTickets(); if (!jiraResponse.Issues.Any()) { Log.Debug("No Jira tickets to process, terminating application."); return; } var ticketList = (await _lazyGitLogic.GetPullRequestInfoForJiraTickets(jiraResponse.Issues.Select(i => i.Key))) .ToList(); if (!ticketList.Any()) { Log.Debug("No pull requests found for Jira tickets, terminating application."); return; } foreach (var ticket in ticketList) { ticket.Summary = jiraResponse.Issues .First(jt => jt.Key == ticket.JiraKey).Fields.Summary ?? string.Empty; if (ticket.PullRequestId == 0) { continue; } var rebaseResult = _lazyGitLogic.RebaseTicket(ticket); ticket.RebaseStatus = rebaseResult.Status; ticket.JiraUrl = _baseTicketUrl + ticket.JiraKey; if (!rebaseResult.RebaseSuccess) { continue; } // Don't delete the branch or update the Jira ticket if the merge failed if (!_lazyGitLogic.MergePullRequest(ticket.PullRequestId)) { continue; } _lazyGitLogic.DeleteBranch(rebaseResult.SourceBranch); var updateSuccess = await _lazyGitLogic.UpdateJiraTicket(ticket.JiraKey); if (!updateSuccess) { Log.Warning("Failed to update Jira ticket with key: {JiraKey}", ticket.JiraKey); } } _lazyGitLogic.ProcessEmails(ticketList); }
public void MergePullRequest_ReturnTrue() { var result = _lazyGitLogic.MergePullRequest(555); Assert.True(result); }