Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: incorrect latest tag in strict specific version #610

Merged
merged 5 commits into from
Nov 28, 2023

Conversation

hezhengxu2018
Copy link
Collaborator

  1. 添加新建任务时的重复版本校验,去除执行任务时的版本去重
  2. 在strictSyncSpecificVersion开启时,修改为从可用版本中选择latestTag。之前从任务的指定版本中生成latestTag逻辑不正确

Copy link

codecov bot commented Nov 7, 2023

Codecov Report

Attention: 167 lines in your changes are missing coverage. Please review.

Comparison is base (6624a36) 97.45% compared to head (bac284f) 96.83%.
Report is 139 commits behind head on master.

Files Patch % Lines
config/config.default.ts 53.03% 31 Missing ⚠️
.../port/controller/admin/PaddingVersionController.ts 48.83% 22 Missing ⚠️
app/core/service/FixNoPaddingVersionService.ts 54.54% 15 Missing ⚠️
app/core/service/PackageSearchService.ts 93.64% 15 Missing ⚠️
app/core/service/PackageSyncerService.ts 85.84% 15 Missing ⚠️
app/port/schedule/SyncBinaryWorker.ts 21.42% 11 Missing ⚠️
app/repository/PackageVersionRepository.ts 87.95% 10 Missing ⚠️
app/core/service/PackageVersionFileService.ts 91.48% 8 Missing ⚠️
app/core/entity/PaddingSemVer.ts 88.00% 6 Missing ⚠️
app/core/service/PackageVersionService.ts 94.91% 6 Missing ⚠️
... and 11 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #610      +/-   ##
==========================================
- Coverage   97.45%   96.83%   -0.62%     
==========================================
  Files         168      180      +12     
  Lines       15691    17548    +1857     
  Branches     2018     2285     +267     
==========================================
+ Hits        15291    16993    +1702     
- Misses        400      555     +155     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

let latestStableVersion: string;
const sortedVersionList = specificVersions.sort(semverRcompare);
latestStableVersion = sortedVersionList.filter(i => !semverPrerelease(i))[0];
let latestStableVersion = semver.maxSatisfying(sortedAvailableVersions, '*');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sortedAvaiableVersionsmaxStatisfying 感觉保留一个就行?

现在 sortedAvailableVersions 还会用在日志输出里。

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sortedAvailableVersions是包含预发布版本和alpha版本beta版本这些,这些版本在排序上还是会高于稳定版;maxSatisfying的返回会过滤掉这些版本只保留最近的稳定版本。
大部分情况下依赖的latest都应该指向stable版本,只有少量依赖不这么做。

Copy link
Member

@elrrrrrrr elrrrrrrr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@elrrrrrrr elrrrrrrr self-requested a review November 28, 2023 12:48
Copy link
Member

@elrrrrrrr elrrrrrrr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -72,7 +73,7 @@ export class TaskRepository extends AbstractRepository {
if (!model || !model.data.specificVersions) return;
if (specificVersions) {
const data = model.data;
const combinedVersions = Array.from(new Set(data.specificVersions.concat(specificVersions)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new Set 的用法有什么问题?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

也没什么大问题,不过感觉lodash的函数语义更明确,可读性好一点,然后查了一下似乎性能也更好一点。所以就直接用lodash了

@fengmk2 fengmk2 merged commit acfd667 into master Nov 28, 2023
11 of 13 checks passed
@fengmk2 fengmk2 deleted the fix--incorrect-latest-tag branch November 28, 2023 14:47
fengmk2 pushed a commit that referenced this pull request Nov 28, 2023
[skip ci]

## [3.48.4](v3.48.3...v3.48.4) (2023-11-28)

### Bug Fixes

* incorrect latest tag in strict specific version ([#610](#610)) ([acfd667](acfd667))
@fengmk2
Copy link
Member

fengmk2 commented Nov 28, 2023

@hezhengxu2018 邀请你加入 cnpm core team https://github.com/orgs/cnpm/teams/core/members

fengmk2 pushed a commit that referenced this pull request Dec 7, 2023
[skip ci]

## [3.48.4](v3.48.3...v3.48.4) (2023-12-07)

### Bug Fixes

* incorrect latest tag in strict specific version ([#610](#610)) ([acfd667](acfd667))
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.

None yet

3 participants