@spaceflow/review-summary 0.23.0 → 0.24.0
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/CHANGELOG.md +34 -0
- package/package.json +3 -1
- package/src/review-summary.service.ts +29 -2
- package/src/types.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.23.0](https://github.com/Lydanne/spaceflow/compare/@spaceflow/review-summary@0.22.0...@spaceflow/review-summary@0.23.0) (2026-03-02)
|
|
4
|
+
|
|
5
|
+
### 新特性
|
|
6
|
+
|
|
7
|
+
* **actions:** 增强对 Gitea 平台的环境变量支持 ([21ba3da](https://github.com/Lydanne/spaceflow/commit/21ba3daa182083ecaec0113de91caf2ab1068000))
|
|
8
|
+
* **actions:** 支持 Gitea 作为 Git Provider ([4c88b36](https://github.com/Lydanne/spaceflow/commit/4c88b36d97ab49a322bac571385b0e57029676ff))
|
|
9
|
+
* **core:** 增强对 Gitea 平台的支持并修复类型转换 ([bfbb45c](https://github.com/Lydanne/spaceflow/commit/bfbb45c521035c80f0e81f5572d5aa1b554405f7))
|
|
10
|
+
* **publish:** 支持 Gitea 环境变量作为 CI 配置来源 ([cd1ba77](https://github.com/Lydanne/spaceflow/commit/cd1ba778617731ef85f9851883122175a99d72ac))
|
|
11
|
+
* **review-summary:** 新增 defect-rate 缺陷率评分策略 ([2777f4d](https://github.com/Lydanne/spaceflow/commit/2777f4da6d364cbc801792f4fa7ac6323da5e1bc))
|
|
12
|
+
* **review-summary:** 新增 issue-based 评分策略并更新文档 ([b6d923e](https://github.com/Lydanne/spaceflow/commit/b6d923e060aafd0b298a39d6fdc3e2f76facf1f3))
|
|
13
|
+
* **review:** 支持从 Gitea Actions 事件文件解析 PR 编号 ([09e2e58](https://github.com/Lydanne/spaceflow/commit/09e2e58d84f773b8a3184feb73b90cb110993ebd))
|
|
14
|
+
|
|
15
|
+
### 文档更新
|
|
16
|
+
|
|
17
|
+
* **docs:** 更新 review-summary 命令的 CI 配置示例 ([8b2b2c5](https://github.com/Lydanne/spaceflow/commit/8b2b2c55ed497619cbb91bd4fd2e5124b6f5ac37))
|
|
18
|
+
* **docs:** 更新 review-summary 命令的 CI 集成示例 ([60c5b70](https://github.com/Lydanne/spaceflow/commit/60c5b70695aa6a4c9cae1e3936670b34d5486792))
|
|
19
|
+
* **docs:** 更新环境变量参考文档,增加 GitLab 支持并优化 Gitea 说明 ([a02f8e0](https://github.com/Lydanne/spaceflow/commit/a02f8e0309368334bc77a331f65338435657eddb))
|
|
20
|
+
* **review-summary:** 更新错误信息以支持 Gitea 环境变量 ([cd02818](https://github.com/Lydanne/spaceflow/commit/cd028183fe7e14d993566e8dc49849b07d2540d9))
|
|
21
|
+
* **scripts:** 更新错误信息以支持 Gitea 环境变量 ([9a9d7f2](https://github.com/Lydanne/spaceflow/commit/9a9d7f20a63bea4cc13d284ed41bc9c4f4aa6595))
|
|
22
|
+
* **shell:** 更新错误信息以支持 Gitea 环境变量 ([72c51d7](https://github.com/Lydanne/spaceflow/commit/72c51d792c140d44d8aa3cb05666de72d170a185))
|
|
23
|
+
* 修复 GitHub Actions 配置示例的 Markdown 渲染问题 ([01daec5](https://github.com/Lydanne/spaceflow/commit/01daec551f2e23ab70357f88b7789897922064a7))
|
|
24
|
+
|
|
25
|
+
### 测试用例
|
|
26
|
+
|
|
27
|
+
* **core:** 修复测试用例中的导入和模拟函数实现 ([0137d4b](https://github.com/Lydanne/spaceflow/commit/0137d4b400f272ce7f7ba74fc5b37fcc453ed717))
|
|
28
|
+
|
|
29
|
+
### 其他修改
|
|
30
|
+
|
|
31
|
+
* **core:** released version 0.21.0 [no ci] ([7fa4381](https://github.com/Lydanne/spaceflow/commit/7fa438124cc27316ad5f37d5cbacc848ebd3b9df))
|
|
32
|
+
* **publish:** released version 0.45.0 [no ci] ([9bd3bbe](https://github.com/Lydanne/spaceflow/commit/9bd3bbe725a3362f762a1407c6a92a993359dfe5))
|
|
33
|
+
* **review:** released version 0.58.0 [no ci] ([790dc5f](https://github.com/Lydanne/spaceflow/commit/790dc5f4b38eba28df6f6e4414dd9c536d5a6377))
|
|
34
|
+
* **scripts:** released version 0.23.0 [no ci] ([2f18d22](https://github.com/Lydanne/spaceflow/commit/2f18d2274e83b65ce006dceed47a985942c8dd1d))
|
|
35
|
+
* **shell:** released version 0.23.0 [no ci] ([0668aa9](https://github.com/Lydanne/spaceflow/commit/0668aa97671ca235509bef547503c301237324f9))
|
|
36
|
+
|
|
3
37
|
## [0.22.0](https://github.com/Lydanne/spaceflow/compare/@spaceflow/review-summary@0.21.0...@spaceflow/review-summary@0.22.0) (2026-03-02)
|
|
4
38
|
|
|
5
39
|
### 新特性
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spaceflow/review-summary",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0",
|
|
4
4
|
"description": "Spaceflow 审查统计命令,根据时间范围统计 PR 贡献情况,按人员汇总并排序",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Lydanne",
|
|
@@ -15,9 +15,11 @@
|
|
|
15
15
|
"type": "module",
|
|
16
16
|
"main": "./dist/index.js",
|
|
17
17
|
"dependencies": {
|
|
18
|
+
"micromatch": "^4.0.8",
|
|
18
19
|
"@spaceflow/review": "0.58.0"
|
|
19
20
|
},
|
|
20
21
|
"devDependencies": {
|
|
22
|
+
"@types/micromatch": "^4.0.9",
|
|
21
23
|
"@types/node": "^22.15.0",
|
|
22
24
|
"@spaceflow/cli": "0.38.0"
|
|
23
25
|
},
|
|
@@ -2,6 +2,7 @@ import { GitProviderService, shouldLog, normalizeVerbose } from "@spaceflow/core
|
|
|
2
2
|
import type { IConfigReader } from "@spaceflow/core";
|
|
3
3
|
import type { PullRequest, Issue, CiConfig } from "@spaceflow/core";
|
|
4
4
|
import { MarkdownFormatter, type ReviewIssue } from "@spaceflow/review";
|
|
5
|
+
import micromatch from "micromatch";
|
|
5
6
|
import { writeFileSync } from "fs";
|
|
6
7
|
import { join } from "path";
|
|
7
8
|
import type {
|
|
@@ -159,8 +160,13 @@ export class PeriodSummaryService {
|
|
|
159
160
|
let additions = 0;
|
|
160
161
|
let deletions = 0;
|
|
161
162
|
let changedFiles = 0;
|
|
163
|
+
const includes = this.resolveIncludes();
|
|
162
164
|
try {
|
|
163
|
-
const
|
|
165
|
+
const allFiles = await this.gitProvider.getPullRequestFiles(owner, repo, pr.number!);
|
|
166
|
+
const files =
|
|
167
|
+
includes.length > 0
|
|
168
|
+
? allFiles.filter((f) => micromatch.isMatch(f.filename ?? "", includes, { matchBase: true }))
|
|
169
|
+
: allFiles;
|
|
164
170
|
changedFiles = files.length;
|
|
165
171
|
for (const file of files) {
|
|
166
172
|
additions += file.additions ?? 0;
|
|
@@ -371,6 +377,22 @@ export class PeriodSummaryService {
|
|
|
371
377
|
return userMap;
|
|
372
378
|
}
|
|
373
379
|
|
|
380
|
+
/**
|
|
381
|
+
* 解析文件过滤 glob 模式:优先使用 review-summary.includes,fallback 到 review.includes
|
|
382
|
+
*/
|
|
383
|
+
protected resolveIncludes(): string[] {
|
|
384
|
+
const config = this.getStrategyConfig();
|
|
385
|
+
if (config.includes && config.includes.length > 0) {
|
|
386
|
+
return config.includes;
|
|
387
|
+
}
|
|
388
|
+
try {
|
|
389
|
+
const reviewConfig = this.config.get<{ includes?: string[] }>("review");
|
|
390
|
+
return reviewConfig?.includes ?? [];
|
|
391
|
+
} catch {
|
|
392
|
+
return [];
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
|
|
374
396
|
/**
|
|
375
397
|
* 获取当前评分策略配置
|
|
376
398
|
*/
|
|
@@ -470,7 +492,10 @@ export class PeriodSummaryService {
|
|
|
470
492
|
const weights = { ...DEFAULT_DEFECT_RATE_WEIGHTS, ...config.defectRateWeights };
|
|
471
493
|
if (stats.prs.length === 0) return 0;
|
|
472
494
|
let complianceSum = 0;
|
|
495
|
+
let counted = 0;
|
|
473
496
|
for (const pr of stats.prs) {
|
|
497
|
+
// 跳过 merge PR(标题以 "Merge" 开头),合并操作不纳入缺陷率统计
|
|
498
|
+
if (pr.title.startsWith("Merge")) continue;
|
|
474
499
|
const totalLines = pr.additions + pr.deletions;
|
|
475
500
|
const per100 = Math.max(1, totalLines / 100);
|
|
476
501
|
const penalty =
|
|
@@ -478,8 +503,10 @@ export class PeriodSummaryService {
|
|
|
478
503
|
const recovery = (pr.fixedErrors + pr.fixedWarns) * weights.fixedDiscount;
|
|
479
504
|
const compliance = Math.min(1, Math.max(0, 1 - penalty + recovery));
|
|
480
505
|
complianceSum += compliance;
|
|
506
|
+
counted++;
|
|
481
507
|
}
|
|
482
|
-
|
|
508
|
+
if (counted === 0) return 0;
|
|
509
|
+
const avgCompliance = complianceSum / counted;
|
|
483
510
|
return Math.round((1 - avgCompliance) * 1000) / 10;
|
|
484
511
|
}
|
|
485
512
|
|
package/src/types.ts
CHANGED
|
@@ -191,6 +191,8 @@ export interface DefectRateWeights {
|
|
|
191
191
|
export interface ReviewSummaryConfig {
|
|
192
192
|
/** 评分策略,默认 "weighted" */
|
|
193
193
|
strategy?: ScoreStrategy;
|
|
194
|
+
/** 文件过滤 glob 模式,未设置时 fallback 读取 review.includes,支持 ! 排除模式 */
|
|
195
|
+
includes?: string[];
|
|
194
196
|
/** 加权模式权重配置(strategy 为 "weighted" 时生效) */
|
|
195
197
|
scoreWeights?: WeightedScoreWeights;
|
|
196
198
|
/** 分数累计模式权重配置(strategy 为 "commit-based" 时生效) */
|