mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-05-28 08:58:37 +00:00
Add BranchProtection.EnforceAdmins object (#1598)
* Add BranchProtection.EnforceAdmins object * Add EnforceAdmin related methods to RepoBranch clients * Add unit tests * Add unit tests for Observable client * Add integration tests for enforce admin methods * Tweak integration test to ensure that they actually do something The `CreateRepositoryWithProtectedBranch` helper method currently sets `EnforceAdmins` as true, so delete it before adding. * add missing docs * rename tests * Add missing ctor * Remove property that is no longer supported https://developer.github.com/changes/2017-05-02-adoption-of-admin-enforced/ * Fix failing unit tests
This commit is contained in:
committed by
Ryan Gribble
parent
73feecefb3
commit
58ba2eccf9
@@ -16,6 +16,17 @@ namespace Octokit
|
||||
[DebuggerDisplay("{DebuggerDisplay,nq}")]
|
||||
public class BranchProtectionSettingsUpdate
|
||||
{
|
||||
/// <summary>
|
||||
/// Create a BranchProtection update request
|
||||
/// </summary>
|
||||
/// <param name="enforceAdmins">Specifies whether the protections applied to this branch also apply to repository admins</param>
|
||||
public BranchProtectionSettingsUpdate(bool enforceAdmins)
|
||||
{
|
||||
EnforceAdmins = enforceAdmins;
|
||||
RequiredStatusChecks = null;
|
||||
Restrictions = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a BranchProtection update request
|
||||
/// </summary>
|
||||
@@ -26,17 +37,34 @@ namespace Octokit
|
||||
Restrictions = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a BranchProtection update request
|
||||
/// </summary>
|
||||
/// <param name="restrictions">Specifies the requested push access restrictions (applies only to Organization owned repositories). Pass null to disable push access restrictions</param>
|
||||
public BranchProtectionSettingsUpdate(BranchProtectionPushRestrictionsUpdate restrictions)
|
||||
{
|
||||
RequiredStatusChecks = null;
|
||||
Restrictions = restrictions;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a BranchProtection update request
|
||||
/// </summary>
|
||||
/// <param name="requiredStatusChecks">Specifies the requested status check settings. Pass null to disable status checks</param>
|
||||
/// <param name="restrictions">Specifies the requested push access restrictions (applies only to Organization owned repositories). Pass null to disable push access restrictions</param>
|
||||
public BranchProtectionSettingsUpdate(BranchProtectionRequiredStatusChecksUpdate requiredStatusChecks, BranchProtectionPushRestrictionsUpdate restrictions)
|
||||
/// <param name="enforceAdmins">Specifies whether the protections applied to this branch also apply to repository admins</param>
|
||||
public BranchProtectionSettingsUpdate(BranchProtectionRequiredStatusChecksUpdate requiredStatusChecks, BranchProtectionPushRestrictionsUpdate restrictions, bool enforceAdmins)
|
||||
{
|
||||
RequiredStatusChecks = requiredStatusChecks;
|
||||
Restrictions = restrictions;
|
||||
EnforceAdmins = enforceAdmins;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Specifies whether the protections applied to this branch also apply to repository admins
|
||||
/// </summary>
|
||||
public bool EnforceAdmins { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Status check settings for the protected branch
|
||||
/// </summary>
|
||||
@@ -54,9 +82,10 @@ namespace Octokit
|
||||
get
|
||||
{
|
||||
return string.Format(CultureInfo.InvariantCulture,
|
||||
"StatusChecks: {0} Restrictions: {1}",
|
||||
"StatusChecks: {0} Restrictions: {1} EnforceAdmins: {2}",
|
||||
RequiredStatusChecks == null ? "disabled" : RequiredStatusChecks.DebuggerDisplay,
|
||||
Restrictions == null ? "disabled" : Restrictions.DebuggerDisplay);
|
||||
Restrictions == null ? "disabled" : Restrictions.DebuggerDisplay,
|
||||
EnforceAdmins);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -70,21 +99,14 @@ namespace Octokit
|
||||
/// <summary>
|
||||
/// Status check settings for branch protection
|
||||
/// </summary>
|
||||
/// <param name="includeAdmins">Enforce required status checks for repository administrators</param>
|
||||
/// <param name="strict">Require branches to be up to date before merging</param>
|
||||
/// <param name="contexts">Require status checks to pass before merging</param>
|
||||
public BranchProtectionRequiredStatusChecksUpdate(bool includeAdmins, bool strict, IReadOnlyList<string> contexts)
|
||||
public BranchProtectionRequiredStatusChecksUpdate(bool strict, IReadOnlyList<string> contexts)
|
||||
{
|
||||
IncludeAdmins = includeAdmins;
|
||||
Strict = strict;
|
||||
Contexts = contexts;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enforce required status checks for repository administrators
|
||||
/// </summary>
|
||||
public bool IncludeAdmins { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Require branches to be up to date before merging
|
||||
/// </summary>
|
||||
@@ -99,7 +121,7 @@ namespace Octokit
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Format(CultureInfo.InvariantCulture, "IncludeAdmins: {0} Strict: {1} Contexts: {2}", IncludeAdmins, Strict, Contexts == null ? "" : String.Join(",", Contexts));
|
||||
return string.Format(CultureInfo.InvariantCulture, "Strict: {0} Contexts: {1}", Strict, Contexts == null ? "" : string.Join(",", Contexts));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user