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


C# Octokit.NewRepository類代碼示例

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


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

示例1: 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

示例2: CreateAsync

        public async Task<string> CreateAsync(string name)
        {
            var newRepo = new NewRepository(name) { AutoInit = true };

            var repository = await Client.Repository.Create(newRepo).ConfigureAwait(false);
            var newLabels =
                Configuration.repository.labels.Select(label => new NewLabel(label.name, label.color)).ToList();
            foreach (var newLabel in newLabels)
            {
                await Client.Issue.Labels.Create(repository.Owner.Login, repository.Name, newLabel).ConfigureAwait(false);
            }
            foreach (var branch in Configuration.repository.branches)
            {
                var master =
                    await
                        Client.GitDatabase.Reference.Get(repository.Owner.Login, repository.Name, "heads/master")
                            .ConfigureAwait(false);

                var reference = new NewReference($"refs/heads/{branch.Name}", master.Object.Sha);
                var createdReference = await
                    Client.GitDatabase.Reference.Create(repository.Owner.Login, repository.Name, reference)
                        .ConfigureAwait(false);
                if (branch.IsDefault)
                {
                    var repositoryUpdate = new RepositoryUpdate();
                    repositoryUpdate.Name = repository.Name;
                    repositoryUpdate.DefaultBranch = branch.Name;
                    await Client.Repository.Edit(repository.Owner.Login, repository.Name, repositoryUpdate).ConfigureAwait(false);
                }
            }

            return repository.HtmlUrl;
        }
開發者ID:asizikov,項目名稱:github-create-repository,代碼行數:33,代碼來源:CreateNewRepositoryTask.cs

示例3: Create

 async Task<Repository> Create(Uri url, string organizationLogin, NewRepository newRepository)
 {
     try
     {
         return await ApiConnection.Post<Repository>(url, newRepository);
     }
     catch (ApiValidationException e)
     {
         string errorMessage = e.ApiError.FirstErrorMessageSafe();
         
         if (String.Equals(
             "name already exists on this account",
             errorMessage,
             StringComparison.OrdinalIgnoreCase))
         {
             var baseAddress = Connection.BaseAddress.Host != GitHubClient.GitHubApiUrl.Host
                 ? Connection.BaseAddress
                 : new Uri("https://github.com/");
             throw new RepositoryExistsException(
                 organizationLogin,
                 newRepository.Name,
                 baseAddress, e);
         }
         if (String.Equals(
             "name can't be private. You are over your quota.",
             errorMessage,
             StringComparison.OrdinalIgnoreCase))
         {
             throw new PrivateRepositoryQuotaExceededException(e);
         }
         throw;
     }
 }
開發者ID:raghur,項目名稱:octokit.net,代碼行數:33,代碼來源:RepositoriesClient.cs

示例4: Create

        /// <summary>
        /// Creates a new repository for the current user.
        /// </summary>
        /// <remarks>
        /// See the <a href="http://developer.github.com/v3/repos/#create">API documentation</a> for more information.
        /// </remarks>
        /// <param name="newRepository">A <see cref="NewRepository"/> instance describing the new repository to create</param>
        /// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
        /// <returns>A <see cref="Repository"/> instance for the created repository.</returns>
        public Task<Repository> Create(NewRepository newRepository)
        {
            Ensure.ArgumentNotNull(newRepository, "newRepository");
            if (string.IsNullOrEmpty(newRepository.Name))
                throw new ArgumentException("The new repository's name must not be null.");

            return ApiConnection.Post<Repository>(ApiUrls.Repositories(), newRepository);
        }
開發者ID:ninadamondikar,項目名稱:octokit.net,代碼行數:17,代碼來源:RepositoriesClient.cs

示例5: CreateRepository

        public IObservable<Repository> CreateRepository(NewRepository repository, string login, bool isUser)
        {
            Guard.ArgumentNotEmptyString(login, "login");

            var client = gitHubClient.Repository;

            return (isUser ? client.Create(repository) : client.Create(login, repository));
        }
