Exemplo n.º 1
0
        /// <summary>
        /// Remove user restrictions for the specified branch (applies only to Organization owned repositories)
        /// </summary>
        /// <remarks>
        /// See the <a href="https://developer.github.com/v3/repos/branches/#remove-user-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="users">List of users with push access to remove</param>
        public IObservable <User> DeleteProtectedBranchUserRestrictions(string owner, string name, string branch, BranchProtectionUserCollection users)
        {
            Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
            Ensure.ArgumentNotNullOrEmptyString(name, "name");
            Ensure.ArgumentNotNullOrEmptyString(branch, "branch");
            Ensure.ArgumentNotNull(users, "users");

            return(_client.DeleteProtectedBranchUserRestrictions(owner, name, branch, users).ToObservable().SelectMany(x => x));
        }
        public async Task DeletesProtectedBranchUserRestrictionsForOrgRepo()
        {
            using (var context = await _github.CreateOrganizationRepositoryWithProtectedBranch())
            {
                var repoOwner = context.RepositoryContext.RepositoryOwner;
                var repoName  = context.RepositoryContext.RepositoryName;
                var user      = new BranchProtectionUserCollection()
                {
                    _github.User.Current().Result.Login
                };
                var restrictions = await _client.AddProtectedBranchUserRestrictions(repoOwner, repoName, "master", user);

                Assert.NotNull(restrictions);
                Assert.Equal(1, restrictions.Count);

                var deleted = await _client.DeleteProtectedBranchUserRestrictions(repoOwner, repoName, "master", user);

                Assert.NotNull(deleted);
                Assert.Equal(0, deleted.Count);
            }
        }