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; }
public async Task UpdatesMergeMethodWithRepositoryId() { var github = Helper.GetAuthenticatedClient(); using (var context = await github.CreateRepositoryContext("public-repo")) { var updateRepository = new RepositoryUpdate(context.RepositoryName) { AllowMergeCommit = true, AllowSquashMerge = true, AllowRebaseMerge = false }; var editedRepository = await github.Repository.Edit(context.RepositoryId, updateRepository); Assert.True(editedRepository.AllowMergeCommit); Assert.True(editedRepository.AllowSquashMerge); Assert.False(editedRepository.AllowRebaseMerge); var repository = await github.Repository.Get(context.RepositoryId); Assert.True(repository.AllowMergeCommit); Assert.True(repository.AllowSquashMerge); Assert.False(repository.AllowRebaseMerge); } }
public async Task UpdatesHasWikiWithRepositoryId() { var github = Helper.GetAuthenticatedClient(); var repoName = Helper.MakeNameWithTimestamp("public-repo"); _repository = await github.Repository.Create(new NewRepository(repoName) { AutoInit = true }); var update = new RepositoryUpdate { Name = repoName, HasWiki = false }; _repository = await github.Repository.Edit(_repository.Id, update); Assert.Equal(false, _repository.HasWiki); }
public async Task UpdatesPrivateWithRepositoryId() { var github = Helper.GetAuthenticatedClient(); var userDetails = await github.User.Current(); if (userDetails.Plan.PrivateRepos == 0) { throw new Exception("Test cannot complete, account is on free plan"); } var repoName = Helper.MakeNameWithTimestamp("public-repo"); _repository = await github.Repository.Create(new NewRepository(repoName) { AutoInit = true }); var update = new RepositoryUpdate { Name = repoName, Private = true }; _repository = await github.Repository.Edit(_repository.Id, update); Assert.Equal(true, _repository.Private); }
public async Task UpdatesHomepageWithRepositoryId() { var github = Helper.GetAuthenticatedClient(); var repoName = Helper.MakeNameWithTimestamp("public-repo"); _repository = await github.Repository.Create(new NewRepository(repoName) { AutoInit = true }); var update = new RepositoryUpdate { Name = repoName, Homepage = "http://aUrl.to/nowhere" }; _repository = await github.Repository.Edit(_repository.Id, update); Assert.Equal("http://aUrl.to/nowhere", _repository.Homepage); }
public async Task UpdatesDescriptionWithRepositoryId() { var github = Helper.GetAuthenticatedClient(); var repoName = Helper.MakeNameWithTimestamp("public-repo"); _repository = await github.Repository.Create(new NewRepository(repoName) { AutoInit = true }); var update = new RepositoryUpdate { Name = repoName, Description = "Updated description" }; _repository = await github.Repository.Edit(_repository.Id, update); Assert.Equal("Updated description", _repository.Description); }
public async Task UpdatesName() { var github = Helper.GetAuthenticatedClient(); var repoName = Helper.MakeNameWithTimestamp("public-repo"); _repository = await github.Repository.Create(new NewRepository(repoName) { AutoInit = true }); var updatedName = Helper.MakeNameWithTimestamp("updated-repo"); var update = new RepositoryUpdate { Name = updatedName }; _repository = await github.Repository.Edit(Helper.UserName, repoName, update); Assert.Equal(update.Name, _repository.Name); }
/// <summary> /// Updates the specified repository with the values given in <paramref name="update"/> /// </summary> /// <param name="repositoryId">The Id of the repository</param> /// <param name="update">New values to update the repository with</param> /// <returns>The updated <see cref="T:Octokit.Repository"/></returns> public Task <Repository> Edit(long repositoryId, RepositoryUpdate update) { Ensure.ArgumentNotNull(update, "update"); return(ApiConnection.Patch <Repository>(ApiUrls.Repository(repositoryId), update)); }
public void PatchesCorrectUrl() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoriesClient(connection); var update = new RepositoryUpdate(); client.Edit("owner", "repo", update); connection.Received() .Patch<Repository>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo"), Arg.Any<RepositoryUpdate>()); }
/// <summary> /// Updates the specified repository with the values given in <paramref name="update"/> /// </summary> /// <param name="repositoryId">The Id of the repository</param> /// <param name="update">New values to update the repository with</param> /// <returns>The updated <see cref="T:Octokit.Repository"/></returns> public Task<Repository> Edit(long repositoryId, RepositoryUpdate update) { Ensure.ArgumentNotNull(update, "update"); return ApiConnection.Patch<Repository>(ApiUrls.Repository(repositoryId), update, AcceptHeaders.SquashCommitPreview); }
/// <summary> /// Updates the specified repository with the values given in <paramref name="update"/> /// </summary> /// <param name="repositoryId">The Id of the repository</param> /// <param name="update">New values to update the repository with</param> /// <returns>The updated <see cref="T:Octokit.Repository"/></returns> public Task <Repository> Edit(long repositoryId, RepositoryUpdate update) { Ensure.ArgumentNotNull(update, "update"); return(ApiConnection.Patch <Repository>(ApiUrls.Repository(repositoryId), update, AcceptHeaders.Concat(AcceptHeaders.SquashCommitPreview, AcceptHeaders.LicensesApiPreview))); }
public async Task UpdatesHasWiki() { var github = CreateGitHubClient(); var repoName = Helper.MakeNameWithTimestamp("public-repo"); _repository = await github.Repository.Create(new NewRepository { Name = repoName, AutoInit = true }); var update = new RepositoryUpdate { Name = repoName, HasWiki = false }; _repository = await github.Repository.Edit(Helper.UserName, repoName, update); Assert.Equal(false, _repository.HasWiki); }
public async Task UpdatesHomepage() { var github = CreateGitHubClient(); var repoName = Helper.MakeNameWithTimestamp("public-repo"); _repository = await github.Repository.Create(new NewRepository { Name = repoName, AutoInit = true }); var update = new RepositoryUpdate { Name = repoName, Homepage = "http://aUrl.to/nowhere" }; _repository = await github.Repository.Edit(Helper.UserName, repoName, update); Assert.Equal("http://aUrl.to/nowhere", _repository.Homepage); }
public async Task UpdatesDescription() { var github = CreateGitHubClient(); var repoName = Helper.MakeNameWithTimestamp("public-repo"); _repository = await github.Repository.Create(new NewRepository { Name = repoName, AutoInit = true }); var update = new RepositoryUpdate { Name = repoName, Description = "Updated description" }; _repository = await github.Repository.Edit(Helper.UserName, repoName, update); Assert.Equal("Updated description", _repository.Description); }
/// <summary> /// Updates the specified repository with the values given in <paramref name="update"/> /// </summary> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="update">New values to update the repository with</param> /// <returns>The updated <see cref="T:Octokit.Repository"/></returns> public Task<Repository> Edit(string owner, string name, RepositoryUpdate update) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNull(update, "update"); return ApiConnection.Patch<Repository>(ApiUrls.Repository(owner, name), update); }
/// <summary> /// Updates the specified repository with the values given in <paramref name="update"/> /// </summary> /// <param name="repositoryId">The ID of the repository</param> /// <param name="update">New values to update the repository with</param> /// <returns>The updated <see cref="T:Octokit.Repository"/></returns> public Task<Repository> Edit(int repositoryId, RepositoryUpdate update) { Ensure.ArgumentNotNull(update, "update"); return ApiConnection.Patch<Repository>(ApiUrls.Repository(repositoryId), update); }
public void EnsuresNonNullArguments() { var client = new RepositoriesClient(Substitute.For<IApiConnection>()); var update = new RepositoryUpdate(); Assert.Throws<ArgumentNullException>(() => client.Edit(null, "repo", update)); Assert.Throws<ArgumentNullException>(() => client.Edit("owner", null, update)); Assert.Throws<ArgumentNullException>(() => client.Edit("owner", "repo", null)); Assert.Throws<ArgumentException>(() => client.Edit("", "repo", update)); Assert.Throws<ArgumentException>(() => client.Edit("owner", "", update)); }