Exemplo n.º 1
0
        /// <summary>
        /// Replace 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/#replace-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> UpdateProtectedBranchTeamRestrictions(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.UpdateProtectedBranchTeamRestrictions(owner, name, branch, teams).ToObservable().SelectMany(x => x));
        }
        public async Task UpdatesProtectedBranchTeamRestrictionsForOrgRepo()
        {
            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.UpdateProtectedBranchTeamRestrictions(repoOwner, repoName, "master", newTeam);

            Assert.NotNull(restrictions);
            Assert.Equal(_contextOrgTeam2.TeamName, restrictions[0].Name);
        }