開發者ID:nulltoken,項目名稱:VisualStudio,代碼行數:8,代碼來源:ApiClient.cs

示例6: Create

        /// <summary>
        /// Creates a new repository in the specified organization.
        /// </summary>
        /// <remarks>
        /// See the <a href="http://developer.github.com/v3/repos/#create">API documentation</a> for more information.
        /// </remarks>
        /// <param name="organizationLogin">Login of the organization in which to create the repository</param>
        /// <param name="newRepository">A <see cref="NewRepository"/> instance describing the new repository to create</param>
        /// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
        /// <returns>A <see cref="Repository"/> instance for the created repository</returns>
        public Task<Repository> Create(string organizationLogin, NewRepository newRepository)
        {
            Ensure.ArgumentNotNull(organizationLogin, "organizationLogin");
            Ensure.ArgumentNotNull(newRepository, "newRepository");
            if (string.IsNullOrEmpty(newRepository.Name))
                throw new ArgumentException("The new repository's name must not be null.");

            return Create(ApiUrls.OrganizationRepositories(organizationLogin), organizationLogin, newRepository);
        }
開發者ID:RadicalLove,項目名稱:octokit.net,代碼行數:19,代碼來源:RepositoriesClient.cs

示例7: TheNewRepositoryDescription

            public void TheNewRepositoryDescription()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoriesClient(connection);
                var newRepository = new NewRepository { Name = "aName" };

                client.Create(newRepository);

                connection.Received().Post<Repository>(Args.Uri, newRepository);
            }
開發者ID:jeffwilcox,項目名稱:octokit.net,代碼行數:10,代碼來源:RepositoriesClientTests.cs

示例8: CreateRepository

        public IObservable<Unit> CreateRepository(
            NewRepository newRepository,
            IAccount account,
            string directory,
            IApiClient apiClient)
        {
            Guard.ArgumentNotEmptyString(directory, nameof(directory));

            return apiClient.CreateRepository(newRepository, account.Login, account.IsUser)
                .Select(repository => cloneService.CloneRepository(repository.CloneUrl, repository.Name, directory))
                .SelectUnit();
        }
開發者ID:chris134pravin,項目名稱:VisualStudio,代碼行數:12,代碼來源:RepositoryCreationService.cs

示例9: CanQueueAllCodeRepository

    public async Task CanQueueAllCodeRepository()
    {
        var newRepository = new NewRepository(Helper.MakeNameWithTimestamp("public-repo"));
        using (var context = await _github.CreateRepositoryContext(newRepository))
        {
            var response = await
                _github.Enterprise.SearchIndexing.QueueAllCode(EnterpriseHelper.UserName, context.RepositoryName);

            Assert.NotNull(response);
            Assert.NotNull(response.Message);
            Assert.True(response.Message.All(m => m.Contains("was added to the indexing queue")));
        }
    }
開發者ID:RadicalLove,項目名稱:octokit.net,代碼行數:13,代碼來源:EnterpriseSearchIndexingClientTests.cs

示例10: CreateRepository

        void CreateRepository(string name)
        {
            var nrep = new NewRepository("test");
            //nrep.AutoInit = true;
            try
            {
                //client.Repository.Create(nrep).Wait();
                //var rep = await client.Repository.Create(nrep);

            }
            catch (Exception e)
            {
                ;
            }
        }
開發者ID:john-guo,項目名稱:hodgepodge,代碼行數:15,代碼來源:Program.cs

示例11: CreatesARepositoryWithoutDownloads

        public async Task CreatesARepositoryWithoutDownloads()
        {
            var github = Helper.GetAuthenticatedClient();

            var repoName = Helper.MakeNameWithTimestamp("repo-without-downloads");

            var newRepository = new NewRepository(repoName) { HasDownloads = false };

            using (var context = await github.CreateRepositoryContext(newRepository))
            {
                var createdRepository = context.Repository;

                Assert.False(createdRepository.HasDownloads);
                var repository = await github.Repository.Get(Helper.UserName, repoName);
                Assert.False(repository.HasDownloads);
            }
        }
