Beispiel #1
0
        /// <summary>
        /// Replace 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/#replace-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</param>
        public IObservable <User> UpdateProtectedBranchUserRestrictions(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.UpdateProtectedBranchUserRestrictions(owner, name, branch, users).ToObservable().SelectMany(x => x));
        }
        public async Task UpdatesProtectedBranchUserRestrictionsForOrgRepo()
        {
            var repoOwner = _orgRepoContext.RepositoryContext.RepositoryOwner;
            var repoName  = _orgRepoContext.RepositoryContext.RepositoryName;
            var newUser   = new BranchProtectionUserCollection()
            {
                _github.User.Current().Result.Login
            };

            var restrictions = await _client.UpdateProtectedBranchUserRestrictions(repoOwner, repoName, "master", newUser);

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