示例#1
0
        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);
        }
示例#2
0
 private static string GetTargetBranchName(ITemplateReplacer replacer) =>
 replacer.MakeString(Constants.NewBranchName);
示例#3
0
 private static string GetDescription(ITemplateReplacer replacer) =>
 replacer.MakeString(Constants.NewPrDescription);
示例#4
0
 private static string GetTitle(ITemplateReplacer replacer) =>
 replacer.MakeString(Constants.NewPrTitle);
示例#5
0
 private static string GetCommitMessage(ITemplateReplacer replacer) =>
 replacer.MakeString(Constants.NewCommitMessage);