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


C# Octokit.NewCommit類代碼示例

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


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

示例1: CanCreateAReference

    public async Task CanCreateAReference()
    {
        var blob = new NewBlob
        {
            Content = "Hello World!",
            Encoding = EncodingType.Utf8
        };
        var blobResult = await _client.GitDatabase.Blob.Create(_owner, _repository.Name, blob);

        var newTree = new NewTree();
        newTree.Tree.Add(new NewTreeItem
        {
            Mode = FileMode.File,
            Type = TreeType.Blob,
            Path = "README.md",
            Sha = blobResult.Sha
        });

        var treeResult = await _client.GitDatabase.Tree.Create(_owner, _repository.Name, newTree);

        var newCommit = new NewCommit("This is a new commit", treeResult.Sha, Enumerable.Empty<string>());

        var commitResult = await _client.GitDatabase.Commit.Create(_owner, _repository.Name, newCommit);

        var newReference = new NewReference("heads/develop", commitResult.Sha);
        var result = await _fixture.Create(_owner, _repository.Name, newReference);

        Assert.NotNull(result);
    }
開發者ID:richardkundl,項目名稱:octokit.net,代碼行數:29,代碼來源:ReferencesClientTests.cs

示例2: DeploymentsClientTests

    public DeploymentsClientTests()
    {
        var gitHubClient = Helper.GetAuthenticatedClient();

        _deploymentsClient = gitHubClient.Repository.Deployment;

        var newRepository = new NewRepository(Helper.MakeNameWithTimestamp("public-repo"))
        {
            AutoInit = true
        };

        _repository = gitHubClient.Repository.Create(newRepository).Result;
        _repositoryOwner = _repository.Owner.Login;

        var blob = new NewBlob
        {
            Content = "Hello World!",
            Encoding = EncodingType.Utf8
        };

        var blobResult = gitHubClient.GitDatabase.Blob.Create(_repositoryOwner, _repository.Name, blob).Result;

        var newTree = new NewTree();
        newTree.Tree.Add(new NewTreeItem
        {
            Type = TreeType.Blob,
            Mode = FileMode.File,
            Path = "README.md",
            Sha = blobResult.Sha
        });

        var treeResult = gitHubClient.GitDatabase.Tree.Create(_repositoryOwner, _repository.Name, newTree).Result;
        var newCommit = new NewCommit("test-commit", treeResult.Sha);
        _commit = gitHubClient.GitDatabase.Commit.Create(_repositoryOwner, _repository.Name, newCommit).Result;
    }
開發者ID:cH40z-Lord,項目名稱:octokit.net,代碼行數:35,代碼來源:DeploymentsClientTests.cs

示例3: DeploymentStatusClientTests

    public DeploymentStatusClientTests()
    {
        var github = Helper.GetAuthenticatedClient();

        _deploymentsClient = github.Repository.Deployment;
        _context = github.CreateRepositoryContext("public-repo").Result;

        var blob = new NewBlob
        {
            Content = "Hello World!",
            Encoding = EncodingType.Utf8
        };

        var blobResult = github.Git.Blob.Create(_context.RepositoryOwner, _context.RepositoryName, blob).Result;

        var newTree = new NewTree();
        newTree.Tree.Add(new NewTreeItem
        {
            Type = TreeType.Blob,
            Mode = FileMode.File,
            Path = "README.md",
            Sha = blobResult.Sha
        });

        var treeResult = github.Git.Tree.Create(_context.RepositoryOwner, _context.RepositoryName, newTree).Result;
        var newCommit = new NewCommit("test-commit", treeResult.Sha);

        var commit = github.Git.Commit.Create(_context.RepositoryOwner, _context.RepositoryName, newCommit).Result;

        var newDeployment = new NewDeployment(commit.Sha) { AutoMerge = false };
        _deployment = _deploymentsClient.Create(_context.RepositoryOwner, _context.RepositoryName, newDeployment).Result;
    }
開發者ID:RadicalLove,項目名稱:octokit.net,代碼行數:32,代碼來源:DeploymentStatusClientTests.cs

