{"id":38048499,"url":"https://github.com/bigbang1112/simplest-git-source-generator","last_synced_at":"2026-01-19T10:00:42.474Z","repository":{"id":332243431,"uuid":"1133147216","full_name":"BigBang1112/simplest-git-source-generator","owner":"BigBang1112","description":"Simplest solution to get Git information in your .NET apps.","archived":false,"fork":false,"pushed_at":"2026-01-13T20:03:15.000Z","size":48,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-18T15:47:26.802Z","etag":null,"topics":["branch","build","commit","csharp","dotnet","git","metadata","msbuild","roslyn","source-generator","version"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BigBang1112.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-01-13T00:22:20.000Z","updated_at":"2026-01-13T20:02:03.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/BigBang1112/simplest-git-source-generator","commit_stats":null,"previous_names":["bigbang1112/simplest-git-source-generator"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/BigBang1112/simplest-git-source-generator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BigBang1112%2Fsimplest-git-source-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BigBang1112%2Fsimplest-git-source-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BigBang1112%2Fsimplest-git-source-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BigBang1112%2Fsimplest-git-source-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BigBang1112","download_url":"https://codeload.github.com/BigBang1112/simplest-git-source-generator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BigBang1112%2Fsimplest-git-source-generator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28565047,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-19T08:53:44.001Z","status":"ssl_error","status_checked_at":"2026-01-19T08:52:40.245Z","response_time":67,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["branch","build","commit","csharp","dotnet","git","metadata","msbuild","roslyn","source-generator","version"],"created_at":"2026-01-16T20:01:21.101Z","updated_at":"2026-01-19T10:00:42.468Z","avatar_url":"https://github.com/BigBang1112.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SimplestGitSourceGenerator\n\n[![Nuget](https://img.shields.io/nuget/v/SimplestGitSourceGenerator?style=for-the-badge\u0026logo=nuget)](https://www.nuget.org/packages/SimplestGitSourceGenerator/)\n[![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/BigBang1112/simplest-git-source-generator?include_prereleases\u0026style=for-the-badge\u0026logo=github)](https://github.com/BigBang1112/simplest-git-source-generator/releases)\n\nHappy to showcase the simplest solution for retrieving Git information in your .NET apps.\n\n## Requirements\n\n- Project must be a Git repository with at least 1 commit\n- Git must be installed\n\nIf these requirements are not fulfilled, the build will not pass!\n\n## Usage\n\nInstall the NuGet package:\n\n```\ndotnet add package SimplestGitSourceGenerator\n```\n\n**Code:**\n\n```cs\nusing SimplestGitSourceGenerator;\n\nConsole.WriteLine(SimplestGit.CommitHash);\nConsole.WriteLine(SimplestGit.CommitDate);\nConsole.WriteLine(SimplestGit.Branch);\nConsole.WriteLine(SimplestGit.Tag);\n```\n\nIf you want to include remote URL as well, you can enable it via property:\n\n```xml\n\u003cPropertyGroup\u003e\n    \u003cPublishRepositoryUrl\u003etrue\u003c/PublishRepositoryUrl\u003e\n\u003c/PropertyGroup\u003e\n```\n\nOnce that's done, you can access it via `SimplestGit.RemoteUrl`.\n\n### Docker build\n\nEnsure that you remove `.git` folders from your `.dockerignore` file and that you multi-stage your build so that the `.git` folder is not included in the final image.\n\nMake sure to install `git` before building your project (Alpine example):\n\n```dockerfile\nRUN apk add --no-cache git\n```\n\n## How does it work?\n\nBefore the source generator kicks in, several Git commands are called and stored as compiler properties before they are baked into the code.\n\n- `git rev-parse HEAD` (`SimplestGitCommitHash`)\n- `git rev-parse --abbrev-ref HEAD` (`SimplestGitBranch`)\n- `git log -1 --format=%cI` (`SimplestGitCommitDate`)\n- `git describe --tags --always` (`SimplestGitTag`)\n- `git ls-remote --get-url` (`SimplestGitRemoteUrl`)\n\nThese commands must complete with the exit code 0, otherwise, the build will not pass. All of that is done thanks to the `build/SimplestGitSourceGenerator.targets` file.\n\nThis is a simpler alternative to SourceLink or GitInfo packages if you don't mind requiring the Git dependency.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbigbang1112%2Fsimplest-git-source-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbigbang1112%2Fsimplest-git-source-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbigbang1112%2Fsimplest-git-source-generator/lists"}