當前位置: 首頁>>代碼示例>>C#>>正文


C# Octokit.NewPullRequest類代碼示例

本文整理匯總了C#中Octokit.NewPullRequest的典型用法代碼示例。如果您正苦於以下問題:C# NewPullRequest類的具體用法?C# NewPullRequest怎麽用?C# NewPullRequest使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


NewPullRequest類屬於Octokit命名空間,在下文中一共展示了NewPullRequest類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CreatePullRequest

        public async Task<PullRequest> CreatePullRequest(string branchToMerge, string prTitleHalfway, string description, string targetUsername, string targetRepository, string targetBranch, string shortTargetBranchName)
        {
            var user = await this.client.User.Current();
            var username = user.Login;

            var headRef = username + ":" + branchToMerge;
            var baseRef = targetBranch;
            var title = prTitleHalfway + " (" + shortTargetBranchName + ")";
            var newPR = new NewPullRequest(title, headRef, baseRef);
            newPR.Body = description;
            try
            {
                var pullRequest = await this.client.Repository.PullRequest.Create(targetUsername, targetRepository, newPR);
                MessageBox.Show("Success! Created PR #" + pullRequest.Number + ": " + pullRequest.Title);
                return pullRequest;
            }
            catch (Octokit.ApiValidationException e)
            {
                MessageBox.Show(e.Message + "\n\n" + e.HttpResponse.Body);
                throw;
            }
            catch (Exception)
            {
                MessageBox.Show("Error!");
                throw;
            }
        }
開發者ID:chrispatrick,項目名稱:prcreator,代碼行數:27,代碼來源:GitHubWrapper.cs

示例2: Create

        /// <summary>
        /// Create a pull request for the specified repository.
        /// </summary>
        /// <remarks>http://developer.github.com/v3/pulls/#create-a-pull-request</remarks>
        /// <param name="owner">The owner of the repository</param>
        /// <param name="name">The name of the repository</param>
        /// <param name="newPullRequest">A <see cref="NewPullRequest"/> instance describing the new PullRequest to create</param>
        /// <returns>A <see cref="PullRequest"/> result which was created on the server</returns>
        public Task<PullRequest> Create(string owner, string name, NewPullRequest newPullRequest)
        {
            Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
            Ensure.ArgumentNotNullOrEmptyString(name, "name");
            Ensure.ArgumentNotNull(newPullRequest, "newPullRequest");

            return ApiConnection.Post<PullRequest>(ApiUrls.PullRequests(owner, name), newPullRequest);
        }
開發者ID:pmacn,項目名稱:octokit.net,代碼行數:16,代碼來源:PullRequestsClient.cs

示例3: CanCreate

    public async Task CanCreate()
    {
        await CreateTheWorld();

        var newPullRequest = new NewPullRequest("a pull request", branchName, "master");
        var result = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest);
        Assert.Equal("a pull request", result.Title);
    }
開發者ID:RadicalLove,項目名稱:octokit.net,代碼行數:8,代碼來源:PullRequestsClientTests.cs

示例4: CanCreate

    public async Task CanCreate()
    {
        await CreateTheWorld();

        var newPullRequest = new NewPullRequest("a pull request", "my-branch", "master");
        var result = await _fixture.Create(Helper.UserName, _repository.Name, newPullRequest);

        Assert.Equal("a pull request", result.Title);
        Assert.False(result.Merged);
    }
開發者ID:Therzok,項目名稱:octokit.net,代碼行數:10,代碼來源:PullRequestsClientTests.cs

示例5: CanGetForRepository

    public async Task CanGetForRepository()
    {
        await CreateTheWorld();

        var newPullRequest = new NewPullRequest("a pull request", branchName, "master");
        var result = await _fixture.Create(Helper.UserName, _repository.Name, newPullRequest);

        var pullRequests = await _fixture.GetForRepository(Helper.UserName, _repository.Name);

        Assert.Equal(1, pullRequests.Count);
        Assert.Equal(result.Title, pullRequests[0].Title);
    }
開發者ID:nigel-sampson,項目名稱:octokit.net,代碼行數:12,代碼來源:PullRequestsClientTests.cs

示例6: IgnoresOpenPullRequest

    public async Task IgnoresOpenPullRequest()
    {
        await CreateTheWorld();

        var newPullRequest = new NewPullRequest("a pull request", branchName, "master");
        await _fixture.Create(Helper.UserName, _repository.Name, newPullRequest);

        var openPullRequests = new PullRequestRequest { State = ItemState.Closed };
        var pullRequests = await _fixture.GetForRepository(Helper.UserName, _repository.Name, openPullRequests);

        Assert.Empty(pullRequests);
    }