示例4: CanCreateAndRetrieveCommit

    public async Task CanCreateAndRetrieveCommit()
    {
        var blob = new NewBlob
        {
            Content = "Hello World!",
            Encoding = EncodingType.Utf8
        };
        var blobResult = await _client.GitDatabase.Blob.Create(_owner, _repository.Name, blob);

        var newTree = new NewTree();
        newTree.Tree.Add(new NewTreeItem
        {
            Type = TreeType.Blob,
            Mode = FileMode.File,
            Path = "README.md",
            Sha = blobResult.Sha
        });

        var treeResult = await _client.GitDatabase.Tree.Create(_owner, _repository.Name, newTree);

        var newCommit = new NewCommit("test-commit", treeResult.Sha, Enumerable.Empty<string>());

        var commit = await _fixture.Create(_owner, _repository.Name, newCommit);
        Assert.NotNull(commit);

        var retrieved = await _fixture.Get(_owner, _repository.Name, commit.Sha);
        Assert.NotNull(retrieved);
    }
開發者ID:rgmills,項目名稱:octokit.net,代碼行數:28,代碼來源:CommitsClientTests.cs

示例5: CreateCommits

    private IEnumerable<Commit> CreateCommits(int commitCount)
    {
        var github = Helper.GetAuthenticatedClient();

        var list = new List<Commit>();

        for (int i = 0; i < commitCount; i++)
        {
            var blob = new NewBlob
            {
                Content = string.Format("Hello World {0}!", i),
                Encoding = EncodingType.Utf8
            };

            var blobResult = github.Git.Blob.Create(_context.RepositoryOwner, _context.RepositoryName, blob).Result;

            var newTree = new NewTree();
            newTree.Tree.Add(new NewTreeItem
            {
                Type = TreeType.Blob,
                Mode = FileMode.File,
                Path = "README.md",
                Sha = blobResult.Sha
            });

            var treeResult = github.Git.Tree.Create(_context.RepositoryOwner, _context.RepositoryName, newTree).Result;
            var newCommit = new NewCommit("test-commit", treeResult.Sha);
            var commit = github.Git.Commit.Create(_context.RepositoryOwner, _context.RepositoryName, newCommit).Result;
            list.Add(commit);
        }

        return list;
    }
開發者ID:daveaglick,項目名稱:octokit.net,代碼行數:33,代碼來源:DeploymentsClientTests.cs

示例6: Create

        /// <summary>
        /// Create a commit for a given repository
        /// </summary>
        /// <remarks>
        /// http://developer.github.com/v3/git/commits/#create-a-commit
        /// </remarks>
        /// <param name="owner">The owner of the repository</param>
        /// <param name="name">The name of the repository</param>
        /// <param name="commit">The commit to create</param>
        public Task<Commit> Create(string owner, string name, NewCommit commit)
        {
            Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
            Ensure.ArgumentNotNullOrEmptyString(name, "name");
            Ensure.ArgumentNotNull(commit, "commit");

            return ApiConnection.Post<Commit>(ApiUrls.CreateCommit(owner, name), commit);
        }
開發者ID:Sarmad93,項目名稱:octokit.net,代碼行數:17,代碼來源:CommitsClient.cs

示例7: EnsuresNonNullArguments

        public async Task EnsuresNonNullArguments()
        {
            var client = new CommitsClient(Substitute.For<IApiConnection>());

            var newCommit = new NewCommit("message", "tree", new[] { "parent1", "parent2" });
            await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create(null, "name", newCommit));
            await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create("owner", null, newCommit));
            await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create("owner", "name", null));
            await Assert.ThrowsAsync<ArgumentException>(() => client.Create("", "name", newCommit));
            await Assert.ThrowsAsync<ArgumentException>(() => client.Create("owner", "", newCommit));
        }
開發者ID:cloudRoutine,項目名稱:octokit.net,代碼行數:11,代碼來源:CommitsClientTests.cs

示例8: PostsToTheCorrectUrl

        public void PostsToTheCorrectUrl()
        {
            var connection = Substitute.For<IApiConnection>();
            var client = new CommitsClient(connection);

            var parents = new List<string> { "sha-reference1", "sha-reference2" };
            var newCommit = new NewCommit("message", "tree", parents);
            client.Create("owner", "repo", newCommit);

            connection.Received().Post<Commit>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/git/commits"),
                                               Arg.Is<NewCommit>(nc => nc.Message == "message"
                                                                    && nc.Tree == "tree"
                                                                    && nc.Parents.Count() == 2));
        }
