From 100d08850e0932a0f059176a82c62de01e197aff Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Wed, 28 Oct 2015 16:12:04 -0700 Subject: [PATCH 01/19] updated the README link --- README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 0d3daa22..c11fc88c 100644 --- a/README.md +++ b/README.md @@ -40,17 +40,17 @@ In Xamarin Studio you can find this option under the project's context menu: **A ## Documentation -Please see https://github.com/octokit/octokit.net/blob/master/docs/index.md for more detailed documentation. +Documentation is available at http://octokitnet.readthedocs.org/en/latest/. ## Build -Octokit is a single assembly designed to be easy to deploy anywhere. If you +Octokit is a single assembly designed to be easy to deploy anywhere. If you prefer to compile it yourself, you’ll need: * Visual Studio 2013, or Xamarin Studio * Windows 8 or higher to build and test the WinRT projects -To clone it locally click the "Clone in Windows" button above or run the +To clone it locally click the "Clone in Windows" button above or run the following git commands. ``` @@ -61,7 +61,7 @@ cd Octokit ## Contribute -Visit the [Contributor Guidelines](https://github.com/octokit/octokit.net/blob/master/CONTRIBUTING.md) +Visit the [Contributor Guidelines](https://github.com/octokit/octokit.net/blob/master/CONTRIBUTING.md) for more details. ## Build Server @@ -70,9 +70,9 @@ The builds and tests for Octokit.net are run on [AppVeyor](http://www.appveyor.c ## Problems? -Octokit is 100% certified to be bug free. If you find an issue with our -certification, please visit the [issue tracker](https://github.com/octokit/octokit.net/issues) -and report the issue. +Octokit is 100% certified to be bug free. If you find an issue with our +certification, please visit the [issue tracker](https://github.com/octokit/octokit.net/issues) +and report the issue. Please be kind and search to see if the issue is already logged before creating a new one. If you're pressed for time, log it anyways. @@ -84,12 +84,12 @@ When creating an issue, clearly explain * What actually happened. * Steps to reproduce the problem. -Also include any other information you think is relevant to reproduce the +Also include any other information you think is relevant to reproduce the problem. ## Related Projects - - [ScriptCs.OctoKit](https://github.com/alfhenrik/ScriptCs.OctoKit) - a script pack to use Octokit in scriptcs + - [ScriptCs.OctoKit](https://github.com/alfhenrik/ScriptCs.OctoKit) - a script pack to use Octokit in scriptcs ## Copyright and License From 31b93dd6fa807b20ee605120b0f560a43ab986ee Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Wed, 28 Oct 2015 19:36:05 -0700 Subject: [PATCH 02/19] sketching out a simple site layout using existing docs --- mkdocs.yml | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 mkdocs.yml diff --git a/mkdocs.yml b/mkdocs.yml new file mode 100644 index 00000000..07923b4e --- /dev/null +++ b/mkdocs.yml @@ -0,0 +1,38 @@ +site_name: Octokit.net Documentation +site_description: A GitHub API client for .NET + +dev_addr: '0.0.0.0:8000' + +repo_url: https://github.com/octokit/octokit.net/ + +docs_dir: docs/ +site_dir: docs/_build/ + +theme: readthedocs +#theme_dir: ./theme/mkdocs/ +#theme_center_lead: false + +pages: + +- Home : 'index.md' + +- Getting Started : + - 'Creating a GitHubClient' : 'getting-started.md' + +- Features: + - 'Issues' : 'issues.md' + - 'Labels' : 'labels.md' + - 'Milestones' : 'milestones.md' + - 'Releases' : 'releases.md' + - 'Search' : 'search.md' + - 'Git Database' : 'git-database.md' + +- Advanced: + - 'Debugging from Source': 'debugging-source.md' + - 'OAuth Flow': 'oauth-flow.md' + - 'HttpClient': 'http-client.md' + + +- Contributing: + - 'Shipping Releases' : 'shipping-releases.md' + - 'Strong Naming' : 'strong-naming.md' From 785138dfe7db48625fbaee4a5ce0eb9f06f55767 Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Wed, 28 Oct 2015 19:36:29 -0700 Subject: [PATCH 03/19] bump gitignore --- .gitignore | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index d053335d..86a7c29d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ # Windows image file caches -Thumbs.db +Thumbs.db # Folder config file Desktop.ini @@ -82,4 +82,7 @@ tools/xunit.runner.console # New VS Test Runner creates arbitrary folders with PDBs *.pdb -pingme.txt \ No newline at end of file +pingme.txt + +# ReadTheDocs build output +docs/_build From cf8fbd05ade370d2001fb0a73d849595fa204d5e Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Wed, 28 Oct 2015 19:49:52 -0700 Subject: [PATCH 04/19] indenting is whitespace specific ew --- mkdocs.yml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/mkdocs.yml b/mkdocs.yml index 07923b4e..2a16b26f 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: Octokit.net Documentation +site_name : Octokit.net Documentation site_description: A GitHub API client for .NET dev_addr: '0.0.0.0:8000' @@ -13,10 +13,9 @@ theme: readthedocs #theme_center_lead: false pages: +- 'Home' : 'index.md' -- Home : 'index.md' - -- Getting Started : +- 'Getting Started' : - 'Creating a GitHubClient' : 'getting-started.md' - Features: @@ -32,7 +31,6 @@ pages: - 'OAuth Flow': 'oauth-flow.md' - 'HttpClient': 'http-client.md' - - Contributing: - - 'Shipping Releases' : 'shipping-releases.md' - - 'Strong Naming' : 'strong-naming.md' + - 'Shipping Releases' : 'shipping-releases.md' + - 'Strong Naming' : 'strong-naming.md' From 03a1d16bd6623345d4fec22c5a1306c5b0e31af9 Mon Sep 17 00:00:00 2001 From: Haroon Date: Thu, 29 Oct 2015 15:53:08 +0000 Subject: [PATCH 05/19] Searching repos --- docs/search.md | 74 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 71 insertions(+), 3 deletions(-) diff --git a/docs/search.md b/docs/search.md index c8cd57e5..f8f9a831 100644 --- a/docs/search.md +++ b/docs/search.md @@ -115,11 +115,79 @@ var request = new SearchIssuesRequest("linux") }; ``` - - ## Search Repositories -**TODO** +Finding repositories via various criteria. + +```csharp +// Initialize a new instance of the SearchRepositoriesRequest class +var request = new SearchRepositoriesRequest(); + +// you can also specify a search term here +var request = new SearchRepositoriesRequest("bootstrap"); +``` + +Now we can further filter our search. + +```csharp +var request = new SearchRepositoriesRequest("mvc client side framework") +{ + // lets find a library with over 1k stars + Stars = Range.GreaterThan(1000); + + // we can specify how big we want the repo to be in kilobytes + Size = Range.GreaterThan(1); + + // maybe we want the library to have over 50 forks? + Forks = Range.GreaterThan(50); + + // we may want to include or exclude the forks too + Fork = ForkQualifier.IncludeForks; + + // how about we restrict the language the library is written in? + Language = Language.JavaScript; + + // maybe we want to include searching in the read me? + In = new[] { InQualifier.Readme }; + + // how about only the name of the project? + In = new[] { InQualifier.Name }; + + // or search the readme, name or description? + In = new[] { InQualifier.Readme, InQualifier.Description, InQualifier.Name }; + + // how about searching for libraries created before a given date? + Created = DateRange.GreaterThan(new DateTime(2015, 1, 1)); + + // or after a given date? + Created = DateRange.LessThan(new DateTime(2015, 1, 1)); + + // or maybe the last time this repo was updated? + Updated = DateRange.GreaterThan(new DateTime(2013, 1, 1)); + + // or maybe updated between a given date? + Updated = DateRange.Between(new DateTime(2012, 4, 30), new DateTime(2012, 7, 4)); + + // we can also restrict the owner of the repo if we so wish + User = "dhh"; +}; +``` + +We can also sort our results, the default sort direction is descending + +```csharp +var request = new SearchRepositoriesRequest("mvc client side framework") +{ + // sort by the number of stars + SortField = RepoSearchSort.Stars; + + // or by forks? + SortField = RepoSearchSort.Forks; + + // how about changing that sort direction? + Order = SortDirection.Ascending; +} +```` ## Search Code From 3e1aef0c57bc4e9a22a4cd4b8ce8898b15f03ad1 Mon Sep 17 00:00:00 2001 From: Haroon Date: Thu, 29 Oct 2015 16:13:51 +0000 Subject: [PATCH 06/19] Fix those code blocks --- docs/search.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/search.md b/docs/search.md index f8f9a831..78e45c51 100644 --- a/docs/search.md +++ b/docs/search.md @@ -187,7 +187,7 @@ var request = new SearchRepositoriesRequest("mvc client side framework") // how about changing that sort direction? Order = SortDirection.Ascending; } -```` +``` ## Search Code From c249e0c535905bea592d02bfd94f96e4e63b5f00 Mon Sep 17 00:00:00 2001 From: Haroon Date: Thu, 29 Oct 2015 16:15:52 +0000 Subject: [PATCH 07/19] syntax fixes --- docs/search.md | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/docs/search.md b/docs/search.md index 78e45c51..6c585089 100644 --- a/docs/search.md +++ b/docs/search.md @@ -133,43 +133,43 @@ Now we can further filter our search. var request = new SearchRepositoriesRequest("mvc client side framework") { // lets find a library with over 1k stars - Stars = Range.GreaterThan(1000); + Stars = Range.GreaterThan(1000), // we can specify how big we want the repo to be in kilobytes - Size = Range.GreaterThan(1); + Size = Range.GreaterThan(1), // maybe we want the library to have over 50 forks? - Forks = Range.GreaterThan(50); + Forks = Range.GreaterThan(50), // we may want to include or exclude the forks too - Fork = ForkQualifier.IncludeForks; + Fork = ForkQualifier.IncludeForks, // how about we restrict the language the library is written in? - Language = Language.JavaScript; + Language = Language.JavaScript, // maybe we want to include searching in the read me? - In = new[] { InQualifier.Readme }; + In = new[] { InQualifier.Readme }, // how about only the name of the project? - In = new[] { InQualifier.Name }; + In = new[] { InQualifier.Name }, // or search the readme, name or description? - In = new[] { InQualifier.Readme, InQualifier.Description, InQualifier.Name }; + In = new[] { InQualifier.Readme, InQualifier.Description, InQualifier.Name }, // how about searching for libraries created before a given date? - Created = DateRange.GreaterThan(new DateTime(2015, 1, 1)); + Created = DateRange.GreaterThan(new DateTime(2015, 1, 1)), // or after a given date? - Created = DateRange.LessThan(new DateTime(2015, 1, 1)); + Created = DateRange.LessThan(new DateTime(2015, 1, 1)), // or maybe the last time this repo was updated? - Updated = DateRange.GreaterThan(new DateTime(2013, 1, 1)); + Updated = DateRange.GreaterThan(new DateTime(2013, 1, 1)), // or maybe updated between a given date? - Updated = DateRange.Between(new DateTime(2012, 4, 30), new DateTime(2012, 7, 4)); + Updated = DateRange.Between(new DateTime(2012, 4, 30), new DateTime(2012, 7, 4)), // we can also restrict the owner of the repo if we so wish - User = "dhh"; + User = "dhh" }; ``` @@ -179,13 +179,13 @@ We can also sort our results, the default sort direction is descending var request = new SearchRepositoriesRequest("mvc client side framework") { // sort by the number of stars - SortField = RepoSearchSort.Stars; + SortField = RepoSearchSort.Stars, // or by forks? - SortField = RepoSearchSort.Forks; + SortField = RepoSearchSort.Forks, // how about changing that sort direction? - Order = SortDirection.Ascending; + Order = SortDirection.Ascending } ``` From 812f4a11810297e6941e8a90e7653bc44b4262f8 Mon Sep 17 00:00:00 2001 From: Haroon Date: Fri, 30 Oct 2015 21:03:17 +0000 Subject: [PATCH 08/19] Some minor amendments --- docs/search.md | 37 ++++++++++++++----------------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/docs/search.md b/docs/search.md index 6c585089..e859cf6b 100644 --- a/docs/search.md +++ b/docs/search.md @@ -134,40 +134,31 @@ var request = new SearchRepositoriesRequest("mvc client side framework") { // lets find a library with over 1k stars Stars = Range.GreaterThan(1000), - + // we can specify how big we want the repo to be in kilobytes Size = Range.GreaterThan(1), - + // maybe we want the library to have over 50 forks? Forks = Range.GreaterThan(50), - + // we may want to include or exclude the forks too Fork = ForkQualifier.IncludeForks, - + // how about we restrict the language the library is written in? Language = Language.JavaScript, - + // maybe we want to include searching in the read me? In = new[] { InQualifier.Readme }, - - // how about only the name of the project? - In = new[] { InQualifier.Name }, - - // or search the readme, name or description? + + // or go all out and search the readme, name or description? In = new[] { InQualifier.Readme, InQualifier.Description, InQualifier.Name }, - - // how about searching for libraries created before a given date? + + // how about searching for libraries created after a given date? Created = DateRange.GreaterThan(new DateTime(2015, 1, 1)), - - // or after a given date? - Created = DateRange.LessThan(new DateTime(2015, 1, 1)), - - // or maybe the last time this repo was updated? - Updated = DateRange.GreaterThan(new DateTime(2013, 1, 1)), - - // or maybe updated between a given date? + + // or maybe check for repos that have been updated between a given date range? Updated = DateRange.Between(new DateTime(2012, 4, 30), new DateTime(2012, 7, 4)), - + // we can also restrict the owner of the repo if we so wish User = "dhh" }; @@ -180,10 +171,10 @@ var request = new SearchRepositoriesRequest("mvc client side framework") { // sort by the number of stars SortField = RepoSearchSort.Stars, - + // or by forks? SortField = RepoSearchSort.Forks, - + // how about changing that sort direction? Order = SortDirection.Ascending } From 472f2535b7b1f21236cfe77fd5035f83ddfcc955 Mon Sep 17 00:00:00 2001 From: Haroon Date: Fri, 30 Oct 2015 21:30:15 +0000 Subject: [PATCH 09/19] How do we use the searchRepos --- docs/search.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/search.md b/docs/search.md index e859cf6b..779d9135 100644 --- a/docs/search.md +++ b/docs/search.md @@ -117,9 +117,12 @@ var request = new SearchIssuesRequest("linux") ## Search Repositories -Finding repositories via various criteria. +To search for repositories using Octokit you need to create a ```SearchRepositoriesRequest``` and populate it with the search criteria. ```csharp +// Use your github client to search for repos by passing in a SearchRepositoriesRequest instance +var result = githubClient.Search.SearchRepo(request); + // Initialize a new instance of the SearchRepositoriesRequest class var request = new SearchRepositoriesRequest(); From f8379c725262b9b50e8b0f99c8964bdf686a5262 Mon Sep 17 00:00:00 2001 From: Haroon Date: Fri, 30 Oct 2015 21:44:54 +0000 Subject: [PATCH 10/19] Move things around a bit --- docs/search.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/search.md b/docs/search.md index 779d9135..42cd602b 100644 --- a/docs/search.md +++ b/docs/search.md @@ -120,14 +120,13 @@ var request = new SearchIssuesRequest("linux") To search for repositories using Octokit you need to create a ```SearchRepositoriesRequest``` and populate it with the search criteria. ```csharp -// Use your github client to search for repos by passing in a SearchRepositoriesRequest instance -var result = githubClient.Search.SearchRepo(request); - // Initialize a new instance of the SearchRepositoriesRequest class var request = new SearchRepositoriesRequest(); // you can also specify a search term here var request = new SearchRepositoriesRequest("bootstrap"); + +var result = await githubClient.Search.SearchRepo(request); ``` Now we can further filter our search. From 44efdc902c471e5add5374281cadb845f5f2d13e Mon Sep 17 00:00:00 2001 From: Haroon Date: Fri, 30 Oct 2015 21:45:44 +0000 Subject: [PATCH 11/19] :lipstick: --- docs/search.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/search.md b/docs/search.md index 42cd602b..34b3f1d5 100644 --- a/docs/search.md +++ b/docs/search.md @@ -117,7 +117,7 @@ var request = new SearchIssuesRequest("linux") ## Search Repositories -To search for repositories using Octokit you need to create a ```SearchRepositoriesRequest``` and populate it with the search criteria. +To search for repositories using Octokit you need to create a `SearchRepositoriesRequest` and populate it with the search criteria. ```csharp // Initialize a new instance of the SearchRepositoriesRequest class From d5e69e32fc7911a7ea72146fb3c88db6739e4a11 Mon Sep 17 00:00:00 2001 From: Haroon Date: Fri, 30 Oct 2015 23:13:08 +0000 Subject: [PATCH 12/19] Searching users docs --- docs/search.md | 50 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/docs/search.md b/docs/search.md index 34b3f1d5..e4bf92e0 100644 --- a/docs/search.md +++ b/docs/search.md @@ -188,4 +188,52 @@ var request = new SearchRepositoriesRequest("mvc client side framework") ## Search Users -**TODO** +To search for users using Octokit you need to create a SearchUsersRequest and populate it with the search criteria. + +```csharp +// Initialize a new instance of the SearchUsersRequest class with a search term +var request = new SearchUsersRequest("dhh"); + +var result = await githubClient.Search.SearchUsers(request); +``` + +Now we can further filter our search. + +```csharp +var request = new SearchUsersRequest("dhh") +{ + // lets find user with over 1k followers + Followers = Range.GreaterThan(1000), + + // find a user created after the date + Created = DateRange.GreaterThan(new DateTime(2015, 1, 1)), + + // we can search the location of a user, found a martian anyone? + Location = "Mars", + + // find a user that has over 100 repos + Repositories = Range.GreaterThan(100), + + // how about we find users that have a repo that match a certain language + Language = Language.JavaScript, + + // we may want to restrict to orgs or users only + AccountType = AccountSearchType.Org, + + // maybe we want to peek the username only? + In = new[] { UserInQualifier.Username }, + + // or go all out and search username, email and fullname? + In = new[] { UserInQualifier.Username, UserInQualifier.Email, UserInQualifier.Fullname }, +}; +``` + +We can also sort our results, by Followers, Repositories, Joined or leave as null for best match. + +```csharp +var request = new SearchUsersRequest("dhh") +{ + // sort by the number of followers + SortField = UsersSearchSort.Followers +} +``` From 93393b199687915580abd41f19b8dae46e0d3fb2 Mon Sep 17 00:00:00 2001 From: Haroon Date: Sat, 31 Oct 2015 10:59:51 +0000 Subject: [PATCH 13/19] :lipstick: --- docs/search.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/search.md b/docs/search.md index e4bf92e0..6b6cd22a 100644 --- a/docs/search.md +++ b/docs/search.md @@ -188,7 +188,7 @@ var request = new SearchRepositoriesRequest("mvc client side framework") ## Search Users -To search for users using Octokit you need to create a SearchUsersRequest and populate it with the search criteria. +To search for users using Octokit you need to create a `SearchUsersRequest` and populate it with the search criteria. ```csharp // Initialize a new instance of the SearchUsersRequest class with a search term From 3f6297ae5aa2be28189b4eada5fdbf1bfbe5fb06 Mon Sep 17 00:00:00 2001 From: Haroon Date: Sat, 31 Oct 2015 22:08:49 +0000 Subject: [PATCH 14/19] Prepping searching code doc --- docs/search.md | 56 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/docs/search.md b/docs/search.md index 6b6cd22a..00686b75 100644 --- a/docs/search.md +++ b/docs/search.md @@ -184,7 +184,61 @@ var request = new SearchRepositoriesRequest("mvc client side framework") ## Search Code -**TODO** +To search for code using Octokit you need to create a `SearchCodeRequest` and populate it with the search criteria. + +```csharp +// Initialize a new instance of the SearchCodeRequest class with a search term +var request = new SearchCodeRequest("auth"); + +// Or we can restrict the search to a specific repo +var request = new SearchCodeRequest("auth", "dhh", "rails"); + +var result = await githubClient.Search.SearchCode(request); +``` + +Now we can further filter our search. + +```csharp +var request = new SearchCodeRequest("auth") +{ + // maybe we want to restrict the search to the file only + In = new[] { CodeInQualifier.File }, + + // or we can search the file and the path too + In = new[] { CodeInQualifier.File, CodeInQualifier.Path }, + + // how about we find a file based on a certain language + Language = Language.JavaScript, + + // do we want to search forks too? + Forks = true, + + // find files that are above 1000 bytes + Size = Range.GreaterThan(1000), + + // we may want to restrict the search to the path of a file + Path = "app/assets", + + // we may want to restrict the file based on file extension + Extension = "json", + + // restrict search to a specific file name + FileName = "app.json", + + // search within a users or orgs repo + User = "dhh" +}; +``` + +We can also sort our results by indexed or leave as null for best match. + +```csharp +var request = new SearchCodeRequest("dhh") +{ + // sort by last indexed + SortField = CodeSearchSort.Indexed +} +``` ## Search Users From 538b33bba10bb7f2d1a0fa2d4d11cb1b9b50f9b8 Mon Sep 17 00:00:00 2001 From: Haroon Date: Tue, 3 Nov 2015 21:11:45 +0000 Subject: [PATCH 15/19] :lipstick: --- docs/search.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/docs/search.md b/docs/search.md index 00686b75..a3536579 100644 --- a/docs/search.md +++ b/docs/search.md @@ -201,10 +201,7 @@ Now we can further filter our search. ```csharp var request = new SearchCodeRequest("auth") { - // maybe we want to restrict the search to the file only - In = new[] { CodeInQualifier.File }, - - // or we can search the file and the path too + // we can restrict search to the file, path or search both In = new[] { CodeInQualifier.File, CodeInQualifier.Path }, // how about we find a file based on a certain language From 5ca6633cb133ca8db4f2be17c2ebb0e26a446d64 Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Wed, 27 Jan 2016 12:35:38 +1030 Subject: [PATCH 16/19] fix up impacted test --- Octokit.Tests/Clients/RepositoryPagesClientTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Octokit.Tests/Clients/RepositoryPagesClientTests.cs b/Octokit.Tests/Clients/RepositoryPagesClientTests.cs index e783b48a..dbafeb1a 100644 --- a/Octokit.Tests/Clients/RepositoryPagesClientTests.cs +++ b/Octokit.Tests/Clients/RepositoryPagesClientTests.cs @@ -17,7 +17,7 @@ namespace Octokit.Tests.Clients client.Get("fake", "repo"); - connection.Received().Get(Arg.Is(u => u.ToString() == "repos/fake/repo/pages"), null); + connection.Received().Get(Arg.Is(u => u.ToString() == "repos/fake/repo/pages")); } [Fact] @@ -65,7 +65,7 @@ namespace Octokit.Tests.Clients client.GetLatest("fake", "repo"); - connection.Received().Get(Arg.Is(u => u.ToString() == "repos/fake/repo/pages/builds/latest"), null); + connection.Received().Get(Arg.Is(u => u.ToString() == "repos/fake/repo/pages/builds/latest")); } [Fact] From 47e06b53005cdcb97490d051d4553df787c76595 Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Wed, 27 Jan 2016 11:37:15 +1030 Subject: [PATCH 17/19] documenting running up the docs locally, and a bit of cleanup --- docs/contributing.md | 30 ++++++++++++++++++++++++++++++ mkdocs.yml | 4 ++-- 2 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 docs/contributing.md diff --git a/docs/contributing.md b/docs/contributing.md new file mode 100644 index 00000000..07431750 --- /dev/null +++ b/docs/contributing.md @@ -0,0 +1,30 @@ +These instructions are for users who would like to get this documentation site running locally, +so you can edit changes and view them immediately. + +## Windows + +You need these things: + + - this repo - `git clone https://github.com/octokit/octokit.net.git` + - Python - install it from Chocolatey: `cinst python` + - mkdocs - install it with pip: `pip install mkdocs` + +**NOTE**: of course mkdocs doesn't appear on your PATH after this. Ugh. It's 2016. Come on people. + +**HACK**: add this to your PATH - `C:\ProgramData\chocolatey\lib\python3\tools\Scripts` and restart your shell. + +Once you've got all that, run `mkdocs serve` from the root of your repository and then point your browser +to `http://localhost:8000/` + +**NOTE**: You'll probably get a dialog here to give `python.exe` permission to open port 8000 on your firewall. This is fine. + +## OS X + +You need these things: + + - this repo - `git clone https://github.com/octokit/octokit.net.git` + - Python - if you don't have it already, get it from homebrew: `brew install python3` + - mkdocs - install it with pip: `pip install mkdocs` + +Once you've got all that, run `mkdocs serve` from the root of your repository and then point your browser +to `http://localhost:8000/` diff --git a/mkdocs.yml b/mkdocs.yml index 2a16b26f..9bea8f0a 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -15,8 +15,7 @@ theme: readthedocs pages: - 'Home' : 'index.md' -- 'Getting Started' : - - 'Creating a GitHubClient' : 'getting-started.md' +- 'Getting Started' : getting-started.md - Features: - 'Issues' : 'issues.md' @@ -34,3 +33,4 @@ pages: - Contributing: - 'Shipping Releases' : 'shipping-releases.md' - 'Strong Naming' : 'strong-naming.md' + - 'Documentation': 'contributing.md' From 64a0cda80c408e1c2285a6e8b38b901f8a3d4ae4 Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Wed, 27 Jan 2016 12:19:59 +1030 Subject: [PATCH 18/19] added a sample script using Octokit --- docs/demos/exploring-pull-requests.md | 90 +++++++++++++++++++++++++++ docs/getting-started.md | 8 +-- docs/index.md | 28 ++++----- mkdocs.yml | 3 + 4 files changed, 108 insertions(+), 21 deletions(-) create mode 100644 docs/demos/exploring-pull-requests.md diff --git a/docs/demos/exploring-pull-requests.md b/docs/demos/exploring-pull-requests.md new file mode 100644 index 00000000..40059928 --- /dev/null +++ b/docs/demos/exploring-pull-requests.md @@ -0,0 +1,90 @@ +**Scenario:** I have a lot of small pull requests to review, but things are a mess +- old pull requests which might be superseded by new ones, and it's hard to see from +the descriptions what the changes actually represent. + +**Goal:** a list of files, ordered by the number of pull requests which modify the +file (most popular at the top). This then gives me a list of pull requests that I +can review as a group. + +**Code** + +I'm using the Octokit.Reactive package as this helps represent the flow than tasks. + +``` +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reactive.Linq; +using Octokit; +using Octokit.Internal; +using Octokit.Reactive; + +class Program +{ + static string owner = "github"; + static string name = "gitignore"; + + static InMemoryCredentialStore credentials = new InMemoryCredentialStore(new Credentials("your-token-here")); + static ObservableGitHubClient client = new ObservableGitHubClient(new ProductHeaderValue("ophion"), credentials); + + static void Main(string[] args) + { + var request = new PullRequestRequest(); + + var results = new Dictionary>(); + + // fetch all open pull requests + client.PullRequest.GetAllForRepository(owner, name, request) + .SelectMany(pr => + { + // for each pull request, get the files and associate + // with the pull request number - this is a bit kludgey + return client.PullRequest.Files(owner, name, pr.Number) + .Select(file => Tuple.Create(pr.Number, file.FileName)); + }) + .Subscribe(data => + { + if (results.ContainsKey(data.Item2)) + { + // if we're already tracking this file, add it + results[data.Item2].Add(data.Item1); + } + else + { + // otherwise, we create a new list + var list = new List { data.Item1 }; + results[data.Item2] = list; + } + }, + ex => + { + Console.WriteLine("Exception found: " + ex.ToString()); + }, + () => + { + // after that's done, let's sort by the most popular files + var sortbyPopularity = results + .OrderByDescending(kvp => kvp.Value.Count); + + // output each file with the related pull requests + foreach (var file in sortbyPopularity) + { + Console.WriteLine("File: {0}", file.Key); + + foreach (var id in file.Value) + { + Console.WriteLine(" - PR: {0}", id); + } + + Console.WriteLine(); + } + }); + + // this will take a while, let's wait for user input before exiting + Console.ReadLine(); + } +} +``` + + +**Notes:** diff --git a/docs/getting-started.md b/docs/getting-started.md index d76fa074..72695448 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -35,7 +35,7 @@ It is **strongly recommended** to use the [OAuth Flow](https://github.com/octoki When authenticated, you have 5000 requests per hour available. So this is the recommended approach for interacting with the API. -### Connecting to GitHub Enterprise +### Connect to GitHub Enterprise Octokit also supports connecting to GitHub Enterprise environments - just provide the URL to your GitHub Enterprise server when creating the client. @@ -44,11 +44,11 @@ var ghe = new Uri("https://github.myenterprise.com/"); var client = new GitHubClient(new ProductHeaderValue("my-cool-app"), ghe); ``` -### Get exploring +### Get some data -Once you've got that setup, the simplest thing to experiment with is fetching details about a specific user: +Once you have that setup, the simplest thing to experiment with is fetching details about a specific user: -``` +```csharp var user = await client.User.Get("shiftkey"); Console.WriteLine("{0} has {1} public repositories - go check out their profile at {2}", user.Name, diff --git a/docs/index.md b/docs/index.md index 379fe656..ae79d333 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,24 +1,18 @@ # Octokit.net -This is a place for putting together some introductory documentation about how to use Octokit.net. +If you are new to Octokit, I recommend reading the +[Getting Started](https://github.com/octokit/octokit.net/blob/master/docs/getting-started.md) +guide, which walks through configuring the basics. - - [Getting Started](https://github.com/octokit/octokit.net/blob/master/docs/getting-started.md) - - [OAuth Flow](https://github.com/octokit/octokit.net/blob/master/docs/oauth-flow.md) - - [Releases API](https://github.com/octokit/octokit.net/blob/master/docs/releases.md) - - [Git Database API](https://github.com/octokit/octokit.net/blob/master/docs/git-database.md) +When you're done with that, have a look at the topics listed under **Features** to get +an idea of what other things are available. +If you're looking for some real-world examples, check out the **Samples** section. -Possible topics to cover: +There's also some advanced topics which require familiarity with the internals of Octokit. +You shouldn't need to know these well, but they're there if there comes a day when you do. - - Working with Repositories - - Working with User data - - Searching Repositories - - ... - -If you're not sure where to start, there's a suite of +If we still haven't covered a topic you're interested in, check out the suite of [integration tests](https://github.com/octokit/octokit.net/tree/master/Octokit.Tests.Integration/Clients) -which can help you to get familiar with how things currently work. - -Love and Octocats, - -The Octokit.net Team +which can help you to get familiar with how things currently work. Then open an issue +against the repository, so we can properly document things. diff --git a/mkdocs.yml b/mkdocs.yml index 9bea8f0a..713d7cbf 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -25,6 +25,9 @@ pages: - 'Search' : 'search.md' - 'Git Database' : 'git-database.md' +- Samples: + - 'Exploring Pull Requests' : 'demos/exploring-pull-requests.md' + - Advanced: - 'Debugging from Source': 'debugging-source.md' - 'OAuth Flow': 'oauth-flow.md' From 32e8d9059cbd18b0c01c4aeba7299ccdc28ae186 Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Wed, 27 Jan 2016 13:08:26 +1030 Subject: [PATCH 19/19] moving things around --- docs/demos/exploring-pull-requests.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/docs/demos/exploring-pull-requests.md b/docs/demos/exploring-pull-requests.md index 40059928..2ed5ab7c 100644 --- a/docs/demos/exploring-pull-requests.md +++ b/docs/demos/exploring-pull-requests.md @@ -6,10 +6,6 @@ the descriptions what the changes actually represent. file (most popular at the top). This then gives me a list of pull requests that I can review as a group. -**Code** - -I'm using the Octokit.Reactive package as this helps represent the flow than tasks. - ``` using System; using System.Collections.Generic; @@ -30,7 +26,6 @@ class Program static void Main(string[] args) { var request = new PullRequestRequest(); - var results = new Dictionary>(); // fetch all open pull requests @@ -88,3 +83,7 @@ class Program **Notes:** + +I'm using the Octokit.Reactive package as this helps represent the flow than +tasks. This code also isn't very advanced - it could be more clever, but it +works for what I needed.