日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

统计 Github 2021 贡献过的开源项目

發(fā)布時(shí)間:2023/12/4 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 统计 Github 2021 贡献过的开源项目 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

統(tǒng)計(jì)一下 2021 貢獻(xiàn)過的開源項(xiàng)目

Intro

新的一年的開始了,有很多總結(jié)和回顧還沒有做,今天就盤點(diǎn)一下貢獻(xiàn)過的開源項(xiàng)目吧~

起初想著手動(dòng)地通過 Github Dashboard 來統(tǒng)計(jì)

但是感覺有些麻煩,還得一個(gè)個(gè)地復(fù)制標(biāo)題鏈接等,好麻煩,于是就想是不是可以寫一個(gè)簡(jiǎn)單的小程序通過 Github 的 API 來統(tǒng)計(jì)呢,答案是肯定的,可以參考后面的示例代碼

Contributions

過去一年的貢獻(xiàn)如下,一共提了 81 個(gè) PR 其中有 43 個(gè)是自己維護(hù)的開源項(xiàng)目的 PR,已從下面的 PR 中移除

統(tǒng)計(jì)結(jié)果來自 Github 的 API:https://api.github.com/search/issues?page=1&q=author%3Aweihanli+type%3Apr+is:merged+merged:%3E=2021-01-01

  • davidfowl/DotNetCodingPatterns

    • enhancement on Caching singletons sample code https://github.com/davidfowl/DotNetCodingPatterns/pull/11

  • domaindrivendev/Swashbuckle.AspNetCore

    • Enhancement for SwaggerUIMiddleware https://github.com/domaindrivendev/Swashbuckle.AspNetCore/pull/2214

  • dotnet/aspnetcore

    • Fix http logging log typo https://github.com/dotnet/aspnetcore/pull/36871

    • Update 10_bug_report.md https://github.com/dotnet/aspnetcore/pull/36922

  • dotnet/core

    • Update for .NET 6 release https://github.com/dotnet/core/pull/6892

  • dotnet/dotnet-monitor

    • update windows build script https://github.com/dotnet/dotnet-monitor/pull/40

  • dotnet/format

    • Remove unnecessary config https://github.com/dotnet/format/pull/1486

  • dotnet/issue-labeler

    • use generic host https://github.com/dotnet/issue-labeler/pull/15

  • dotnet/maui

    • Update MauiAppBuilder.cs https://github.com/dotnet/maui/pull/3445

  • dotnet/runtime

    • Update ConfigurationManager https://github.com/dotnet/runtime/pull/59600

  • dotnet/sdk

    • Add self contained short flag https://github.com/dotnet/sdk/pull/19681

    • Use null-coalescing assignment operator https://github.com/dotnet/sdk/pull/20678

  • dotnetcore/CAP

    • make OperateResult._errors readonly https://github.com/dotnetcore/CAP/pull/869

    • fix typo in comment https://github.com/dotnetcore/CAP/pull/870

    • Use KeyExistsAsync for exists check https://github.com/dotnetcore/CAP/pull/1004

  • dotnetcore/FastGithub

    • Fix build for .NET 6 with the latest SDK and some warning and typo https://github.com/dotnetcore/FastGithub/pull/26

    • Remove unnecessary config https://github.com/dotnetcore/FastGithub/pull/84

  • EdiWang/Moonglade

    • Common.props enhancement https://github.com/EdiWang/Moonglade/pull/566

  • IEvangelist/blazorators

    • Github CodeSpaces support https://github.com/IEvangelist/blazorators/pull/3

    • Refine the generator https://github.com/IEvangelist/blazorators/pull/6

    • Apply file-scoped namespace style and skip none partial classes https://github.com/IEvangelist/blazorators/pull/7

  • IEvangelist/pwned-client

    • Remove IsExternalInit https://github.com/IEvangelist/pwned-client/pull/6

  • kubernetes-client/csharp

    • Update TokenFileAuth https://github.com/kubernetes-client/csharp/pull/631

    • Expose kube config default location https://github.com/kubernetes-client/csharp/pull/635

    • Makes realFileSystem readonly https://github.com/kubernetes-client/csharp/pull/655

    • AddRange extension enhancement https://github.com/kubernetes-client/csharp/pull/771

  • LemonSharp/Admin.FrontEnd

    • Add Github CI support https://github.com/LemonSharp/Admin.FrontEnd/pull/2

    • Add dotnet-monitor https://github.com/LemonSharp/Admin.FrontEnd/pull/4

  • LemonSharp/User

    • Publish event when user register success https://github.com/LemonSharp/User/pull/1

  • LemonSharp/VaccinationCore

    • Implement AppointmentQueries/VaccinationQueries https://github.com/LemonSharp/VaccinationCore/pull/1

  • LemonSharp/VaccinationSite

    • Feat/add appointment api https://github.com/LemonSharp/VaccinationSite/pull/1

    • Add GetSiteInfoById API https://github.com/LemonSharp/VaccinationSite/pull/2

    • Add dotnet-monitor sidecar https://github.com/LemonSharp/VaccinationSite/pull/3

    • Enable swagger on production https://github.com/LemonSharp/VaccinationSite/pull/4

  • microsoft/reverse-proxy

    • Fix typo https://github.com/microsoft/reverse-proxy/pull/1245

    • Use WaitAsync https://github.com/microsoft/reverse-proxy/pull/1306

  • night-moon-studio/NatashaPad

    • Update to .NET 6 https://github.com/night-moon-studio/NatashaPad/pull/10

  • pengweiqhca/Xunit.DependencyInjection

    • Add Github Actions CI https://github.com/pengweiqhca/Xunit.DependencyInjection/pull/55

    • Update template https://github.com/pengweiqhca/Xunit.DependencyInjection/pull/59

  • StackExchange/StackExchange.Redis

    • Add support for GETDEL command https://github.com/StackExchange/StackExchange.Redis/pull/1840

    • Makes StreamEntry constructor public https://github.com/StackExchange/StackExchange.Redis/pull/1923

  • Tyrrrz/CliWrap

    • Remove unused dependencies https://github.com/Tyrrrz/CliWrap/pull/132

  • ua-parser/uap-csharp

    • Update target framework for netstandard2.0 https://github.com/ua-parser/uap-csharp/pull/65

