{"id":16920769,"url":"https://github.com/dherault/parse-git-patch","last_synced_at":"2025-03-22T11:30:51.705Z","repository":{"id":44007010,"uuid":"236521091","full_name":"dherault/parse-git-patch","owner":"dherault","description":"Parse git patches with ease","archived":false,"fork":false,"pushed_at":"2024-03-25T14:53:24.000Z","size":425,"stargazers_count":16,"open_issues_count":2,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-05-02T00:56:46.197Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/dherault.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}},"created_at":"2020-01-27T15:21:49.000Z","updated_at":"2024-06-19T11:25:37.047Z","dependencies_parsed_at":"2024-03-25T16:13:41.000Z","dependency_job_id":null,"html_url":"https://github.com/dherault/parse-git-patch","commit_stats":{"total_commits":15,"total_committers":2,"mean_commits":7.5,"dds":0.1333333333333333,"last_synced_commit":"42b37dbc3335e22bb90fbb38b34d90b065745b4e"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dherault%2Fparse-git-patch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dherault%2Fparse-git-patch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dherault%2Fparse-git-patch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dherault%2Fparse-git-patch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dherault","download_url":"https://codeload.github.com/dherault/parse-git-patch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244866435,"owners_count":20523517,"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":[],"created_at":"2024-10-13T19:49:33.298Z","updated_at":"2025-03-22T11:30:51.700Z","avatar_url":"https://github.com/dherault.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# parse-git-patch\n\n*Parse git patches with ease*\n\nThis NPM package allows you to parse git patches and diffs into an human and machine-readable object.\n\n## Installation\n\n`npm i parse-git-patch`\n\n## Usage\n\n```patch\nFrom 0f6f88c98fff3afa0289f46bf4eab469f45eebc6 Mon Sep 17 00:00:00 2001\nFrom: A dev \u003ca-dev@users.noreply.github.com\u003e\nDate: Sat, 25 Jan 2020 19:21:35 +0200\nSubject: [PATCH] JSON stringify string responses\n\n---\n src/events/http/HttpServer.js | 4 +++-\n 1 file changed, 3 insertions(+), 1 deletion(-)\n\ndiff --git a/src/events/http/HttpServer.js b/src/events/http/HttpServer.js\nindex 20bf454..c0fdafb 100644\n--- a/src/events/http/HttpServer.js\n+++ b/src/events/http/HttpServer.js\n@@ -770,7 +770,9 @@ export default class HttpServer {\n           override: false,\n         })\n\n-        if (result \u0026\u0026 typeof result.body !== 'undefined') {\n+        if (typeof result === 'string') {\n+          response.source = JSON.stringify(result)\n+        } else if (result \u0026\u0026 typeof result.body !== 'undefined') {\n           if (result.isBase64Encoded) {\n             response.encoding = 'binary'\n             response.source = Buffer.from(result.body, 'base64')\n--\n2.21.1 (Apple Git-122.3)\n```\n\n```js\nconst parseGitPatch = require('parse-git-patch')\n\nconst patch = fs.readFileSync(patchLocation, 'utf-8')\nconst parsedPatch = parseGitPatch(patch)\n```\n\n```js\n{\n  hash: '0f6f88c98fff3afa0289f46bf4eab469f45eebc6',\n  date: 'Sat, 25 Jan 2020 19:21:35 +0200',\n  message: '[PATCH] JSON stringify string responses',\n  authorEmail: 'a-dev@users.noreply.github.com',\n  authorName: 'A dev',\n  files: [\n    {\n      added: false,\n      deleted: false,\n      beforeName: 'src/events/http/HttpServer.js',\n      afterName: 'src/events/http/HttpServer.js',\n      modifiedLines: [\n        {\n          line: '        if (result \u0026\u0026 typeof result.body !== \\'undefined\\') {',\n          lineNumber: 773,\n          added: false,\n        },\n        {\n          line: '        if (typeof result === \\'string\\') {',\n          lineNumber: 773,\n          added: true,\n        },\n        {\n          line: '          response.source = JSON.stringify(result)',\n          lineNumber: 774,\n          added: true,\n        },\n        {\n          line: '        } else if (result \u0026\u0026 typeof result.body !== \\'undefined\\') {',\n          lineNumber: 775,\n          added: true,\n        },\n      ],\n    },\n  ],\n}\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdherault%2Fparse-git-patch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdherault%2Fparse-git-patch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdherault%2Fparse-git-patch/lists"}