開發者ID:nigel-sampson,項目名稱:octokit.net,代碼行數:12,代碼來源:PullRequestsClientTests.cs

示例7: CreatePR

        public static BuildTargetResult CreatePR(BuildTargetContext c)
        {
            string remoteBranchName = c.GetRemoteBranchName();

            NewPullRequest prInfo = new NewPullRequest(
                PullRequestTitle,
                s_config.GitHubOriginOwner + ":" + remoteBranchName,
                s_config.GitHubUpstreamBranch);

            GitHubClient gitHub = new GitHubClient(new ProductHeaderValue("dotnetDependencyUpdater"));

            gitHub.Credentials = new Credentials(s_config.Password);

            PullRequest createdPR = gitHub.PullRequest.Create(s_config.GitHubUpstreamOwner, s_config.GitHubProject, prInfo).Result;
            c.Info($"Created Pull Request: {createdPR.HtmlUrl}");

            return c.Success();
        }
開發者ID:krytarowski,項目名稱:cli,代碼行數:18,代碼來源:PushPRTargets.cs

示例8: ReturnsCorrectCountOfPullRequestsWithoutStart

    public async Task ReturnsCorrectCountOfPullRequestsWithoutStart()
    {
        await CreateTheWorld();

        var newPullRequest = new NewPullRequest("a pull request", branchName, "master");
        var result = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest);

        var options = new ApiOptions
        {
            PageSize = 3,
            PageCount = 1
        };

        var pullRequests = await _fixture.GetAllForRepository(Helper.UserName, _context.RepositoryName, options);

        Assert.Equal(1, pullRequests.Count);
        Assert.Equal(result.Title, pullRequests[0].Title);
    }
開發者ID:RadicalLove,項目名稱:octokit.net,代碼行數:18,代碼來源:PullRequestsClientTests.cs

示例9: CanFindClosedPullRequest

    public async Task CanFindClosedPullRequest()
    {
        await CreateTheWorld();

        var newPullRequest = new NewPullRequest("a pull request", branchName, "master");
        var pullRequest = await _fixture.Create(Helper.UserName, _repository.Name, newPullRequest);

        var updatePullRequest = new PullRequestUpdate { State = ItemState.Closed };
        await _fixture.Update(Helper.UserName, _repository.Name, pullRequest.Number, updatePullRequest);

        var closedPullRequests = new PullRequestRequest { State = ItemState.Closed };
        var pullRequests = await _fixture.GetForRepository(Helper.UserName, _repository.Name, closedPullRequests);

        Assert.Equal(1, pullRequests.Count);
    }
開發者ID:nigel-sampson,項目名稱:octokit.net,代碼行數:15,代碼來源:PullRequestsClientTests.cs

示例10: CanClose

    public async Task CanClose()
    {
        await CreateTheWorld();

        var newPullRequest = new NewPullRequest("a pull request", branchName, "master");
        var pullRequest = await _fixture.Create(Helper.UserName, _repository.Name, newPullRequest);

        var updatePullRequest = new PullRequestUpdate { State = ItemState.Closed };
        var result = await _fixture.Update(Helper.UserName, _repository.Name, pullRequest.Number, updatePullRequest);

        Assert.Equal(ItemState.Closed, result.State);
        Assert.Equal(pullRequest.Title, result.Title);
        Assert.Equal(pullRequest.Body, result.Body);
    }
開發者ID:nigel-sampson,項目名稱:octokit.net,代碼行數:14,代碼來源:PullRequestsClientTests.cs

示例11: CanBeMergedWithSquashCommit

    public async Task CanBeMergedWithSquashCommit()
    {
        await CreateTheWorld();

        var newPullRequest = new NewPullRequest("squash commit pull request", branchName, "master");
        var pullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest);

        var merge = new MergePullRequest { CommitMessage = "fake commit message", CommitTitle = "fake title", Squash = true };
        var result = await _fixture.Merge(Helper.UserName, _context.RepositoryName, pullRequest.Number, merge);
        var commit = await _github.Repository.Commit.Get(_context.RepositoryOwner, _context.RepositoryName, result.Sha);
        var message = commit.Commit.Message;
        Assert.True(result.Merged);
        Assert.Equal("fake title\n\nfake commit message", commit.Commit.Message);

    }
開發者ID:RadicalLove,項目名稱:octokit.net,代碼行數:15,代碼來源:PullRequestsClientTests.cs