開發者ID:cloudRoutine,項目名稱:octokit.net,代碼行數:14,代碼來源:CommitsClientTests.cs

示例9: DeploymentStatusClientTests

    public DeploymentStatusClientTests()
    {
        _gitHubClient = new GitHubClient(new ProductHeaderValue("OctokitTests"))
        {
            Credentials = Helper.Credentials
        };

        _deploymentsClient = _gitHubClient.Repository.Deployment;

        var newRepository = new NewRepository
        {
            Name = Helper.MakeNameWithTimestamp("public-repo"),
            AutoInit = true
        };

        _repository = _gitHubClient.Repository.Create(newRepository).Result;
        _repositoryOwner = _repository.Owner.Login;

        var blob = new NewBlob
        {
            Content = "Hello World!",
            Encoding = EncodingType.Utf8
        };

        var blobResult = _gitHubClient.GitDatabase.Blob.Create(_repositoryOwner, _repository.Name, blob).Result;

        var newTree = new NewTree();
        newTree.Tree.Add(new NewTreeItem
        {
            Type = TreeType.Blob,
            Mode = FileMode.File,
            Path = "README.md",
            Sha = blobResult.Sha
        });

        var treeResult = _gitHubClient.GitDatabase.Tree.Create(_repositoryOwner, _repository.Name, newTree).Result;
        var newCommit = new NewCommit("test-commit", treeResult.Sha);
        _commit = _gitHubClient.GitDatabase.Commit.Create(_repositoryOwner, _repository.Name, newCommit).Result;

        var newDeployment = new NewDeployment { Ref = _commit.Sha };
        _deployment = _deploymentsClient.Create(_repositoryOwner, _repository.Name, newDeployment).Result;
    }
開發者ID:Therzok,項目名稱:octokit.net,代碼行數:42,代碼來源:DeploymentStatusClientTests.cs

示例10: SetupCommitForRepository

        private async Task<Commit> SetupCommitForRepository(IGitHubClient client)
        {
            var blob = new NewBlob
            {
                Content = "Hello World!",
                Encoding = EncodingType.Utf8
            };
            var blobResult = await client.Git.Blob.Create(_context.RepositoryOwner, _context.RepositoryName, blob);

            var newTree = new NewTree();
            newTree.Tree.Add(new NewTreeItem
            {
                Type = TreeType.Blob,
                Mode = FileMode.File,
                Path = "README.md",
                Sha = blobResult.Sha
            });

            var treeResult = await client.Git.Tree.Create(_context.RepositoryOwner, _context.RepositoryName, newTree);

            var newCommit = new NewCommit("test-commit", treeResult.Sha);

            return await client.Git.Commit.Create(_context.RepositoryOwner, _context.RepositoryName, newCommit);
        }
開發者ID:RadicalLove,項目名稱:octokit.net,代碼行數:24,代碼來源:CommitCommentReactionsClientTests.cs

示例11: HelperCreateCommit

    async static Task<Commit> HelperCreateCommit(string owner, string repo)
    {
        var client = Helper.GetAuthenticatedClient();

        var blob = new NewBlob
        {
            Content = "Hello World!",
            Encoding = EncodingType.Utf8
        };
        var blobResult = await client.Git.Blob.Create(owner, repo, blob);

        var newTree = new NewTree();
        newTree.Tree.Add(new NewTreeItem
        {
            Type = TreeType.Blob,
            Mode = FileMode.File,
            Path = "README.md",
            Sha = blobResult.Sha
        });

        var treeResult = await client.Git.Tree.Create(owner, repo, newTree);

        var newCommit = new NewCommit("test-commit", treeResult.Sha);

        return await client.Git.Commit.Create(owner, repo, newCommit);
    }
開發者ID:rlugojr,項目名稱:octokit.net,代碼行數:26,代碼來源:RepositoryCommentsClientTests.cs

