{"id":22400120,"url":"https://github.com/currents-dev/commit-info","last_synced_at":"2025-08-10T16:39:51.456Z","repository":{"id":205938293,"uuid":"715468761","full_name":"currents-dev/commit-info","owner":"currents-dev","description":null,"archived":false,"fork":false,"pushed_at":"2024-10-25T07:07:37.000Z","size":1451,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-29T01:39:24.310Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/currents-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2023-11-07T07:53:35.000Z","updated_at":"2024-10-25T07:07:38.000Z","dependencies_parsed_at":"2023-11-07T08:00:25.658Z","dependency_job_id":"f2775948-6de1-4f3f-a174-295846dc9907","html_url":"https://github.com/currents-dev/commit-info","commit_stats":null,"previous_names":["currents-dev/commit-info"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/currents-dev/commit-info","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/currents-dev%2Fcommit-info","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/currents-dev%2Fcommit-info/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/currents-dev%2Fcommit-info/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/currents-dev%2Fcommit-info/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/currents-dev","download_url":"https://codeload.github.com/currents-dev/commit-info/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/currents-dev%2Fcommit-info/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269440224,"owners_count":24417384,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-08T02:00:09.200Z","response_time":72,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-12-05T08:11:27.441Z","updated_at":"2025-08-10T16:39:51.406Z","avatar_url":"https://github.com/currents-dev.png","language":"JavaScript","readme":"# @currents/commit-info\n\nCollects Git commit info from git CLI\n\n\n## Install\n\nRequires [Node](https://nodejs.org/en/) version 6 or above.\n\n```sh\nnpm install --save @currents-dev/commit-info\n```\n\n## Use\n\n```js\nconst {commitInfo} = require('@currents-dev/commit-info')\n// default folder is current working directory\ncommitInfo(folder)\n  .then(info =\u003e {\n    // info object will have properties\n    // branch\n    // message\n    // email\n    // author\n    // sha\n    // timestamp (in seconds since epoch)\n    // remote\n  })\n```\n\nNotes:\n\n- Code assumes there is `.git` folder and uses Git commands to get each property, like `git show -s --pretty=%B`, see [src/git-api.js](src/git-api.js). Note: there is fallback to environment variables.\n- Resolves with [Bluebird](https://github.com/petkaantonov/bluebird) promise.\n- Only uses Git commands, see [src/git-api.js](src/git-api.js)\n- If a command fails, returns `null` for each property\n- If you need to debug, run with `DEBUG=commit-info` environment variable.\n\n## Fallback environment variables\n\nIf getting the commit information using `git` fails for some reason, you can provide the commit information by setting the environment variables. This module will look at the following environment variables as a fallback\n\n```\nbranch: COMMIT_INFO_BRANCH\nmessage: COMMIT_INFO_MESSAGE\nemail: COMMIT_INFO_EMAIL\nauthor: COMMIT_INFO_AUTHOR\nsha: COMMIT_INFO_SHA\ntimestamp: COMMIT_INFO_TIMESTAMP\nremote: COMMIT_INFO_REMOTE\n```\n\n### For Docker containers\n\nWhen running your application inside a Docker container, you should set these environment variables using `-e` syntax.\n\n```shell\n$ docker run \\\n  -e COMMIT_INFO_BRANCH=develop \\\n  -e COMMIT_INFO_SHA=e5d9eb66474bc0b681da9240aa5a457fe17bc8f3 \\\n  \u003ccontainer name\u003e\n```\n\nSee [docker-example](docker-example) for a full example.\n\n## Individual methods\n\nIn addition to `commitInfo` this module also exposes individual promise-returning\nmethods `getBranch`, `getMessage`, `getEmail`, `getAuthor`, `getSha`, `getTimestamp`, `getRemoteOrigin`. These methods do NOT use fallback environment variables.\n\nFor example\n\n```js\nconst {getAuthor} = require('@currents/commit-info')\ngetAuthor('path/to/repo')\n  .then(name =\u003e ...)\n```\n\n### getBranch\n\nResolves with the current git branch name or `null`.\n\n```js\nconst {getBranch} = require('@currents/commit-info')\ngetBranch()\n  .then(branch =\u003e ...)\n```\n\n- If this is detached commit (reporting `HEAD`), returns `null`\n\n### Small print\n\nLicense: MIT - do anything with the code, but don't blame me if it does not work.\n\nSupport: if you find any problems with this module, email / tweet /\n[open issue](https://github.com/currents-dev/commit-info/issues) on Github\n\n## MIT License\n\nCopyright (c) 2017 Cypress.io\n\nPermission is hereby granted, free of charge, to any person\nobtaining a copy of this software and associated documentation\nfiles (the \"Software\"), to deal in the Software without\nrestriction, including without limitation the rights to use,\ncopy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the\nSoftware is furnished to do so, subject to the following\nconditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\nOF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\nHOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\nWHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\nFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\nOTHER DEALINGS IN THE SOFTWARE.\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcurrents-dev%2Fcommit-info","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcurrents-dev%2Fcommit-info","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcurrents-dev%2Fcommit-info/lists"}