{"id":17970424,"url":"https://github.com/ni-m/githashextractor","last_synced_at":"2026-03-01T11:01:20.638Z","repository":{"id":38204499,"uuid":"485471667","full_name":"ni-m/GitHashExtractor","owner":"ni-m","description":"Extract Git hash and save this information as a file for version tracking in software and firmware","archived":false,"fork":false,"pushed_at":"2025-05-09T12:18:47.000Z","size":49,"stargazers_count":1,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-25T21:44:21.871Z","etag":null,"topics":["cicd","cmake","cpp","qt","version-control"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ni-m.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}},"created_at":"2022-04-25T17:36:52.000Z","updated_at":"2025-05-02T12:38:38.000Z","dependencies_parsed_at":"2025-07-25T16:25:38.813Z","dependency_job_id":"bd3510ed-8c93-494d-a6cb-0458c533df55","html_url":"https://github.com/ni-m/GitHashExtractor","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/ni-m/GitHashExtractor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ni-m%2FGitHashExtractor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ni-m%2FGitHashExtractor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ni-m%2FGitHashExtractor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ni-m%2FGitHashExtractor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ni-m","download_url":"https://codeload.github.com/ni-m/GitHashExtractor/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ni-m%2FGitHashExtractor/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29967930,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-01T10:55:55.490Z","status":"ssl_error","status_checked_at":"2026-03-01T10:55:55.175Z","response_time":124,"last_error":"SSL_read: 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":["cicd","cmake","cpp","qt","version-control"],"created_at":"2024-10-29T15:05:17.837Z","updated_at":"2026-03-01T11:01:20.633Z","avatar_url":"https://github.com/ni-m.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GitHashExtractor\n\n![GitHashExtractor Banner image](./doc/banner.svg)\nUse this repo to extract the current git hash and date information on compile time. It supports various languages as stated in [utilization](#utilization). Head over to [example](/example/) for a quick look into the working principle.\n\n## Requirements\nUse one of the following schemas for your Git tags as described in [Semver 2.0.0](https://semver.org/spec/v2.0.0.html)\n```\n1.2.2-alpha\n1.2.2-alpha.3\n1.2.2-alpha.beta\nv2.3.4-beta\n```\n\n## Available variables\nName | Usage | Example | Flag to disable\n-- | -- | -- | --\ngitURL | The url of this GitRepo | username/repo | GH_NO_URL\ngitVersion | info from git describe | v1.0.23-3-g354377c-dirty | GH_NO_TEXT\ncompDate | Date of compilation | 2021-09-19 | GH_NO_TEXT\ncompTime | Time of compilation | 17:06:40 | GH_NO_TEXT\ncompUnixTime | Unix timestamp of compilation | 1653459717 | GH_NO_RAW\ntagArray | Array with Major.Minor.Patch | 1.0.23 | GH_NO_RAW\ntagPreRelease | Prerelease as string | alpha / alpha.2 / alpha.beta | GH_NO_RAW\ntagOffset | Amount of commits ahead this tag | 3 | GH_NO_RAW\ngitHash | GitHash(n=7) as HexValue | 0x354377c | GH_NO_RAW\ngitDirty | 1 for uncommited changes, else 0 | 1 | GH_NO_RAW\n\n## Example [template](template/templateCpp.h) after build\n```\nnamespace version\n{\n    #ifndef GH_NO_URL\n        constexpr char gitURL[] = \"username/gitrepo\";\n    #endif\n    #ifndef GH_NO_TEXT\n        constexpr char gitVersion[] = \"v1.1.1-0-gc184746-dirty\";\n        constexpr char compDate[] = \"2022-06-03\";\n        constexpr char compTime[] = \"12:28:27\";\n    #endif\n    #ifndef GH_NO_RAW\n        constexpr uint32_t compUnixTime = 1654252107;\n        constexpr char tagArray[] = {1, 1, 1, 0}; //Major.Minor.Patch\n        constexpr char tagPreRelease[] = \"\";\n        constexpr char tagOffset = 0;\n        constexpr uint32_t gitHash = 0xc184746;\n        constexpr char gitDirty = 1;\n    #endif\n}\n```\n\n## Installation\nRun the following command in your local git repo: [Troubleshooting](#troubleshooting)\n```\ngit submodule add https://github.com/ni-m/GitHashExtractor\n```\n```\nGit repo:\n├───GitHashExtractor\n│   ├───doc\n│   ├───example\n│   ├───template\n│   ├───firmwareVersion.py\n│   └───version.h\n└───Project files\n```\n## Utilization\n### PlatformIO\nAdd the following lines to your platformio.ini file (uses default Cpp.h template) Adjust flags as needed.\n```\nextra_scripts = \n    pre:GitHashExtractor/firmwareVersion.py\nbuild_flags =\n    -D GH_NO_TEXT\n```\n***\n### Qt creator with cmake\nAdd files to PROJECT_SOURCE:\n```\nset(PROJECT_SOURCES\n        [... your files ...]\n        GitHashExtractor/firmwareVersion.py\n        GitHashExtractor/version.h\n)\n```\nAdd the following lines right after \"set(PROJECT_SOURCES)\" to your CMakeLists.txt file \n```\n# START github.com/ni-m/gitHashExtractor\nset(VERSION_FILE \"./GitHashExtractor/version.h\")\nset(VERSION_PYTHON \"./GitHashExtractor/firmwareVersion.py\")\nset_property(SOURCE ${VERSION_FILE} PROPERTY SKIP_AUTOGEN ON)\nadd_custom_command(OUTPUT ${VERSION_FILE}\n    COMMAND python ${VERSION_PYTHON} [ARGS] [Qt.h]\n    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}\n    COMMENT \"Creating ${VERSION_FILE}\"\n)\n\n# target GitHashExtractor is always built\nadd_custom_target(GitHashExtractor ALL DEPENDS ${VERSION_FILE})\n# END github.com/ni-m/gitHashExtractor\n```\n### Makefile\nAdd the following line to your target\n```\npython3 GitHubExtractor/firmwareVersion.py\n```\n## Tool configuration\nThe following software versions were used to develop this software:\n- VS Code\n- Python 3.10.2\n\n## Troubleshooting\nYou may need to clone the submodule seperate after cloning your project.  \n  \nProblem with .gitignore: Add the following line to your .gitignore\n```\n!GitHashExtractor\n```\nUpdate submodule to latest version\n```\ngit submodule update --remote\n```\nInit git submodule after submodule add\n```\ngit submodule update --init\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fni-m%2Fgithashextractor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fni-m%2Fgithashextractor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fni-m%2Fgithashextractor/lists"}