開發者ID:daveaglick,項目名稱:octokit.net,代碼行數:17,代碼來源:RepositoriesClientTests.cs

示例12: CreatesRepositoryAndPushesLocalToIt

        public async Task CreatesRepositoryAndPushesLocalToIt()
        {
            var solution = Substitute.For<IVsSolution>();
            var gitClient = Substitute.For<IGitClient>();
            var service = new RepositoryPublishService(gitClient, Substitutes.IVSGitServices);
            var newRepository = new Octokit.NewRepository("test");
            var account = Substitute.For<IAccount>();
            account.Login.Returns("monalisa");
            account.IsUser.Returns(true);
            var gitHubRepository = CreateRepository(account.Login, newRepository.Name);
            var apiClient = Substitute.For<IApiClient>();
            apiClient.CreateRepository(newRepository, "monalisa", true).Returns(Observable.Return(gitHubRepository));

            var repository = await service.PublishRepository(newRepository, account, apiClient);

            Assert.Equal("https://github.com/monalisa/test", repository.CloneUrl);
        }
開發者ID:github,項目名稱:VisualStudio,代碼行數:17,代碼來源:RepositoryPublishServiceTests.cs

示例13: 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

示例14: CreatesRepositoryOnlineViaApiAndThenClonesIt

        public void CreatesRepositoryOnlineViaApiAndThenClonesIt()
        {
            var provider = Substitutes.ServiceProvider;
            var newRepository = new NewRepository("octokit.net");
            var repository = new TestRepository("octokit.net", "https://github.com/octokit/octokit.net");
            var account = Substitute.For<IAccount>();
            account.Login.Returns("octokit");
            account.IsUser.Returns(false);
            var apiClient = Substitute.For<IApiClient>();
            apiClient.CreateRepository(newRepository, "octokit", false)
                .Returns(Observable.Return(repository));
            var cloneService = provider.GetRepositoryCloneService();
            cloneService.CloneRepository("https://github.com/octokit/octokit.net", "octokit.net", @"c:\dev")
                .Returns(Observable.Return(Unit.Default));
            var creator = provider.GetRepositoryCreationService();

            creator.CreateRepository(newRepository, account, @"c:\dev", apiClient).Subscribe();

            apiClient.Received().CreateRepository(newRepository, "octokit", false);
        }
開發者ID:chris134pravin,項目名稱:VisualStudio,代碼行數:20,代碼來源:RepositoryCreationServiceTests.cs

示例15: ThrowsRepositoryExistsExceptionWhenRepositoryExistsForCurrentUser

            public async Task ThrowsRepositoryExistsExceptionWhenRepositoryExistsForCurrentUser()
            {
                var newRepository = new NewRepository { Name = "aName" };
                var response = Substitute.For<IResponse>();
                response.StatusCode.Returns((HttpStatusCode)422);
                response.Body.Returns(@"{""message"":""Validation Failed"",""documentation_url"":"
                    + @"""http://developer.github.com/v3/repos/#create"",""errors"":[{""resource"":""Repository"","
                    + @"""code"":""custom"",""field"":""name"",""message"":""name already exists on this account""}]}");
                var credentials = new Credentials("haacked", "pwd");
                var connection = Substitute.For<IApiConnection>();
                connection.Connection.BaseAddress.Returns(GitHubClient.GitHubApiUrl);
                connection.Connection.Credentials.Returns(credentials);
                connection.Post<Repository>(Args.Uri, newRepository)
                    .Returns<Task<Repository>>(_ => { throw new ApiValidationException(response); });
                var client = new RepositoriesClient(connection);

                var exception = await AssertEx.Throws<RepositoryExistsException>(
                    async () => await client.Create(newRepository));

                Assert.False(exception.OwnerIsOrganization);
                Assert.Null(exception.Owner);
                Assert.Equal("aName", exception.RepositoryName);
                Assert.Null(exception.ExistingRepositoryWebUrl);
            }
開發者ID:jeffwilcox,項目名稱:octokit.net,代碼行數:24,代碼來源:RepositoriesClientTests.cs


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