{"id":23968605,"url":"https://github.com/vutran/git-parser","last_synced_at":"2025-04-13T15:40:31.919Z","repository":{"id":41086568,"uuid":"66299386","full_name":"vutran/git-parser","owner":"vutran","description":"↔️ Parse Git output","archived":false,"fork":false,"pushed_at":"2018-08-05T00:59:40.000Z","size":105,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-10T22:18:04.828Z","etag":null,"topics":["git","javascript","node","parser"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/vutran.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}},"created_at":"2016-08-22T18:51:09.000Z","updated_at":"2023-04-04T00:11:55.000Z","dependencies_parsed_at":"2022-09-08T05:12:05.695Z","dependency_job_id":null,"html_url":"https://github.com/vutran/git-parser","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vutran%2Fgit-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vutran%2Fgit-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vutran%2Fgit-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vutran%2Fgit-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vutran","download_url":"https://codeload.github.com/vutran/git-parser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248739734,"owners_count":21154219,"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","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":["git","javascript","node","parser"],"created_at":"2025-01-07T00:15:12.320Z","updated_at":"2025-04-13T15:40:31.892Z","avatar_url":"https://github.com/vutran.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# git-parser\n\n[![Travis](https://img.shields.io/travis/vutran/git-parser/master.svg?maxAge=2592000\u0026style=flat-square)](https://travis-ci.org/vutran/git-parser) [![Coveralls branch](https://img.shields.io/coveralls/vutran/git-parser/master.svg?maxAge=2592000\u0026style=flat-square)](https://coveralls.io/github/vutran/git-parser) [![license](https://img.shields.io/github/license/vutran/git-parser.svg?maxAge=2592000\u0026style=flat-square)](LICENSE)\n\n\u003e Parse Git output\n\n## Install\n\n```bash\n$ npm install --save git-parser\n```\n\n## Example\n\n```js\nconst { exec } = require('child_process');\nconst { parseDiff } = require('git-parser');\n\nexec('git diff', (err, stdout, stderr) =\u003e {\n\n  // parse the output of \"git diff\"\n  const diffs = parseDiff(stdout);\n\n  // array of diff objects\n  console.log(diffs);\n\n});\n```\n\n## API\n\n### parseDiff(output)\n\nReturns an array of changes between commits.\n\n#### output\n\nType: `string`\n\nThe diff output string\n\n### parseHunkHeader\n\nReturns an array of hunk headers.\n\n#### output\n\nType: `string`\n\nThe diff output string\n\n### parseFileHeader\n\nReturns an array of hunk headers.\n\n#### output\n\nType: `string`\n\nThe diff output string\n\n### parseStatus(output)\n\nReturns an array of working files' status using `--porcelain` option\n\n```js\nconst { exec } = require('child_process');\nconst { parseStatus } = require('git-parser');\n\nexec('git status --porcelain', (err, stdout, stderr) =\u003e {\n\n  // parse the output of \"git status --porcelain\". works with --branch to get branch name\n  const statuses = parseStatus(stdout);\n\n  console.log(statuses);\n\n});\n```\n\n#### output\n\nType: `object`\n\nJSON Schema\n\n```json\n{\n  \"type\": \"object\",\n  \"properties\": {\n    \"branch\": {\n      \"type\": \"string\",\n      \"description\": \"if no branch is in input, it will return 'default'\"\n    },\n    \"statuses\": {\n      \"type\": \"array\",\n      \"properties\": {\n        \"staged\": {\n          \"type\": \"boolean\",\n          \"description\": \"if false, it will be either unstaged or untracked (untracked would have a status of '??')\"\n        },\n        \"fileName\": {\n          \"type\": \"string\"\n        },\n        \"status\": {\n          \"type\": \"string\",\n          \"description\": \"Uppercase status code: M = modified, A = added, D = deleted, R = renamed, C = copied, ?? = untracked\"\n        }\n      }\n    }\n  }\n}\n```\n\n## License\n\nMIT © [Vu Tran](https://github.com/vutran/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvutran%2Fgit-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvutran%2Fgit-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvutran%2Fgit-parser/lists"}