示例#1
0
        public async Task SubscriptionDeletedAsync(string user)
        {
            ConditionalValue <InProgressPullRequest> maybePr =
                await StateManager.TryGetStateAsync <InProgressPullRequest>(PullRequest);

            if (maybePr.HasValue)
            {
                InProgressPullRequest pr = maybePr.Value;
                if (string.IsNullOrEmpty(pr.Url))
                {
                    // somehow a bad PR got in the collection, remove it
                    await StateManager.RemoveStateAsync(PullRequest);

                    return;
                }

                long installationId = 0;
                if (pr.Url.Contains("github.com"))
                {
                    (string owner, string repo, int id) = GitHubClient.ParsePullRequestUri(pr.Url);
                    installationId = await Context.GetInstallationId($"https://github.com/{owner}/{repo}");
                }

                IRemote darc = await DarcFactory.CreateAsync(pr.Url, installationId);

                await darc.CreatePullRequestCommentAsync(
                    pr.Url,
                    $@"The subscription that generated this pull request has been deleted by @{user}.
This pull request will no longer be tracked by maestro.");

                await StateManager.RemoveStateAsync(PullRequest);
            }
        }
示例#2
0
        private async Task UpdateStatusCommentAsync(IRemote darc, InProgressPullRequest pr, string message)
        {
            if (pr.StatusCommentId == null)
            {
                pr.StatusCommentId = await darc.CreatePullRequestCommentAsync(pr.Url, message);

                await StateManager.SetStateAsync(PullRequest, pr);
            }
            else
            {
                await darc.UpdatePullRequestCommentAsync(pr.Url, pr.StatusCommentId, message);
            }
        }