示例#1
0
        /// <summary>
        /// Update the branch protection settings for the specified branch
        /// </summary>
        /// <remarks>
        /// See the <a href="https://developer.github.com/v3/repos/branches/#update-branch-protection">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="update">Branch protection settings</param>
        public IObservable <BranchProtectionSettings> UpdateBranchProtection(string owner, string name, string branch, BranchProtectionSettingsUpdate update)
        {
            Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
            Ensure.ArgumentNotNullOrEmptyString(name, "name");
            Ensure.ArgumentNotNullOrEmptyString(branch, "branch");
            Ensure.ArgumentNotNull(update, "update");

            return(_client.UpdateBranchProtection(owner, name, branch, update).ToObservable());
        }
示例#2
0
        public async Task UpdatesBranchProtection()
        {
            var repoOwner = _userRepoContext.RepositoryOwner;
            var repoName  = _userRepoContext.RepositoryName;
            var update    = new BranchProtectionSettingsUpdate(
                new BranchProtectionRequiredStatusChecksUpdate(false, false, new[] { "new" }));

            var protection = await _client.UpdateBranchProtection(repoOwner, repoName, "master", update);

            Assert.False(protection.RequiredStatusChecks.IncludeAdmins);
            Assert.False(protection.RequiredStatusChecks.Strict);
            Assert.Equal(1, protection.RequiredStatusChecks.Contexts.Count);

            Assert.Null(protection.Restrictions);
        }