GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - dherault/parse-git-patch: Parse git patches with ease

BranchesTags
Open more actions menu

Latest commit

 

History

40 Commits
40 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
.vscode
.vscode
 
 
src
src
 
 
test
test
 
 
.eslintrc
.eslintrc
 
 
.gitignore
.gitignore
 
 
.npmignore
.npmignore
 
 
CHANGELOG.md
CHANGELOG.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
jest.config.js
jest.config.js
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 
tsconfig.json
tsconfig.json
 
 

Repository files navigation

parse-git-patch

Parse git patches with ease

This NPM package allows you to parse git patches and diffs into an human and machine-readable object.

Installation

npm i parse-git-patch

Usage

From 0f6f88c98fff3afa0289f46bf4eab469f45eebc6 Mon Sep 17 00:00:00 2001
From: A dev <[email protected]>
Date: Sat, 25 Jan 2020 19:21:35 +0200
Subject: [PATCH] JSON stringify string responses

---
 src/events/http/HttpServer.js | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/events/http/HttpServer.js b/src/events/http/HttpServer.js
index 20bf454..c0fdafb 100644
--- a/src/events/http/HttpServer.js
+++ b/src/events/http/HttpServer.js
@@ -770,7 +770,9 @@ export default class HttpServer {
           override: false,
         })

-        if (result && typeof result.body !== 'undefined') {
+        if (typeof result === 'string') {
+          response.source = JSON.stringify(result)
+        } else if (result && typeof result.body !== 'undefined') {
           if (result.isBase64Encoded) {
             response.encoding = 'binary'
             response.source = Buffer.from(result.body, 'base64')
--
2.21.1 (Apple Git-122.3)
const parseGitPatch = require('parse-git-patch')

const patch = fs.readFileSync(patchLocation, 'utf-8')
const parsedPatch = parseGitPatch(patch)
{
  hash: '0f6f88c98fff3afa0289f46bf4eab469f45eebc6',
  date: 'Sat, 25 Jan 2020 19:21:35 +0200',
  message: '[PATCH] JSON stringify string responses',
  authorEmail: '[email protected]',
  authorName: 'A dev',
  files: [
    {
      added: false,
      deleted: false,
      beforeName: 'src/events/http/HttpServer.js',
      afterName: 'src/events/http/HttpServer.js',
      modifiedLines: [
        {
          line: '        if (result && typeof result.body !== \'undefined\') {',
          lineNumber: 773,
          added: false,
        },
        {
          line: '        if (typeof result === \'string\') {',
          lineNumber: 773,
          added: true,
        },
        {
          line: '          response.source = JSON.stringify(result)',
          lineNumber: 774,
          added: true,
        },
        {
          line: '        } else if (result && typeof result.body !== \'undefined\') {',
          lineNumber: 775,
          added: true,
        },
      ],
    },
  ],
}

License

MIT

About

Parse git patches with ease

Resources

Readme
MIT license
Activity

Stars

22 stars

Watchers

1 watching

Forks

7 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.