示例12: CanGetCommitsAndCommentCount

    public async Task CanGetCommitsAndCommentCount()
    {
        await CreateTheWorld();

        var newPullRequest = new NewPullRequest("a pull request", branchName, "master");
        var pullRequest = await _fixture.Create(Helper.UserName, _repository.Name, newPullRequest);

        // create new commit for branch

        const string commitMessage = "Another commit in branch";

        var branch = await _client.GitDatabase.Reference.Get(Helper.UserName, _repository.Name, "heads/" + branchName);

        var newTree = await CreateTree(new Dictionary<string, string> { { "README.md", "Hello World!" } });
        var newCommit = await CreateCommit(commitMessage, newTree.Sha, branch.Object.Sha);
        await _client.GitDatabase.Reference.Update(Helper.UserName, _repository.Name, "heads/" + branchName, new ReferenceUpdate(newCommit.Sha));

        await _repositoryCommentsClient.Create(Helper.UserName, _repository.Name, newCommit.Sha, new NewCommitComment("I am a nice comment") { Path = "README.md", Position = 1 });

        // don't try this at home
        await Task.Delay(TimeSpan.FromSeconds(5));

        var result = await _fixture.Commits(Helper.UserName, _repository.Name, pullRequest.Number);

        Assert.Equal(2, result.Count);
        Assert.Equal("this is the commit to merge into the pull request", result[0].Commit.Message);
        Assert.Equal(0, result[0].Commit.CommentCount);
        Assert.Equal(commitMessage, result[1].Commit.Message);
        Assert.Equal(1, result[1].Commit.CommentCount);
    }
開發者ID:nigel-sampson,項目名稱:octokit.net,代碼行數:30,代碼來源:PullRequestsClientTests.cs

示例13: UpdatesMaster

    public async Task UpdatesMaster()
    {
        await CreateTheWorld();

        var newPullRequest = new NewPullRequest("a pull request", branchName, "master");
        var pullRequest = await _fixture.Create(Helper.UserName, _repository.Name, newPullRequest);

        var merge = new MergePullRequest("thing the thing");
        var result = await _fixture.Merge(Helper.UserName, _repository.Name, pullRequest.Number, merge);

        var master = await _client.GitDatabase.Reference.Get(Helper.UserName, _repository.Name, "heads/master");

        Assert.Equal(result.Sha, master.Object.Sha);
    }
開發者ID:nigel-sampson,項目名稱:octokit.net,代碼行數:14,代碼來源:PullRequestsClientTests.cs

示例14: IsNotMergedInitially

    public async Task IsNotMergedInitially()
    {
        await CreateTheWorld();

        var newPullRequest = new NewPullRequest("a pull request", branchName, "master");
        var pullRequest = await _fixture.Create(Helper.UserName, _repository.Name, newPullRequest);

        var result = await _fixture.Merged(Helper.UserName, _repository.Name, pullRequest.Number);

        Assert.False(result);
    }
開發者ID:nigel-sampson,項目名稱:octokit.net,代碼行數:11,代碼來源:PullRequestsClientTests.cs

示例15: CreatePullRequest

    /// <summary>
    /// Creates the base state for testing (creates a repo, a commit in master, a branch, a commit in the branch and a pull request)
    /// </summary>
    /// <returns></returns>
    async Task<PullRequestData> CreatePullRequest(RepositoryContext context)
    {
        var repoName = context.RepositoryName;

        // Creating a commit in master

        var createdCommitInMaster = await CreateCommit(repoName, "Hello World!", "README.md", "heads/master", "A master commit message");

        // Creating a branch

        var newBranch = new NewReference(branchRef, createdCommitInMaster.Sha);
        await _github.Git.Reference.Create(Helper.UserName, repoName, newBranch);

        // Creating a commit in the branch

        var createdCommitInBranch = await CreateCommit(repoName, "Hello from the fork!", path, branchHead, "A branch commit message");

        // Creating a pull request

        var pullRequest = new NewPullRequest("Nice title for the pull request", branchName, "master");
        var createdPullRequest = await _github.PullRequest.Create(Helper.UserName, repoName, pullRequest);

        var data = new PullRequestData
        {
            Sha = createdCommitInBranch.Sha,
            Number = createdPullRequest.Number,
        };

        return data;
    }
開發者ID:cloudRoutine,項目名稱:octokit.net,代碼行數:34,代碼來源:PullRequestReviewCommentsClientTests.cs


注:本文中的Octokit.NewPullRequest類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。