**git-diff-llm** is a command linetool that generates information about the differences between two git repositories, usually a forked repository and its upstream repository or between two branches of the same repository.\ Let consider the case of a proje
npm install git-diff-llm!Distance of a forked project to upstream
Let's assume we want to have information about the distance between the upstream project at point C and the forked project at point B (C and B can be tags or branches or even commits).\
The tool generates a report with information about the distance between C and B in terms of:
- The number of files that are different between the two repositories at point C and B
- The number of lines of code (LoC) that are added, removed or modified between the two repositories at point C and B - comments and blank lines are not counted
- A summary of the changes in the two repositories at point C and B - the summary is produced by an LLM (Large Language Model) starting from the diff of the two repositories and a prompt template
- A summary of the changes for each file which has differences in the LoC
OPENAI_API_KEY.OPENAI_API_KEYnpx git-diff-llm to launch the server side of the tool. If an error occurs, try to clean the npx cache with the command npx clear-npx-cache.file:/C:\Users\my.name\AppData\Local\npm-cache\_npx\2250f8eed83b8eed\node_modules\git-diff-llm\src\core\browser-client.html (the path is different depending on the OS, for instance with Ubuntu running on wsl the URI File Scheme is file://wsl.localhost/Ubuntu/home/_npx/2250f8eed83b8eed/node_modules/git-diff-llm/src/core/browser-client.html)npm install to install the dependenciesnpm run start- The URL of the second repository, if we want to compare a forked repository with its upstream repository (or another fork for that matter). In this case we need to select the "Compare with other remote repo" checkbox, provide the URL of the second repository and click on the "Confirm" button.
\
!Second repository
- The tag or branch or commit of the first repository (the so called FROM repository)
- The tag or branch or commit of the second repository (the so called TO repository)
- The LLM model to use to generate the summaries of the changes in the two repositories
- The extensions of the files to consider in the comparison (for instance .js,.ts,.html,.css)
\
!From, To and LLM model
- The prompt template to use to generate the summaries of the changes for each single file that has changes in the LoC. The prompt template can contain placeholders:
- {{fileContent}}: where the content of the file (at the FROM tag or branch or commit) is inserted
- {{diffs}}: where the diffs of the file (in git diff format) are inserted
- {{fileName}}: where the name of the file is inserted
- {{language}}: where the extensions chosen by the user are inserted
\
!Prompt
cloc --git-diff-rel --by-file command)The result report can be downloaded in a Markdown format by clicking on the "Download Report" button.
@enrico.piccinin/create-node-ts-app.git-diff-llm can be published as a package on the public NPM registry.
Once published, git-diff-llm can be invoked to execute a command using npx
Contains a configuration for eslint and prettier.
Testing is based on the mocha and chai libraries.
The src folder has the following structure:
- lib folder containing the command
- core folder containing files which implements the logic to execute the command
- internals folder containing the internals of the logic of the command
Run the tests using the command
npm run test