Files
gh-jeremylongshore-claude-c…/skills/git-commit-smart/assets/example_diff.txt
2025-11-30 08:19:27 +08:00

105 lines
4.1 KiB
Plaintext

# Example Git Diff for Git Commit Smart Plugin
This document provides an example Git diff that can be used to test and demonstrate the functionality of the `git-commit-smart` Claude Code plugin. You can copy and paste this diff into a file named `example_diff.txt` and then use it as input for the plugin.
## Purpose
The `example_diff.txt` file serves as a sample input for the plugin, allowing users to:
* Understand how the plugin interprets different types of code changes.
* Experiment with the plugin's ability to generate conventional commit messages.
* Troubleshoot any issues with the plugin's analysis or message generation.
## Example Diff
Below is an example Git diff. It includes a variety of changes, such as:
* Adding a new feature
* Fixing a bug
* Refactoring existing code
* Updating documentation
```diff
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# My Awesome Project
+# My Super Awesome Project
This is a brief description of my project.
--- a/src/index.js
+++ b/src/index.js
@@ -1,5 +1,9 @@
function add(a, b) {
- return a + b;
+ if (typeof a !== 'number' || typeof b !== 'number') {
+ throw new Error('Both arguments must be numbers.');
+ }
+
+ return a + b
}
function subtract(a, b) {
--- a/test/index.test.js
+++ b/test/index.test.js
@@ -1,7 +1,14 @@
const { add, subtract } = require('../src/index');
describe('Math Functions', () => {
+ it('should throw an error if arguments are not numbers', () => {
+ expect(() => add('a', 1)).toThrowError('Both arguments must be numbers.');
+ expect(() => add(1, 'b')).toThrowError('Both arguments must be numbers.');
+ expect(() => add('a', 'b')).toThrowError('Both arguments must be numbers.');
+ });
+
it('should add two numbers correctly', () => {
expect(add(1, 2)).toBe(3);
});
+
it('should subtract two numbers correctly', () => {
expect(subtract(5, 2)).toBe(3);
});
```
## Usage Instructions
1. **Save the Diff:** Copy the entire diff above and save it to a file named `example_diff.txt`.
2. **Stage the Changes (Optional):** If you have a Git repository, you can apply this diff using `git apply example_diff.txt`. This is not required, as the plugin can directly analyze the `example_diff.txt` file.
3. **Invoke the Plugin:** Use the `/gc` command or the appropriate command in your Claude environment to invoke the `git-commit-smart` plugin.
4. **Provide the File:** When prompted, specify `example_diff.txt` as the input file containing the Git diff.
5. **Review the Output:** The plugin will analyze the diff and generate a conventional commit message. Review the suggested message and make any necessary adjustments.
## Expected Output (Example)
Based on the provided diff, the `git-commit-smart` plugin might suggest a commit message similar to:
```
feat(math): implement input validation for add function and update README
This commit introduces input validation to the `add` function in `src/index.js` to ensure that both arguments are numbers. An error is thrown if either argument is not a number.
Additionally, the README.md file has been updated to reflect the project's name change to "My Super Awesome Project."
The test suite has also been updated to include tests for the new input validation in `add`.
```
**Note:** The actual output may vary depending on the specific implementation of the `git-commit-smart` plugin and its AI model.
## Customization
You can modify the `example_diff.txt` file to include different types of changes and test the plugin's ability to handle various scenarios. Experiment with adding new files, deleting files, renaming files, and making more complex code changes.
## Troubleshooting
If you encounter any issues, ensure that:
* The `example_diff.txt` file is correctly formatted as a Git diff.
* The `git-commit-smart` plugin is properly installed and configured.
* Your Claude environment has the necessary permissions to access the file.
## Further Examples
You can find more example diffs online by searching for "example git diff" or looking at the commit history of open-source projects. Remember to adapt the examples to fit the context of your own projects and testing needs.