Git Integration
This guide will help you understand how DeepLint works with Git and how to integrate it into your Git workflow.
Git Integration Overview
DeepLint is designed to work with Git repositories, analyzing changes in your codebase. By default, DeepLint analyzes staged changes, but you can also configure it to include unstaged changes.
The Git integration allows DeepLint to:
Detect staged and unstaged changes in your repository
Parse Git diffs to understand what has changed
Build context for analysis based on these changes
Focus analysis on the parts of your codebase that have changed
Running DeepLint on Git Changes
To run DeepLint on your Git changes:
# Run on staged changes only (default)
deeplint
# Run on both staged and unstaged changes
deeplint --unstaged
Configuration Options
You can configure Git integration through your DeepLint configuration file:
git: {
// Whether to include unstaged changes in the analysis
includeUnstaged: false,
}
Setting includeUnstaged
to true
will make DeepLint include unstaged changes in the analysis by default, without needing to specify the --unstaged
flag.
Git Workflow Integration
DeepLint is designed to be integrated into your Git workflow. Here are some common ways to use DeepLint with Git:
Pre-Commit Analysis
Run DeepLint before committing changes to catch issues early:
# Stage your changes
git add .
# Run DeepLint on staged changes
deeplint
# If no issues are found, commit your changes
git commit -m "Your commit message"
Analyzing Specific Files
You can stage specific files and then run DeepLint to analyze only those files:
# Stage specific files
git add file1.js file2.js
# Run DeepLint on staged changes
deeplint
Analyzing Unstaged Changes
If you want to analyze changes before staging them:
# Run DeepLint on unstaged changes
deeplint --unstaged
Troubleshooting
No Staged Changes
If you run DeepLint without any staged changes, you'll see an error message:
ERROR: No staged changes found. Stage changes with 'git add' or use --unstaged to analyze unstaged changes.
To fix this, either:
Stage some changes with
git add
, orUse the
--unstaged
flag to analyze unstaged changes:
deeplint --unstaged
Not a Git Repository
If you run DeepLint outside of a Git repository, you'll see an error message:
ERROR: Not a Git repository. Initialize a Git repository with 'git init' or navigate to a Git repository.
To fix this, either:
Navigate to a Git repository, or
Initialize a Git repository in your current directory:
git init
Git Not Installed
If Git is not installed or not in your PATH, you'll see an error message:
ERROR: Git not found. Please install Git and ensure it's in your PATH.
To fix this, install Git from git-scm.com and ensure it's in your PATH.
Permission Issues
If DeepLint doesn't have permission to access the Git repository, you'll see an error message:
ERROR: Permission denied: Could not access Git repository.
To fix this, ensure you have the necessary permissions to access the Git repository.
How Git Integration Works
DeepLint's Git integration consists of two main components:
Git Operations: Interacts with Git repositories to retrieve information about changes
Diff Parser: Parses Git diffs into a structured format for analysis
Git Operations
The Git Operations component provides a clean interface for interacting with Git repositories. It uses the simple-git
library to execute Git commands and parse their results. Key operations include:
Checking if there are staged or unstaged changes
Getting the list of staged or unstaged files
Getting the diff for staged or unstaged changes
Getting the diff between two commits
Diff Parser
The Diff Parser component parses Git diff output into a structured format that can be easily processed by the Context Builder. It extracts information about:
Changed files and their paths
Additions, deletions, and modifications
Line numbers and content
Context around changes
This structured information is then used by the Context Builder to build context for analysis.
Note: For planned Git features such as pre-commit hooks, CI/CD integration, and pull request analysis, see the Roadmap.
Next Steps
Now that you understand how DeepLint works with Git, you can:
Configure DeepLint to customize the analysis
Learn about the command line options to get the most out of DeepLint
Explore the context building process to understand how DeepLint analyzes your code
For more detailed information about the Git integration implementation, see the Git Operations and Diff Parsing documentation.
Previous: First Run
Last updated