/// <summary> /// Add team restrictions for the specified branch (applies only to Organization owned repositories) /// </summary> /// <remarks> /// See the <a href="https://developer.github.com/v3/repos/branches/#add-team-restrictions-of-protected-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="branch">The name of the branch</param> /// <param name="teams">List of teams with push access</param> public IObservable <Team> AddProtectedBranchTeamRestrictions(string owner, string name, string branch, BranchProtectionTeamCollection teams) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNullOrEmptyString(branch, "branch"); Ensure.ArgumentNotNull(teams, "teams"); return(_client.AddProtectedBranchTeamRestrictions(owner, name, branch, teams).ToObservable().SelectMany(x => x)); }
public async Task AddsProtectedBranchTeamRestrictionsForOrgRepo() { var repoOwner = _orgRepoContext.RepositoryContext.RepositoryOwner; var repoName = _orgRepoContext.RepositoryContext.RepositoryName; // Grant team push access to repo await _github.Organization.Team.AddRepository( _contextOrgTeam2.TeamId, repoOwner, repoName, new RepositoryPermissionRequest(Permission.Push)); var newTeam = new BranchProtectionTeamCollection() { _contextOrgTeam2.TeamName }; var restrictions = await _client.AddProtectedBranchTeamRestrictions(repoOwner, repoName, "master", newTeam); Assert.NotNull(restrictions); Assert.Equal(2, restrictions.Count); }