Commit interest analysis and filtering
npm install @bernierllc/commit-analyzerCommit interest analysis and filtering
``bash`
npm install @bernierllc/commit-analyzer
- Size-based filtering - Filter by additions, deletions, total changes
- File pattern matching - Include/exclude files by glob patterns
- Branch filtering - Ignore specific branches
- Author filtering - Ignore specific authors
- Interest scoring - Calculate interest score (0-100)
- Configurable criteria - Dynamic criteria updates
`typescript
import { CommitAnalyzer } from '@bernierllc/commit-analyzer';
const analyzer = new CommitAnalyzer({
minAdditions: 10,
minDeletions: 5,
ignoredBranches: ['develop', 'staging'],
ignoredAuthors: ['bot@example.com'],
filePatterns: {
include: ['src//.ts', 'docs//.md'],
exclude: ['.test.ts', '.spec.ts']
}
});
const commit = {
sha: 'abc123',
message: 'Add new feature',
author: { name: 'Developer', email: 'dev@example.com' },
branch: 'main',
additions: 50,
deletions: 10,
files: ['src/feature.ts', 'src/utils.ts'],
timestamp: new Date()
};
const result = analyzer.analyze(commit);
if (result.interesting) {
console.log('Commit is interesting!', result.reasons);
console.log('Score:', result.score);
}
`
`typescript`
const isInteresting = analyzer.isInteresting(commit);
if (isInteresting) {
// Process commit
}
`typescript`
const score = analyzer.calculateScore(commit);
console.log('Interest score:', score); // 0-100
`typescript`
analyzer.updateCriteria({
minAdditions: 20,
minDeletions: 10
});
`typescript`
const analyzer = new CommitAnalyzer({
filePatterns: {
include: ['src/*/.ts'], // Only TypeScript files
exclude: ['*.test.ts'] // Exclude test files
},
requiredFilePatterns: ['src/*/.ts'] // Must have TypeScript files
});
Creates a new commit analyzer with optional criteria.
Analyzes a commit and returns detailed results.
Quick check if a commit is interesting.
Calculates interest score (0-100).
Updates analysis criteria dynamically.
Uses @bernierllc/logger for analysis events, filtering decisions, and scoring calculations.
Can emit analysis events to NeverHub for distributed monitoring and observability. Commit analyzer can publish events like commit.analyzed, commit.interesting, and commit.filtered to NeverHub when available.
Pattern: Optional service discovery integration - package can emit analysis events to NeverHub for distributed monitoring.
Example Integration:
`typescript``
// If NeverHub is available, emit events
if (typeof detectNeverHub === 'function') {
const result = analyzer.analyze(commit);
neverhub.emit('commit-analyzer.commit.analyzed', result);
}
TypeDoc-compatible JSDoc comments are included throughout the source code. All public APIs are documented with examples and type information.
Copyright (c) 2025 Bernier LLC. All rights reserved.