gitdiff-parser is a JavaScript/TypeScript library designed to programmatically parse the output of the standard `git diff` command into a structured data format. It aims for speed and reliability in processing various `git diff` outputs, including additions, deletions, modifications, and renames, extracting details like file paths, modes, hunks, and individual line changes. The current stable version is 0.3.1, indicating that it is in a pre-1.0 development phase where API changes might occur more frequently than in a major stable release. It provides a robust, typed interface for accessing file, hunk, and change-level details from raw diff strings, making it suitable for building tools that need to analyze or manipulate repository changes programmatically, such as code review tools, linters, or continuous integration systems.
Verified import paths — ran on the pinned version, not inferred.
The library primarily uses a default export pattern. While CommonJS `require` might work via transpilation or specific bundler configurations, direct usage in a pure CommonJS environment might require additional setup or lead to issues.
These are TypeScript type definitions. Use `import type` to import them to ensure they are only used at compile-time and avoid potential runtime conflicts or erroneous value imports.
The `parse` function is a method on the default-exported object, not a direct named export from the module root.
Demonstrates how to install the package, import the parser, feed it a sample `git diff` string, and inspect the structured output including files, hunks, and individual changes.
Breaking-change detection hasn't run for this library yet.
CVE tracking and dependency tree are planned for a later release.