Skip to content

feat(git): include lock files with summaries in commit message generation#3

Draft
Copilot wants to merge 5 commits intomainfrom
copilot/improve-lock-file-handling
Draft

feat(git): include lock files with summaries in commit message generation#3
Copilot wants to merge 5 commits intomainfrom
copilot/improve-lock-file-handling

Conversation

Copy link
Contributor

Copilot AI commented Nov 9, 2025

Rebased and Aligned with Main Branch

Successfully rebased the lock file handling implementation onto main branch (v2.1.0) and aligned with current architecture.

Key Changes

Type System

  • shouldIgnore() returns IgnoreResult with type classification (lockfile | generated | vendor)
  • Added FileDiff.isLockFile flag and LockFileOptions type
  • Lock files now return { ignore: false, type: "lockfile" } instead of true

Lock File Handling

  • Created summarizeLockFileChanges() using git diff --numstat
  • Generates summaries: "Updated/Added/Removed dependencies in [filename]"
  • Supports 7 lock file types: package-lock.json, pnpm-lock.yaml, yarn.lock, composer.lock, Cargo.lock, Gemfile.lock, poetry.lock

Configuration

lockFileHandling:
  include: true      # Include lock files (default: true)
  useSummary: true   # Use summaries (default: true)

Architecture Alignment

  • Updated to use getDiffs() and getChanges() (renamed from getStagedDiff and getStagedChangesPaths)
  • Both functions now accept lockFileOptions parameter
  • Compatible with isomorphic-git and current git service architecture

Tests

  • ✅ Updated "filters out lock files" test to "includes lock files"
  • ✅ Added tests for include: false configuration
  • ✅ Added tests for include: true configuration
  • ✅ All 128 tests passing

Benefits

  • More accurate commit messages that include dependency changes
  • Better performance (summaries ~100 bytes vs lock files 100KB+)
  • Fully backward compatible via configuration
  • Defaults improve behavior for all users
Original prompt

This section details on the original issue you should resolve

<issue_title>Improve lock file handling in commit message generation</issue_title>
<issue_description>## Problem

Currently, the application completely ignores lock files (package-lock.json, yarn.lock, pnpm-lock.yaml, etc.) when generating commit messages, as seen in src/services/git.ts:31-43. While this prevents verbose, unhelpful diffs from being included in the AI analysis, it also means that important dependency updates are completely omitted from commit messages.

Current Behavior

The shouldIgnore function in src/services/git.ts:18-50 filters out:

  • package-lock.json
  • pnpm-lock.yaml
  • yarn.lock
  • composer.lock
  • Cargo.lock
  • Gemfile.lock
  • poetry.lock

This means when dependencies are updated, the generated commit message won't mention these changes at all.

Proposed Solution

Instead of completely ignoring lock files, we should:

  1. Detect lock file changes but handle them differently from regular code changes

  2. Generate meaningful summaries for lock file changes, such as:

    • "Updated dependencies" (for general updates)
    • "Added new dependencies: [list]" (when new deps are added)
    • "Removed dependencies: [list]" (when deps are removed)
    • "Updated [package] from X.X.X to Y.Y.Y" (for specific important updates)
  3. Use package manager tools to extract meaningful information:

    • For npm/yarn/pnpm: Parse the diff to identify added/removed/updated packages
    • Use git diff --name-status to detect if lock files changed
    • Run commands like npm ls --depth=0 --json to get dependency info if needed

Implementation Suggestions

  1. Modify shouldIgnore() to return an object instead of boolean:

    type IgnoreResult = {
      ignore: boolean;
      type?: 'lockfile' | 'generated' | 'vendor';
    };
  2. Add a new function summarizeLockFileChanges() that:

    • Parses lock file diffs to extract package changes
    • Returns a concise summary instead of the full diff
  3. Update getStagedDiff() to:

    • Include lock files but mark them with a special flag
    • Generate summaries for lock files instead of full diffs
  4. Modify the commit message generation to:

    • Include lock file summaries in the context
    • Generate appropriate commit messages like "chore(deps): update dependencies"

Benefits

  • More accurate commit messages that reflect all changes
  • Better tracking of dependency updates in commit history
  • Maintains performance by not sending huge lock file diffs to AI
  • Provides meaningful context about dependency changes

Files Affected

  • src/services/git.ts - Main implementation
  • src/services/__tests__/git.test.ts - Update tests
  • src/commands/generateCommitMessage.ts - Handle lock file summaries
  • src/types/git.ts - May need new types for lock file handling

Additional Considerations

  • Should be configurable via .commity.yaml to allow users to customize behavior
  • Consider caching dependency analysis for performance
  • Handle cases where both package.json and lock files change together</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 4 commits November 9, 2025 04:26
Co-authored-by: mickr <7842095+mickr@users.noreply.github.com>
…tion

Co-authored-by: mickr <7842095+mickr@users.noreply.github.com>
Co-authored-by: mickr <7842095+mickr@users.noreply.github.com>
Co-authored-by: mickr <7842095+mickr@users.noreply.github.com>
Copilot AI changed the title [WIP] Improve lock file handling in commit message generation feat(git): include lock files with summaries in commit message generation Nov 9, 2025
Copilot AI requested a review from mickr November 9, 2025 04:41
@mickr
Copy link
Owner

mickr commented Dec 5, 2025

@copilot rebase this branch and align it with our current architecture

Copy link
Contributor Author

Copilot AI commented Dec 5, 2025

@copilot rebase this branch and align it with our current architecture

Rebased the branch onto main (v2.1.0) and aligned with current architecture. All changes have been consolidated into a single clean commit (4d23485) on top of main. The implementation now uses getDiffs() and getChanges() function names that match the current codebase. All 128 tests passing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve lock file handling in commit message generation

2 participants