希望接下來的一年能夠有更多更高質(zhì)量的開源貢獻(xiàn)~

很多開源項(xiàng)目的貢獻(xiàn)很簡(jiǎn)單并不會(huì)很復(fù)雜,大家也可以盡可能的貢獻(xiàn)一些自己的力量來讓 .NET 社區(qū)的開源項(xiàng)目越來越好~

Sample

上面的統(tǒng)計(jì)結(jié)果來自上面提到的 API

-?author?用戶名 -?type=pr?返回?PR -?is:merged?過濾合并的?PR -?merged:?根據(jù)?PR?合并時(shí)間過濾 -?page:?當(dāng)前頁碼,默認(rèn)是?1,?用來分頁

Github API result

上面的返回結(jié)果中的 html_url 對(duì)應(yīng)的就是對(duì)應(yīng) PR 的 HTML 頁面地址, title/body 對(duì)應(yīng) PR 的標(biāo)題和描述信息,created_at 和 closed_at 分別對(duì)應(yīng) PR 的創(chuàng)建和合并時(shí)間

寫了一個(gè)簡(jiǎn)單的小程序來統(tǒng)計(jì)結(jié)果,示例代碼如下:

using?System.Net.Http.Json; using?System.Text.Json.Nodes; using?WeihanLi.Extensions;const?int?pageCount?=?30; const?string?userName?=?"weihanli"; const?string?urlFormat?=$"search/issues?page={{0}}&q=author%3A{userName}+type%3Apr+is:merged+merged:%3E=2021-01-01";var?prList?=?new?List<GithubPRModel>(); var?itemsCount?=?0; var?pageNum?=?1;using?var?httpClient?=?new?HttpClient() {BaseAddress?=?new?Uri("https://api.github.com/") }; //?https://docs.github.com/en/rest/overview/resources-in-the-rest-api#user-agent-required httpClient.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent",?"Mozilla/5.0?(Windows?NT?10.0;?Win64;?x64)?AppleWebKit/537.36?(KHTML,?like?Gecko)?Chrome/97.0.4692.99?Safari/537.36");do {var?url?=?urlFormat.FormatWith(pageNum.ToString());using?var?response?=?await?httpClient.GetAsync(url);var?responseText?=?await?response.Content.ReadAsStringAsync();var?responseObj?=?JsonNode.Parse(responseText);ArgumentNullException.ThrowIfNull(responseObj);var?items?=?responseObj["items"]?.AsArray();ArgumentNullException.ThrowIfNull(items);itemsCount?=?items.Count;foreach?(var?item?in?items){prList.Add(new?GithubPRModel(){Title?=?item["title"]?.GetValue<string>(),Body?=?item["body"]?.GetValue<string>(),Url?=?item["html_url"]?.GetValue<string>(),CreatedAt?=?item["created_at"]?.GetValue<DateTimeOffset>(),ClosedAt?=?item["closed_at"]?.GetValue<DateTimeOffset>()});}pageNum++; }?while?(itemsCount?==?pageCount);var?totalCount?=?prList.Count; prList.RemoveAll(x?=>?userName.Equals(x.UserName,?StringComparison.OrdinalIgnoreCase)); var?excludedCount?=?prList.Count; Console.WriteLine($"Total:{totalCount},?excludedCount:?{excludedCount}");Console.WriteLine("Completed"); Console.ReadLine();internal?class?GithubPRModel {private?string?_url;public?string?Title?{?get;?set;?}public?string?Body?{?get;?set;?}public?DateTimeOffset??CreatedAt?{?get;?set;?}public?DateTimeOffset??ClosedAt?{?get;?set;?}public?string?Url{get?=>?_url;set{_url?=?value;if?(!string.IsNullOrEmpty(_url)){var?index?=?_url.IndexOf("/pull/",?StringComparison.OrdinalIgnoreCase);RepoUrl?=?_url[..index];RepoName?=?RepoUrl.Replace("https://github.com/",?"");UserName?=?RepoName[..RepoName.IndexOf('/')];}}}public?string?UserName?{?get;?private?set;?}public?string?RepoName?{?get;?private?set;?}public?string?RepoUrl?{?get;?private?set;?} }

