Ejemplo n.º 1
0
        public async Task <long> OpenAsync(PullRequestParameters parameters)
        {
            var inMemoryCredentialStore = new InMemoryCredentialStore(new Credentials(KnownGitHubs.Username, parameters.Password));

            var githubClient = new GitHubClient(new ProductHeaderValue("ImgBot"), inMemoryCredentialStore);

            var repo = await githubClient.Repository.Get(parameters.RepoOwner, parameters.RepoName);

            var branch = await githubClient.Repository.Branch.Get(parameters.RepoOwner, parameters.RepoName, KnownGitHubs.BranchName);

            var commit = await githubClient.Repository.Commit.Get(parameters.RepoOwner, parameters.RepoName, branch.Commit.Sha);

            if (branch == null)
            {
                return(0);
            }

            var pr = new NewPullRequest(KnownGitHubs.CommitMessageTitle, KnownGitHubs.BranchName, repo.DefaultBranch)
            {
                Body = PullRequestBody.Generate(commit.Commit.Message),
            };

            var result = await githubClient.PullRequest.Create(parameters.RepoOwner, parameters.RepoName, pr);

            return(result.Id);
        }
Ejemplo n.º 2
0
        public static async Task OpenAsync(PullRequestParameters parameters)
        {
            var inMemoryCredentialStore = new InMemoryCredentialStore(new Credentials(KnownGitHubs.Username, parameters.Password));

            var githubClient = new GitHubClient(new ProductHeaderValue("ImgBot"), inMemoryCredentialStore);

            var repo = await githubClient.Repository.Get(parameters.RepoOwner, parameters.RepoName);

            var pr = new NewPullRequest(KnownGitHubs.CommitMessageTitle, KnownGitHubs.BranchName, repo.DefaultBranch)
            {
                Body = "Beep boop. Optimizing your images is my life. https://imgbot.net/ for more information."
            };

            await githubClient.PullRequest.Create(parameters.RepoOwner, parameters.RepoName, pr);
        }