HtmlUrl | LastPushed | ForksCount | SubscribersCount | StargazersCount | PushedAt |
---|---|---|---|---|---|
https://github.com/scriptcs/scriptcs | 17 minutes ago | 339 | 149 | 1867 | 10.11.17 09:43:52 +00:00 |
https://github.com/agartee/Brickweave | 2 hours ago | 1 | 1 | 1 | 10.11.17 07:12:08 +00:00 |
https://github.com/KallynGowdy/ReactiveUI.Routing | 5 hours ago | 1 | 1 | 3 | 10.11.17 04:35:47 +00:00 |
https://github.com/fredsena/TDD_STUFF | 2 days ago | 0 | 1 | 0 | 8.11.17 16:04:33 +00:00 |
https://github.com/Yan-Fedorov/BullsAndCows | 2 days ago | 0 | 1 | 0 | 7.11.17 18:57:47 +00:00 |
https://github.com/hlaueriksson/ConductOfCode | 7 days ago | 3 | 2 | 2 | 2.11.17 17:33:25 +00:00 |
https://github.com/colored-console/colored-console | 15 days ago | 11 | 5 | 51 | 25.10.17 13:08:28 +00:00 |
https://github.com/wiredwiz/FluentGuard | 18 days ago | 0 | 1 | 0 | 22.10.17 23:45:24 +00:00 |
https://github.com/thebothead/apache-avro-adla | 20 days ago | 0 | 1 | 0 | 20.10.17 13:09:00 +00:00 |
https://github.com/philippdolder/scs_kata | one month ago | 2 | 3 | 0 | 10.10.17 10:57:59 +00:00 |
Last active
November 10, 2017 10:03
-
-
Save adamralph/fd89fb4700b6b26b37f49c0912ffa1f3 to your computer and use it in GitHub Desktop.
A LINQPad script to search GitHub repos for package usage (and potentially other things)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Query Kind="Statements"> | |
<NuGetReference>Humanizer</NuGetReference> | |
<NuGetReference>Octokit</NuGetReference> | |
<Namespace>Humanizer</Namespace> | |
<Namespace>Octokit</Namespace> | |
<Namespace>Octokit.Internal</Namespace> | |
<Namespace>System.Threading.Tasks</Namespace> | |
</Query> | |
// I wrote this script to help me find out where my NuGet packages are being used. | |
// When prompted for a GitHub password, enter a personal access token. See https://github.com/settings/tokens | |
// Change these search parameters accordingly. | |
// The term to search for | |
var term = "xbehave"; | |
// The file names to search within | |
var fileNames = new[] { "packages.config", "*.csproj", "*.vbproj", "*.fsproj" }; | |
// A filter to exclude repositories | |
Func<Repository, bool> excludeRepository = repository => | |
new[] { "adamralph", "adamralph-archive", "xbehave" }.Contains(repository.Owner.Login); | |
// Let the magic begin... | |
var client = new GitHubClient( | |
new ProductHeaderValue("adamralph-code-search-by-repo", "1.0.0"), | |
new InMemoryCredentialStore(new Credentials(Util.GetPassword("GitHub")))); | |
(await Task.WhenAll((await Task.WhenAll( | |
fileNames | |
.Select(fileName => new SearchCodeRequest(term) { FileName = fileName, }) | |
.Select(async request => | |
{ | |
await Task.Delay(500); // attempt to avoid abuse detection by the GitHub API | |
return await client.Search.SearchCode(request); | |
}))) | |
.SelectMany(result => result.Items) | |
.GroupBy(item => item.Repository.HtmlUrl) | |
.Select(group => group.First()) | |
.Select(async item => await client.Repository.Get(item.Repository.Id)))) | |
.Where(repository => !excludeRepository(repository)) | |
.Select(repository => new | |
{ | |
HtmlUrl = new Hyperlinq(repository.HtmlUrl), | |
LastPushed = repository.PushedAt.Humanize(), | |
repository.ForksCount, | |
repository.SubscribersCount, | |
repository.StargazersCount, | |
repository.PushedAt, | |
}) | |
.OrderByDescending(repository => repository.PushedAt) | |
.ToList() | |
.Dump(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment