Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
git-diff-parser
Advanced tools
I still need to publish the module, so until then, simply do this:
npm install git://github.com/spookd/git-diff-parser.git
This is a very simple - and rough - parser for git diff
and git format-patch
.
I made this in an hours time as I needed it for another project of mine. No error handling or tests of any sorts implemented yet.
Instead of describing the resulting objects I figured an example was self explanatory (right?):
parser = require("git-diff-parser")
diff = parser(require("fs").readFileSync("some.diff"))
# Better viewing of linenumbers
pad = (input = "-", toLeft = false) ->
result = "#{input}"
while result.length < 5
result = if toLeft then "#{result} " else " #{result}"
return result
# Loop all the commits
for commit in diff.commits
console.log "Commit ##{commit.sha} by #{commit.author} <#{commit.email}>" if diff.detailed
for file, i in commit.files
console.log "" if i isnt 0
console.log "[deleted] #{file.name}" if file.deleted
console.log "[added] #{file.name}" if file.added
console.log "[renamed] #{file.oldName} -> #{file.name}" if file.renamed
console.log "[file] #{file.name}" if not file.added and not file.deleted and not file.renamed
if file.binary
console.log "<<< binary >>>"
else
for line in file.lines
console.log "" if line.break
console.log "#{pad()}/#{pad(line.ln1, true)} + #{line.text}" if line.type is "added"
console.log "#{pad(line.ln1)}/#{pad("-", true)} - #{line.text}" if line.type is "deleted"
console.log "#{pad(line.ln1)}/#{pad(line.ln2, true)} #{line.text}" if line.type is "normal"
Feel free to optimize, improve and squish bugs. Simply fork it and make a pull request. Remember to add yourself to the list below.
Contributors:
Copyright (c) 2014 spookd and contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
FAQs
A simple parser for Git diffs
The npm package git-diff-parser receives a total of 4,735 weekly downloads. As such, git-diff-parser popularity was classified as popular.
We found that git-diff-parser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.