Esempio n. 1
0
        private CommandResult CreatePullRequest(GitHttpClient client, Guid repoId, GitPullRequest pullRequestBase, string topicBranchName, string targetBranch, string pullRequestTargetBranch)
        {
            var pullRequest = client.CreatePullRequestAsync(new GitPullRequest()
            {
                SourceRefName = AzureGitHelper.WithRefsAndHeadsPrefix(topicBranchName),
                TargetRefName = AzureGitHelper.WithRefsAndHeadsPrefix(targetBranch),
                Title         = $"Merge {pullRequestTargetBranch} to {Options.TargetBranch}",
                Description   = $"Originated by Pull Request {pullRequestBase.PullRequestId} - {pullRequestBase.Title}"
            }, repoId).Result;

            var url = AzureGitHelper.BuildUrl(Context, "/pullrequest/" + pullRequest.PullRequestId);

            BrowserHelper.OpenUrl(url);

            return(Ok());
        }
Esempio n. 2
0
        public override CommandResult Execute()
        {
            var currentBranch = GitHelper.GetCurrentBranchName();
            var targetBranch  = Options.TargetBranch ?? "master";

            if (currentBranch.Contains("-on-"))
            {
                var targetBranchFromCurrentBranch = currentBranch.Substring(currentBranch.LastIndexOf("-on-") + 4).Replace("release-", "release/");

                if (targetBranch?.ToLower() != "master" && targetBranch != targetBranchFromCurrentBranch)
                {
                    return(Fail("Differents Target branch"));
                }

                targetBranch = targetBranchFromCurrentBranch;
            }

            var url = AzureGitHelper.BuildUrl(Context, "/pullrequestcreate?sourceRef={0}&targetRef={1}", currentBranch, targetBranch);

            BrowserHelper.OpenUrl(url);

            return(CommandResult.Ok());
        }