From b4d86d07dcce428f2513c0722e2101a26663f5e4 Mon Sep 17 00:00:00 2001 From: Sarmad Date: Sun, 7 Feb 2016 19:15:31 +0500 Subject: [PATCH 1/4] added new parameters to RepositoryRequest.cs --- Octokit/Models/Request/RepositoryRequest.cs | 84 +++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/Octokit/Models/Request/RepositoryRequest.cs b/Octokit/Models/Request/RepositoryRequest.cs index f22b881fa6..7806171f56 100644 --- a/Octokit/Models/Request/RepositoryRequest.cs +++ b/Octokit/Models/Request/RepositoryRequest.cs @@ -37,6 +37,24 @@ public class RepositoryRequest : RequestParameters /// public SortDirection Direction { get; set; } + /// + /// Gets or sets the visibility property. + /// + /// + /// The public. + /// + + public RepositoryVisibility Visibility { get; set; } + + /// + /// Gets or sets the affiliation property. + /// + /// + /// The owner. + /// + + public RepositoryAffiliation Affiliation { get; set; } + internal string DebuggerDisplay { get @@ -103,4 +121,70 @@ public enum RepositorySort [Parameter(Value = "full_name")] FullName } + + + public enum RepositoryVisibility + { + /// + /// Returns only public repositories + /// + Public, + + /// + /// Returns only private repositories + /// + Private, + + /// + /// Return both public and private repositories + /// + All, + + } + + + public enum RepositoryAffiliation + { + /// + /// Repositories that are owned by the authenticated user + /// + Owner, + + /// + /// Repositories that the user has been added to as a collaborator. + /// + Collaborator, + + /// + /// Repositories that the user has access to through being a member of an organization. + /// This includes every repository on every team that the user is on. + /// + [Parameter(Value = "organization_member")] + OrganizationMember, + + /// + /// Return repositories that are owned by authenticated user and added to as a collaborator. + /// + [Parameter(Value = "owner, collaborator")] + OwnerAndCollaborator, + + /// + /// Return repositories that are owned by authenticated user and user is a member of organization. + /// + [Parameter(Value = "owner, organization_member")] + OwnerAndOrganizationMember, + + /// + /// Return repositories that user has been added as collaborator and user is a member of organization. + /// + [Parameter(Value = "collaborator, organization_member")] + CollaboratorAndOrganizationMember, + + /// + /// Returns all repositories where user is owner,collaborator and organization member. + /// + [Parameter(Value = "owner, collaborator, organization_member")] + All + + } } From 30553d34e366e4c1e3fa43ecc53861f035e52674 Mon Sep 17 00:00:00 2001 From: Sarmad Date: Sun, 7 Feb 2016 21:04:17 +0500 Subject: [PATCH 2/4] fixed some typo and formatting issues --- Octokit/Models/Request/RepositoryRequest.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Octokit/Models/Request/RepositoryRequest.cs b/Octokit/Models/Request/RepositoryRequest.cs index 7806171f56..0c44a2f1f5 100644 --- a/Octokit/Models/Request/RepositoryRequest.cs +++ b/Octokit/Models/Request/RepositoryRequest.cs @@ -41,19 +41,17 @@ public class RepositoryRequest : RequestParameters /// Gets or sets the visibility property. /// /// - /// The public. + /// The no. /// - public RepositoryVisibility Visibility { get; set; } /// - /// Gets or sets the affiliation property. + /// Gets or sets The affiliation property. /// /// /// The owner. /// - - public RepositoryAffiliation Affiliation { get; set; } + public RepositoryAffiliation Affiliation { get; set; } internal string DebuggerDisplay { @@ -169,19 +167,19 @@ public enum RepositoryAffiliation OwnerAndCollaborator, /// - /// Return repositories that are owned by authenticated user and user is a member of organization. + /// Return repositories that are owned by authenticated user or user is a organization member. /// [Parameter(Value = "owner, organization_member")] OwnerAndOrganizationMember, /// - /// Return repositories that user has been added as collaborator and user is a member of organization. + /// Return repositories that user has been added as collaborator or user is a organization member. /// [Parameter(Value = "collaborator, organization_member")] CollaboratorAndOrganizationMember, /// - /// Returns all repositories where user is owner,collaborator and organization member. + /// Returns all repositories where user is owner,collaborator or organization member. /// [Parameter(Value = "owner, collaborator, organization_member")] All From d7cb5620feeb588109c2f7ebbca79937d4745258 Mon Sep 17 00:00:00 2001 From: Sarmad Date: Mon, 8 Feb 2016 16:22:41 +0500 Subject: [PATCH 3/4] fixed typo and improved formatting in comments --- Octokit/Models/Request/RepositoryRequest.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Octokit/Models/Request/RepositoryRequest.cs b/Octokit/Models/Request/RepositoryRequest.cs index 0c44a2f1f5..75083c97d9 100644 --- a/Octokit/Models/Request/RepositoryRequest.cs +++ b/Octokit/Models/Request/RepositoryRequest.cs @@ -41,15 +41,15 @@ public class RepositoryRequest : RequestParameters /// Gets or sets the visibility property. /// /// - /// The no. + /// The visibility. /// public RepositoryVisibility Visibility { get; set; } /// - /// Gets or sets The affiliation property. + /// Gets or sets the affiliation property. /// /// - /// The owner. + /// The affiliation. /// public RepositoryAffiliation Affiliation { get; set; } @@ -120,7 +120,9 @@ public enum RepositorySort FullName } - + /// + /// The properties that repositories can be visibled by. + /// public enum RepositoryVisibility { /// @@ -137,10 +139,11 @@ public enum RepositoryVisibility /// Return both public and private repositories /// All, - } - + /// + /// The properties that repositories can be affiliated by. + /// public enum RepositoryAffiliation { /// @@ -183,6 +186,5 @@ public enum RepositoryAffiliation /// [Parameter(Value = "owner, collaborator, organization_member")] All - } } From 2366c998a298666359d57fda6cf5f0dc0cb4756d Mon Sep 17 00:00:00 2001 From: Sarmad Date: Wed, 10 Feb 2016 04:29:43 +0500 Subject: [PATCH 4/4] added unit tests for the new-parameters-on-ListYourRepository --- .../Clients/RepositoriesClientTests.cs | 41 +++++++++++++++++++ Octokit/Helpers/UriExtensions.cs | 2 +- Octokit/Models/Request/RepositoryRequest.cs | 2 +- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/Octokit.Tests/Clients/RepositoriesClientTests.cs b/Octokit.Tests/Clients/RepositoriesClientTests.cs index 618c591b36..e74cc97b83 100644 --- a/Octokit.Tests/Clients/RepositoriesClientTests.cs +++ b/Octokit.Tests/Clients/RepositoriesClientTests.cs @@ -376,6 +376,47 @@ public void CanFilterBySortDirection() Arg.Is>(d => d["type"] == "member" && d["sort"] == "updated" && d["direction"] == "asc")); } + + [Fact] + public void CanFilterByVisibility() + { + var connection = Substitute.For(); + var client = new RepositoriesClient(connection); + + var request = new RepositoryRequest + { + Visibility = RepositoryVisibility.Private + }; + client.GetAllForCurrent(request); + + connection.Received() + .GetAll( + Arg.Is(u => u.ToString() == "user/repos"), + Arg.Is>(d => + d["visibility"] == "private")); + } + + [Fact] + public void CanFilterByAffiliation() + { + var connection = Substitute.For(); + var client = new RepositoriesClient(connection); + + var request = new RepositoryRequest + { + + Affiliation = RepositoryAffiliation.Owner, + Sort = RepositorySort.FullName + }; + + client.GetAllForCurrent(request); + + connection.Received() + .GetAll( + Arg.Is(u => u.ToString() == "user/repos"), + Arg.Is>(d => + d["affiliation"] == "owner" && d["sort"] == "full_name")); + } } public class TheGetAllForUserMethod diff --git a/Octokit/Helpers/UriExtensions.cs b/Octokit/Helpers/UriExtensions.cs index a2db9969a4..2ee1b873d6 100644 --- a/Octokit/Helpers/UriExtensions.cs +++ b/Octokit/Helpers/UriExtensions.cs @@ -10,7 +10,7 @@ namespace Octokit public static class UriExtensions { /// - /// Merge a dictionary of valeus with an existing + /// Merge a dictionary of values with an existing /// /// Original request Uri /// Collection of key-value pairs diff --git a/Octokit/Models/Request/RepositoryRequest.cs b/Octokit/Models/Request/RepositoryRequest.cs index 75083c97d9..1f5d2e8907 100644 --- a/Octokit/Models/Request/RepositoryRequest.cs +++ b/Octokit/Models/Request/RepositoryRequest.cs @@ -121,7 +121,7 @@ public enum RepositorySort } /// - /// The properties that repositories can be visibled by. + /// The properties that repositories can be visible by. /// public enum RepositoryVisibility {