示例12: CreateCommit

    async Task<Commit> CreateCommit(string repoName, string blobContent, string treePath, string reference, string commitMessage)
    {
        // Creating a blob
        var blob = new NewBlob
        {
            Content = blobContent,
            Encoding = EncodingType.Utf8
        };

        var createdBlob = await _github.Git.Blob.Create(Helper.UserName, repoName, blob);

        // Creating a tree
        var newTree = new NewTree();
        newTree.Tree.Add(new NewTreeItem
        {
            Type = TreeType.Blob,
            Mode = FileMode.File,
            Path = treePath,
            Sha = createdBlob.Sha,
        });

        var createdTree = await _github.Git.Tree.Create(Helper.UserName, repoName, newTree);
        var treeSha = createdTree.Sha;

        // Creating a commit
        var parent = await _github.Git.Reference.Get(Helper.UserName, repoName, reference);
        var commit = new NewCommit(commitMessage, treeSha, parent.Object.Sha);

        var createdCommit = await _github.Git.Commit.Create(Helper.UserName, repoName, commit);
        await _github.Git.Reference.Update(Helper.UserName, repoName, reference, new ReferenceUpdate(createdCommit.Sha));

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

示例13: CanDeleteAReference

    public async Task CanDeleteAReference()
    {
        var blob = new NewBlob
        {
            Content = "Hello World!",
            Encoding = EncodingType.Utf8
        };
        var blobResult = await _client.GitDatabase.Blob.Create(_owner, _repository.Name, blob);

        var newTree = new NewTree();
        newTree.Tree.Add(new NewTreeItem
        {
            Mode = FileMode.File,
            Type = TreeType.Blob,
            Path = "README.md",
            Sha = blobResult.Sha
        });

        var treeResult = await _client.GitDatabase.Tree.Create(_owner, _repository.Name, newTree);

        var newCommit = new NewCommit("This is a new commit", treeResult.Sha);

        var commitResult = await _client.GitDatabase.Commit.Create(_owner, _repository.Name, newCommit);

        var newReference = new NewReference("heads/develop", commitResult.Sha);

        await _fixture.Create(_owner, _repository.Name, newReference);
        await _fixture.Delete(_owner, _repository.Name, "heads/develop");

        var all = await _fixture.GetAll(_owner, _repository.Name);

        Assert.Empty(all.Where(r => r.Ref == "heads/develop"));
    }
開發者ID:ninadamondikar,項目名稱:octokit.net,代碼行數:33,代碼來源:ReferencesClientTests.cs

示例14: CreateCommit

 /// <summary>
 /// Create a GitHub commit
 /// </summary>
 /// <param name="message">The commit message</param>
 /// <param name="sha">The SHA hash for the commit</param>
 /// <param name="parent">The parent commit</param>
 /// <param name="client">The GitHub client</param>
 /// <param name="owner">The owner of the repo</param>
 /// <param name="name">The name of the repo</param>
 /// <returns>The new commit</returns>
 async Task<Commit> CreateCommit(string message, string sha, string parent, GitHubClient client, string owner, string name)
 {
     var newCommit = new NewCommit(message, sha, parent);
     return await client.GitDatabase.Commit.Create(owner, name, newCommit);
 }
開發者ID:DHBrett,項目名稱:Graffiti,代碼行數:15,代碼來源:GitHub.cs

示例15: CanCreateAReference

    public async Task CanCreateAReference()
    {
        var blob = new NewBlob
        {
            Content = "Hello World!",
            Encoding = EncodingType.Utf8
        };
        var blobResult = await _github.Git.Blob.Create(_context.RepositoryOwner, _context.RepositoryName, blob);

        var newTree = new NewTree();
        newTree.Tree.Add(new NewTreeItem
        {
            Mode = FileMode.File,
            Type = TreeType.Blob,
            Path = "README.md",
            Sha = blobResult.Sha
        });

        var treeResult = await _github.Git.Tree.Create(_context.RepositoryOwner, _context.RepositoryName, newTree);

        var newCommit = new NewCommit("This is a new commit", treeResult.Sha);

        var commitResult = await _github.Git.Commit.Create(_context.RepositoryOwner, _context.RepositoryName, newCommit);

        var newReference = new NewReference("heads/develop", commitResult.Sha);
        var result = await _fixture.Create(_context.RepositoryOwner, _context.RepositoryName, newReference);

        Assert.Equal(commitResult.Sha, result.Object.Sha);
    }
開發者ID:cloudRoutine,項目名稱:octokit.net,代碼行數:29,代碼來源:ReferencesClientTests.cs


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