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); }
/// <summary> /// Gets the specified branch. /// </summary> /// <remarks> /// See the <a href="http://developer.github.com/v3/repos/#get-branch">API documentation</a> for more details /// </remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="branchName">The name of the branch</param> /// <returns>The specified <see cref="T:Octokit.Branch"/></returns> public IObservable <Branch> GetBranch(string owner, string name, string branchName) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNullOrEmptyString(branchName, "branchName"); return(_client.GetBranch(owner, name, branchName).ToObservable()); }
/// <summary> /// Gets the specified branch. /// </summary> /// <remarks> /// See the <a href="http://developer.github.com/v3/repos/#get-branch">API documentation</a> for more details /// </remarks> /// <param name="owner">The owner of the repository</param> /// <param name="repositoryName">The name of the repository</param> /// <param name="branchName">The name of the branch</param> /// <returns>The specified <see cref="T:Octokit.Branch"/></returns> public IObservable <Branch> GetBranch(string owner, string repositoryName, string branchName) { return(_client.GetBranch(owner, repositoryName, branchName).ToObservable()); }