上面的結(jié)果就是用這個(gè)示例中的代碼生成的,為了方便也可以改造一下上面的代碼直接生成 Markdown 內(nèi)容,上面的貢獻(xiàn)內(nèi)容就是下面這段生成 markdown 的代碼生成出來的,你也可以根據(jù)自己需要進(jìn)行一些定制

var?mdContent?=?prList.GroupBy(g?=>?new {g.RepoName,g.RepoUrl }) .OrderBy(g?=>?g.Key.RepoName) .Select(g?=>?$@"-?[{g.Key.RepoName}]({g.Key.RepoUrl}) {g.OrderBy(x?=>?x.CreatedAt).Select(x?=>?$"??-?{x.Title}?<{x.Url}>").StringJoin(Environment.NewLine)} ") .StringJoin(Environment.NewLine);await?File.WriteAllTextAsync("result.md",?mdContent);

StringJoin 是一個(gè)基于 string.Join 的擴(kuò)展方法

More

上面的示例中有一個(gè)需要注意的地方就是 UserAgent 請(qǐng)求頭的配置,如果不配置,Github 就會(huì)返回一個(gè) 403?

可以參考 Github 文檔?https://docs.github.com/en/rest/overview/resources-in-the-rest-api#user-agent-required

另外還有一些可以優(yōu)化的地方,比如說可以使用 System.Text.Json 的 GetFromJsonAsync 方法來簡(jiǎn)化 http response JSON 反序列化

另外可以考慮使用 Github 提供的客戶端,因?yàn)槲业男枨蟊容^簡(jiǎn)單所以直接調(diào)了這個(gè) API,也可以考慮使用 Github 客戶端?octokit

References

  • https://api.github.com/search/issues?page=1&q=state%3Aclosed+author%3Aweihanli+type%3Apr+is:merged+merged:%3E=2021-01-01

  • https://docs.github.com/en/rest/overview/resources-in-the-rest-api#user-agent-required

  • https://docs.github.com/en/search-github/searching-on-github/searching-issues-and-pull-requests#search-based-on-the-state-of-an-issue-or-pull-request

  • https://docs.github.com/en/search-github/searching-on-github/searching-issues-and-pull-requests#search-by-author

  • https://stackoverflow.com/questions/17412809/how-to-get-my-pull-requests-from-github-api

  • https://github.com/WeihanLi/SamplesInPractice/blob/master/GithubAPISample/Program.cs

  • https://github.com/octokit/octokit.net

總結(jié)

以上是生活随笔為你收集整理的统计 Github 2021 贡献过的开源项目的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。