@bernierllc/commit-analyzer 1.6.0 → 1.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/dist/commit-analyzer.d.ts +0 -28
- package/dist/commit-analyzer.js +0 -174
- package/dist/errors.d.ts +0 -11
- package/dist/errors.js +0 -24
- package/dist/index.d.ts +0 -4
- package/dist/index.js +0 -14
- package/dist/types.d.ts +0 -67
- package/dist/types.js +0 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bernierllc/commit-analyzer",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.2",
|
|
4
4
|
"description": "Commit interest analysis and filtering",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"license": "SEE LICENSE IN LICENSE",
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"minimatch": "^10.0.0",
|
|
23
|
-
"@bernierllc/logger": "
|
|
23
|
+
"@bernierllc/logger": "2.0.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/jest": "^29.5.0",
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { CommitData, CommitAnalysisCriteria, CommitAnalysisResult } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Commit interest analyzer
|
|
4
|
-
*/
|
|
5
|
-
export declare class CommitAnalyzer {
|
|
6
|
-
private criteria;
|
|
7
|
-
constructor(criteria?: CommitAnalysisCriteria);
|
|
8
|
-
/**
|
|
9
|
-
* Analyze commit for interest
|
|
10
|
-
*/
|
|
11
|
-
analyze(commit: CommitData): CommitAnalysisResult;
|
|
12
|
-
/**
|
|
13
|
-
* Check if commit is interesting (quick check)
|
|
14
|
-
*/
|
|
15
|
-
isInteresting(commit: CommitData): boolean;
|
|
16
|
-
/**
|
|
17
|
-
* Calculate interest score
|
|
18
|
-
*/
|
|
19
|
-
calculateScore(commit: CommitData): number;
|
|
20
|
-
/**
|
|
21
|
-
* Update analysis criteria
|
|
22
|
-
*/
|
|
23
|
-
updateCriteria(criteria: Partial<CommitAnalysisCriteria>): void;
|
|
24
|
-
/**
|
|
25
|
-
* Check files against patterns
|
|
26
|
-
*/
|
|
27
|
-
private checkFiles;
|
|
28
|
-
}
|
package/dist/commit-analyzer.js
DELETED
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
Copyright (c) 2025 Bernier LLC
|
|
4
|
-
|
|
5
|
-
This file is licensed to the client under a limited-use license.
|
|
6
|
-
The client may use and modify this code *only within the scope of the project it was delivered for*.
|
|
7
|
-
Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.CommitAnalyzer = void 0;
|
|
11
|
-
const logger_1 = require("@bernierllc/logger");
|
|
12
|
-
const minimatch_1 = require("minimatch");
|
|
13
|
-
const logger = (0, logger_1.createLogger)();
|
|
14
|
-
/**
|
|
15
|
-
* Commit interest analyzer
|
|
16
|
-
*/
|
|
17
|
-
class CommitAnalyzer {
|
|
18
|
-
criteria;
|
|
19
|
-
constructor(criteria = {}) {
|
|
20
|
-
this.criteria = {
|
|
21
|
-
minAdditions: criteria.minAdditions ?? 0,
|
|
22
|
-
minDeletions: criteria.minDeletions ?? 0,
|
|
23
|
-
minTotalChanges: criteria.minTotalChanges ?? 0,
|
|
24
|
-
minFilesChanged: criteria.minFilesChanged ?? 0,
|
|
25
|
-
ignoredBranches: criteria.ignoredBranches,
|
|
26
|
-
ignoredAuthors: criteria.ignoredAuthors,
|
|
27
|
-
filePatterns: criteria.filePatterns,
|
|
28
|
-
requiredFilePatterns: criteria.requiredFilePatterns
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Analyze commit for interest
|
|
33
|
-
*/
|
|
34
|
-
analyze(commit) {
|
|
35
|
-
const reasons = [];
|
|
36
|
-
const matchedCriteria = {};
|
|
37
|
-
let score = 0;
|
|
38
|
-
// Check branch
|
|
39
|
-
if (this.criteria.ignoredBranches?.includes(commit.branch)) {
|
|
40
|
-
reasons.push(`Branch ${commit.branch} is ignored`);
|
|
41
|
-
return {
|
|
42
|
-
interesting: false,
|
|
43
|
-
score: 0,
|
|
44
|
-
reasons,
|
|
45
|
-
matchedCriteria: { branch: false }
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
matchedCriteria.branch = true;
|
|
49
|
-
score += 10;
|
|
50
|
-
// Check author
|
|
51
|
-
const authorEmail = commit.author.email.toLowerCase();
|
|
52
|
-
const authorName = commit.author.name.toLowerCase();
|
|
53
|
-
if (this.criteria.ignoredAuthors?.some(ignored => authorEmail.includes(ignored.toLowerCase()) ||
|
|
54
|
-
authorName.includes(ignored.toLowerCase()))) {
|
|
55
|
-
reasons.push(`Author ${commit.author.email} is ignored`);
|
|
56
|
-
return {
|
|
57
|
-
interesting: false,
|
|
58
|
-
score: 0,
|
|
59
|
-
reasons,
|
|
60
|
-
matchedCriteria: { author: false }
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
matchedCriteria.author = true;
|
|
64
|
-
score += 10;
|
|
65
|
-
// Check size
|
|
66
|
-
const totalChanges = commit.additions + commit.deletions;
|
|
67
|
-
const sizeMatch = commit.additions >= this.criteria.minAdditions &&
|
|
68
|
-
commit.deletions >= this.criteria.minDeletions &&
|
|
69
|
-
totalChanges >= this.criteria.minTotalChanges;
|
|
70
|
-
if (sizeMatch) {
|
|
71
|
-
matchedCriteria.size = true;
|
|
72
|
-
score += 30;
|
|
73
|
-
reasons.push(`Size criteria met: +${commit.additions}/-${commit.deletions}`);
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
matchedCriteria.size = false;
|
|
77
|
-
reasons.push(`Size criteria not met: +${commit.additions}/-${commit.deletions} ` +
|
|
78
|
-
`(required: +${this.criteria.minAdditions}/-${this.criteria.minDeletions}, total: ${this.criteria.minTotalChanges})`);
|
|
79
|
-
}
|
|
80
|
-
// Check files
|
|
81
|
-
const filesMatch = this.checkFiles(commit.files, reasons);
|
|
82
|
-
if (filesMatch) {
|
|
83
|
-
matchedCriteria.files = true;
|
|
84
|
-
score += 30;
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
matchedCriteria.files = false;
|
|
88
|
-
}
|
|
89
|
-
// Check file count
|
|
90
|
-
if (commit.files.length >= this.criteria.minFilesChanged) {
|
|
91
|
-
score += 20;
|
|
92
|
-
reasons.push(`File count criteria met: ${commit.files.length} files`);
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
reasons.push(`File count criteria not met: ${commit.files.length} files ` +
|
|
96
|
-
`(required: ${this.criteria.minFilesChanged})`);
|
|
97
|
-
}
|
|
98
|
-
const interesting = score >= 50 && sizeMatch && filesMatch;
|
|
99
|
-
if (interesting) {
|
|
100
|
-
reasons.unshift('Commit is interesting');
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
reasons.unshift('Commit is not interesting');
|
|
104
|
-
}
|
|
105
|
-
logger.debug('Commit analyzed', {
|
|
106
|
-
sha: commit.sha,
|
|
107
|
-
interesting,
|
|
108
|
-
score,
|
|
109
|
-
reasons: reasons.length
|
|
110
|
-
});
|
|
111
|
-
return {
|
|
112
|
-
interesting,
|
|
113
|
-
score: Math.min(100, score),
|
|
114
|
-
reasons,
|
|
115
|
-
matchedCriteria
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Check if commit is interesting (quick check)
|
|
120
|
-
*/
|
|
121
|
-
isInteresting(commit) {
|
|
122
|
-
return this.analyze(commit).interesting;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Calculate interest score
|
|
126
|
-
*/
|
|
127
|
-
calculateScore(commit) {
|
|
128
|
-
return this.analyze(commit).score;
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Update analysis criteria
|
|
132
|
-
*/
|
|
133
|
-
updateCriteria(criteria) {
|
|
134
|
-
this.criteria = {
|
|
135
|
-
...this.criteria,
|
|
136
|
-
...criteria,
|
|
137
|
-
minAdditions: criteria.minAdditions ?? this.criteria.minAdditions,
|
|
138
|
-
minDeletions: criteria.minDeletions ?? this.criteria.minDeletions,
|
|
139
|
-
minTotalChanges: criteria.minTotalChanges ?? this.criteria.minTotalChanges,
|
|
140
|
-
minFilesChanged: criteria.minFilesChanged ?? this.criteria.minFilesChanged
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Check files against patterns
|
|
145
|
-
*/
|
|
146
|
-
checkFiles(files, reasons) {
|
|
147
|
-
// Check required patterns
|
|
148
|
-
if (this.criteria.requiredFilePatterns && this.criteria.requiredFilePatterns.length > 0) {
|
|
149
|
-
const hasRequired = this.criteria.requiredFilePatterns.some(pattern => files.some(file => (0, minimatch_1.minimatch)(file, pattern)));
|
|
150
|
-
if (!hasRequired) {
|
|
151
|
-
reasons.push(`No files match required patterns: ${this.criteria.requiredFilePatterns.join(', ')}`);
|
|
152
|
-
return false;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
// Check include patterns
|
|
156
|
-
if (this.criteria.filePatterns?.include && this.criteria.filePatterns.include.length > 0) {
|
|
157
|
-
const hasIncluded = this.criteria.filePatterns.include.some(pattern => files.some(file => (0, minimatch_1.minimatch)(file, pattern)));
|
|
158
|
-
if (!hasIncluded) {
|
|
159
|
-
reasons.push(`No files match include patterns: ${this.criteria.filePatterns.include.join(', ')}`);
|
|
160
|
-
return false;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
// Check exclude patterns
|
|
164
|
-
if (this.criteria.filePatterns?.exclude && this.criteria.filePatterns.exclude.length > 0) {
|
|
165
|
-
const hasExcluded = this.criteria.filePatterns.exclude.some(pattern => files.some(file => (0, minimatch_1.minimatch)(file, pattern)));
|
|
166
|
-
if (hasExcluded) {
|
|
167
|
-
reasons.push(`Files match exclude patterns: ${this.criteria.filePatterns.exclude.join(', ')}`);
|
|
168
|
-
return false;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
return true;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
exports.CommitAnalyzer = CommitAnalyzer;
|
package/dist/errors.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export type CommitAnalyzerErrorCode = 'COMMIT_ANALYZER_ERROR' | 'COMMIT_ANALYZER_INVALID_CRITERIA' | 'COMMIT_ANALYZER_INVALID_COMMIT' | 'COMMIT_ANALYZER_PATTERN_ERROR';
|
|
2
|
-
export interface CommitAnalyzerErrorOptions {
|
|
3
|
-
cause?: Error;
|
|
4
|
-
code?: CommitAnalyzerErrorCode;
|
|
5
|
-
context?: Record<string, unknown>;
|
|
6
|
-
}
|
|
7
|
-
export declare class CommitAnalyzerError extends Error {
|
|
8
|
-
readonly code: CommitAnalyzerErrorCode;
|
|
9
|
-
readonly context?: Record<string, unknown>;
|
|
10
|
-
constructor(message: string, options?: CommitAnalyzerErrorOptions);
|
|
11
|
-
}
|
package/dist/errors.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
Copyright (c) 2025 Bernier LLC
|
|
4
|
-
|
|
5
|
-
This file is licensed to the client under a limited-use license.
|
|
6
|
-
The client may use and modify this code *only within the scope of the project it was delivered for*.
|
|
7
|
-
Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.CommitAnalyzerError = void 0;
|
|
11
|
-
class CommitAnalyzerError extends Error {
|
|
12
|
-
code;
|
|
13
|
-
context;
|
|
14
|
-
constructor(message, options) {
|
|
15
|
-
super(message, options?.cause ? { cause: options.cause } : undefined);
|
|
16
|
-
this.name = 'CommitAnalyzerError';
|
|
17
|
-
this.code = options?.code ?? 'COMMIT_ANALYZER_ERROR';
|
|
18
|
-
if (options?.context !== undefined) {
|
|
19
|
-
this.context = options.context;
|
|
20
|
-
}
|
|
21
|
-
Error.captureStackTrace?.(this, this.constructor);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
exports.CommitAnalyzerError = CommitAnalyzerError;
|
package/dist/index.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export { CommitAnalyzer } from './commit-analyzer';
|
|
2
|
-
export { CommitAnalyzerError } from './errors';
|
|
3
|
-
export type { CommitAnalyzerErrorCode, CommitAnalyzerErrorOptions } from './errors';
|
|
4
|
-
export type { CommitData, CommitAnalysisCriteria, CommitAnalysisResult } from './types';
|
package/dist/index.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
Copyright (c) 2025 Bernier LLC
|
|
4
|
-
|
|
5
|
-
This file is licensed to the client under a limited-use license.
|
|
6
|
-
The client may use and modify this code *only within the scope of the project it was delivered for*.
|
|
7
|
-
Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.CommitAnalyzerError = exports.CommitAnalyzer = void 0;
|
|
11
|
-
var commit_analyzer_1 = require("./commit-analyzer");
|
|
12
|
-
Object.defineProperty(exports, "CommitAnalyzer", { enumerable: true, get: function () { return commit_analyzer_1.CommitAnalyzer; } });
|
|
13
|
-
var errors_1 = require("./errors");
|
|
14
|
-
Object.defineProperty(exports, "CommitAnalyzerError", { enumerable: true, get: function () { return errors_1.CommitAnalyzerError; } });
|
package/dist/types.d.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Commit analysis criteria
|
|
3
|
-
*/
|
|
4
|
-
export interface CommitAnalysisCriteria {
|
|
5
|
-
/** Minimum lines added */
|
|
6
|
-
minAdditions?: number;
|
|
7
|
-
/** Minimum lines deleted */
|
|
8
|
-
minDeletions?: number;
|
|
9
|
-
/** Minimum total changes */
|
|
10
|
-
minTotalChanges?: number;
|
|
11
|
-
/** Branches to ignore */
|
|
12
|
-
ignoredBranches?: string[];
|
|
13
|
-
/** Authors to ignore */
|
|
14
|
-
ignoredAuthors?: string[];
|
|
15
|
-
/** File patterns to include/exclude */
|
|
16
|
-
filePatterns?: {
|
|
17
|
-
include?: string[];
|
|
18
|
-
exclude?: string[];
|
|
19
|
-
};
|
|
20
|
-
/** Required file patterns */
|
|
21
|
-
requiredFilePatterns?: string[];
|
|
22
|
-
/** Minimum number of files changed */
|
|
23
|
-
minFilesChanged?: number;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Commit analysis result
|
|
27
|
-
*/
|
|
28
|
-
export interface CommitAnalysisResult {
|
|
29
|
-
/** Whether commit is interesting */
|
|
30
|
-
interesting: boolean;
|
|
31
|
-
/** Interest score (0-100) */
|
|
32
|
-
score: number;
|
|
33
|
-
/** Reasons for interest/not-interest */
|
|
34
|
-
reasons: string[];
|
|
35
|
-
/** Which criteria matched */
|
|
36
|
-
matchedCriteria: {
|
|
37
|
-
size?: boolean;
|
|
38
|
-
files?: boolean;
|
|
39
|
-
branch?: boolean;
|
|
40
|
-
author?: boolean;
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Commit data
|
|
45
|
-
*/
|
|
46
|
-
export interface CommitData {
|
|
47
|
-
/** Commit SHA */
|
|
48
|
-
sha: string;
|
|
49
|
-
/** Commit message */
|
|
50
|
-
message: string;
|
|
51
|
-
/** Commit author */
|
|
52
|
-
author: {
|
|
53
|
-
name: string;
|
|
54
|
-
email: string;
|
|
55
|
-
username?: string;
|
|
56
|
-
};
|
|
57
|
-
/** Branch name */
|
|
58
|
-
branch: string;
|
|
59
|
-
/** Lines added */
|
|
60
|
-
additions: number;
|
|
61
|
-
/** Lines deleted */
|
|
62
|
-
deletions: number;
|
|
63
|
-
/** Files changed */
|
|
64
|
-
files: string[];
|
|
65
|
-
/** Commit timestamp */
|
|
66
|
-
timestamp: Date;
|
|
67
|
-
}
|
package/dist/types.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
Copyright (c) 2025 Bernier LLC
|
|
4
|
-
|
|
5
|
-
This file is licensed to the client under a limited-use license.
|
|
6
|
-
The client may use and modify this code *only within the scope of the project it was delivered for*.
|
|
7
|
-
Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|