Searching repos

This commit is contained in:
Haroon
2015-10-29 15:53:08 +00:00
parent cf8fbd05ad
commit 03a1d16bd6
+71 -3
View File
@@ -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