Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protected Branches updates - main methods #1441

Merged
merged 15 commits into from
Aug 29, 2016

Conversation

ryangribble
Copy link
Contributor

@ryangribble ryangribble commented Aug 10, 2016

Closes #1407

The updates to Protected Branches preview API added a significant number of new endpoints allowing granularity in setting each segment of the branch protection settings separately.

For an MVP (Minimum Viable Product) approach, this PR implements only the top level methods, which will enable octokit.net users to manage all aspects of BranchProtection from that top level. If there is need/desire, the other more granular methods can be added in separate PRs

This PR implements the following methods:

    Task<BranchProtectionSettings> GetBranchProtection(string owner, string name, string branch);
    Task<BranchProtectionSettings> GetBranchProtection(int repositoryId, string branch);
    Task<BranchProtectionSettings> UpdateBranchProtection(string owner, string name, string branch, BranchProtectionSettingsUpdate update);
    Task<BranchProtectionSettings> UpdateBranchProtection(int repositoryId, string branch, BranchProtectionSettingsUpdate update);
    Task<bool> DeleteBranchProtection(string owner, string name, string branch);
    Task<bool> DeleteBranchProtection(int repositoryId, string branch);
  • RepositoryBranchesClient
  • Unit Tests
  • Integration Tests
  • ObservableRepositoryBranchesClient
  • Unit Tests for Observable client

So far only non reactive client and unit tests
…pdate request that doesnt take a restrictions parameter
- fix Update method PUT parameters
- add [SerializeNull] to various request fields
- fix deserialize problem with ProtectedBranchRestrictions ctor not being public
- tidy up DebuggerDisplay output
…eRepositoryBranchesClient

Add unit tests for Observable methods
@ryangribble ryangribble changed the title Protected Branches preview v2 MVP Protected Branches updaets - main methods Aug 10, 2016
}

[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class BranchProtectionRequiredStatusChecks
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

XMLDocs for consistency?

@hnrkndrssn
Copy link
Contributor

Apart from (possibly) a couple of missing XMLDocs, the code looks good to me 👍

@ryangribble ryangribble changed the title Protected Branches updaets - main methods Protected Branches updates - main methods Aug 10, 2016
@hnrkndrssn
Copy link
Contributor

Looks good to me!

@ryangribble
Copy link
Contributor Author

@shiftkey let me know if you want to 👀 this over or if you're happy for me to merge based on @alfhenrik's review

@@ -23,6 +25,9 @@ public class TheGetAllMethod
{
Assert.NotNull(branch.Protection);
}

// Ensure Protected attribute is deserialized (at least master branch should be true)
Assert.True(branches.Any(x => x.Protected));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we make this test assert the state of master and 🔥 this comment?

@shiftkey
Copy link
Member

@ryangribble just gave it a look over, a few little comments but nothing serious

👍 merge at your leisure

@shiftkey shiftkey mentioned this pull request Aug 15, 2016
10 tasks
@ryangribble
Copy link
Contributor Author

Ive fixed the comments and 💄 just waiting for any suggestions on that comment regarding a nicer ctor. But otherwise this can be merged

Change team and user lists to specific classes derived from Collection<T> so we can offer better configuration of BranchProtectionPushRestriction via multiple ctors (teams only, users only, teams and users, etc)
Add another ctor to BranchProtectionPushRestrictions for the case where no teams/users are specified (ie admin only)
Change organization update tests to use this new ctor and assert we get empty lists rather than no push restrictions
@ryangribble
Copy link
Contributor Author

ryangribble commented Aug 25, 2016

OK ive implemented the user and team push restrictions settings be classes derived from Collection<string> which means we can now offer nicer ctors to better configure those options, rather than having to pass empty arrays etc

// Only admins can push
new BranchProtectionPushRestrictionsUpdate();

// Specify some teams that can push
new BranchProtectionPushRestrictionsUpdate(
    new BranchProtectionTeamCollection { "my-team1", "my-team2" });

// specify some users that can push
new BranchProtectionPushRestrictionsUpdate(
    new BranchProtectionUserCollection { "user1", "user2" });

// spceify both teams AND users that can push
new BranchProtectionPushRestrictionsUpdate(
    new BranchProtectionTeamCollection { "my-team1", "my-team2" },
    new BranchProtectionUserCollection { "user1", "user2" });

@ryangribble
Copy link
Contributor Author

ryangribble commented Aug 25, 2016

Also I realise some of the names are pretty verbose (eg BranchProtectionRequiredStatusChecks) but that's because most of the simpler names (eg RequiredStatusChecks) are still taken by the previous implementation which we've flagged as [Obsolete] but still need to keep around for another release or 2...

@shiftkey
Copy link
Member

@ryangribble that all seems great ✨

@shiftkey shiftkey merged commit 4808941 into octokit:master Aug 29, 2016
@ryangribble ryangribble deleted the protected-branches-v2 branch August 30, 2016 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants