private async Task <int?> CreatePullRequestIfChanged(Guid repoId, List <GitChange> changes, string lastCommit, string baseBranchName, string targetBranchName, ITemplateReplacer replacer) { if (changes.Count > 0) { var title = GetTitle(replacer); var description = GetDescription(replacer); var commitMessage = GetCommitMessage(replacer); var push = CreatePush(lastCommit, changes, targetBranchName, commitMessage); await _gitClient.CreatePushAsync(push, repoId).ConfigureAwait(false); Log($"Push for {repoId} at {targetBranchName} created."); if (!string.Equals(baseBranchName, targetBranchName, StringComparison.InvariantCultureIgnoreCase)) { var pr = CreatePullRequest(baseBranchName, targetBranchName, title, description); var result = await _gitClient.CreatePullRequestAsync(pr, repoId).ConfigureAwait(false); Log($"Pull request for {repoId} to {baseBranchName} created."); return(result.PullRequestId); } Log($"Skipping pull request since {baseBranchName} was the target."); } return(null); }
private static string GetTargetBranchName(ITemplateReplacer replacer) => replacer.MakeString(Constants.NewBranchName);
private static string GetDescription(ITemplateReplacer replacer) => replacer.MakeString(Constants.NewPrDescription);
private static string GetTitle(ITemplateReplacer replacer) => replacer.MakeString(Constants.NewPrTitle);
private static string GetCommitMessage(ITemplateReplacer replacer) => replacer.MakeString(Constants.NewCommitMessage);