public Task <Branch> EditBranch(long repositoryId, string branch, BranchUpdate update) { Ensure.ArgumentNotNullOrEmptyString(branch, "branch"); Ensure.ArgumentNotNull(update, "update"); return(Branch.Edit(repositoryId, branch, update)); }
public Task <Branch> Edit(int repositoryId, string branch, BranchUpdate update) { Ensure.ArgumentNotNullOrEmptyString(branch, "branch"); Ensure.ArgumentNotNull(update, "update"); return(ApiConnection.Patch <Branch>(ApiUrls.RepoBranch(repositoryId, branch), update, AcceptHeaders.ProtectedBranchesApiPreview)); }
/// <summary> /// Edit the specified branch 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="branch">The name of the branch</param> /// <param name="update">New values to update the branch with</param> /// <returns>The updated <see cref="T:Octokit.Branch"/></returns> public Task <Branch> EditBranch(string owner, string name, string branch, BranchUpdate update) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "repositoryName"); Ensure.ArgumentNotNullOrEmptyString(branch, "branchName"); Ensure.ArgumentNotNull(update, "update"); return(ApiConnection.Patch <Branch>(ApiUrls.RepoBranch(owner, name, branch), update, AcceptHeaders.ProtectedBranchesApiPreview)); }
public Task <Branch> EditBranch(string owner, string name, string branch, BranchUpdate update) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNullOrEmptyString(branch, "branch"); Ensure.ArgumentNotNull(update, "update"); return(Branch.Edit(owner, name, branch, update)); }
public async Task CreateTheWorld() { // Set master branch to be protected, with some status checks var requiredStatusChecks = new RequiredStatusChecks(EnforcementLevel.Everyone, new List<string>() { "check1", "check2" }); var update = new BranchUpdate(); update.Protection = new BranchProtection(true, requiredStatusChecks); var newBranch = await _fixture.EditBranch(_context.Repository.Owner.Login, _context.Repository.Name, "master", update); }
public async Task ProtectsBranch() { // Set master branch to be protected, with some status checks var requiredStatusChecks = new RequiredStatusChecks(EnforcementLevel.Everyone, new List<string>() { "check1", "check2", "check3" }); var update = new BranchUpdate(); update.Protection = new BranchProtection(true, requiredStatusChecks); var branch = await _fixture.EditBranch(_context.Repository.Owner.Login, _context.Repository.Name, "master", update); // Ensure a branch object was returned Assert.NotNull(branch); // Retrieve master branch branch = await _fixture.GetBranch(_context.Repository.Owner.Login, _context.Repository.Name, "master"); // Assert the changes were made Assert.Equal(branch.Protection.Enabled, true); Assert.Equal(branch.Protection.RequiredStatusChecks.EnforcementLevel, EnforcementLevel.Everyone); Assert.Equal(branch.Protection.RequiredStatusChecks.Contexts.Count, 3); }
public async Task RemoveStatusCheckEnforcement() { await CreateTheWorld(); // Remove status check enforcement var requiredStatusChecks = new RequiredStatusChecks(EnforcementLevel.Off, new List<string>() { "check1" }); var update = new BranchUpdate(); update.Protection = new BranchProtection(true, requiredStatusChecks); var branch = await _fixture.EditBranch(_context.Repository.Owner.Login, _context.Repository.Name, "master", update); // Ensure a branch object was returned Assert.NotNull(branch); // Retrieve master branch branch = await _fixture.GetBranch(_context.Repository.Owner.Login, _context.Repository.Name, "master"); // Assert the changes were made Assert.Equal(branch.Protection.Enabled, true); Assert.Equal(branch.Protection.RequiredStatusChecks.EnforcementLevel, EnforcementLevel.Off); Assert.Equal(branch.Protection.RequiredStatusChecks.Contexts.Count, 1); }
/// <summary> /// Edit the specified branch with the values given in <paramref name="update"/> /// </summary> /// <param name="repositoryId">The ID of the repository</param> /// <param name="branch">The name of the branch</param> /// <param name="update">New values to update the branch with</param> /// <returns>The updated <see cref="T:Octokit.Branch"/></returns> public Task<Branch> EditBranch(int repositoryId, string branch, BranchUpdate update) { Ensure.ArgumentNotNullOrEmptyString(branch, "branch"); Ensure.ArgumentNotNull(update, "update"); return ApiConnection.Patch<Branch>(ApiUrls.RepoBranch(repositoryId, branch), update, AcceptHeaders.ProtectedBranchesApiPreview); }
/// <summary> /// Edit the specified branch 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="branch">The name of the branch</param> /// <param name="update">New values to update the branch with</param> /// <returns>The updated <see cref="T:Octokit.Branch"/></returns> public Task<Branch> EditBranch(string owner, string name, string branch, BranchUpdate update) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNullOrEmptyString(branch, "branch"); Ensure.ArgumentNotNull(update, "update"); return ApiConnection.Patch<Branch>(ApiUrls.RepoBranch(owner, name, branch), update, AcceptHeaders.ProtectedBranchesApiPreview); }
public async Task UnprotectsBranch() { await CreateTheWorld(); // Unprotect branch // Deliberately set Enforcement and Contexts to some values (these should be ignored) var requiredStatusChecks = new RequiredStatusChecks(EnforcementLevel.Everyone, new List<string> { "check1" }); var update = new BranchUpdate(); update.Protection = new BranchProtection(false, requiredStatusChecks); var branch = await _fixture.EditBranch(_context.Repository.Owner.Login, _context.Repository.Name, "master", update); // Ensure a branch object was returned Assert.NotNull(branch); // Retrieve master branch branch = await _fixture.GetBranch(_context.Repository.Owner.Login, _context.Repository.Name, "master"); // Assert the branch is unprotected, and enforcement/contexts are cleared Assert.Equal(branch.Protection.Enabled, false); Assert.Equal(branch.Protection.RequiredStatusChecks.EnforcementLevel, EnforcementLevel.Off); Assert.Equal(branch.Protection.RequiredStatusChecks.Contexts.Count, 0); }
public Task<Branch> EditBranch(long repositoryId, string branch, BranchUpdate update) { Ensure.ArgumentNotNullOrEmptyString(branch, "branch"); Ensure.ArgumentNotNull(update, "update"); return Branch.Edit(repositoryId, branch, update); }
public Task<Branch> EditBranch(string owner, string name, string branch, BranchUpdate update) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNullOrEmptyString(branch, "branch"); Ensure.ArgumentNotNull(update, "update"); return Branch.Edit(owner, name, branch, update); }