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

git describe --tag 代替现有的git.count() % 65535 作为版本号 #1890

Closed
trim21 opened this issue May 24, 2024 · 13 comments
Closed
Labels
enhancement New feature or request

Comments

@trim21
Copy link

trim21 commented May 24, 2024

现在的 git.count() 是用过 git rev-list --all --count 计算出来的,其他分支的commit也会计算在内,导致如果本地有其他分支的话哪怕是同一个commit也会产生不同的版本数字。

建议使用 git describe --tag 代替,这样生成版本号是 v1.6.1.2657-7-g6f07eb1a,从上一个 tag 开始计算的,不会受到其他分支的影响。

有一个潜在问题是目前的 git.count() % 65535 是 2664,所以会从2664倒退回2657。可能造成一些困扰。

@trim21 trim21 added the enhancement New feature or request label May 24, 2024
@Rhilip
Copy link
Collaborator

Rhilip commented May 25, 2024

v1.6.1.2657-7-g6f07eb1a 不能用于version字段,会导致用户无法加载插件

image

refs: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/version#version_format

@trim21
Copy link
Author

trim21 commented May 25, 2024

v1.6.1.2657后面的部分截掉作为manifest的版本呢?把完整的显示在左下角。

2664和2657中间的差可以考虑发10个空白commit跳过去(

@Rhilip
Copy link
Collaborator

Rhilip commented May 25, 2024

感觉也不是很好。
如果仅考虑当前分支的commit数量,可以直接弃用git-rev-sync提供的git.count()方法,改用 node:child_process 的 childProcess.spawnSync 方法执行 git rev-list HEAD --count 命令会好些。
还可以减少dev依赖。

import childProcess from "node:child_process";
const build_number = childProcess.spawnSync('git', ['rev-list','HEAD','--tag']).stdout.toString('utf8').replace(/^\s+|\s+$/g, '');

@trim21
Copy link
Author

trim21 commented May 25, 2024

还有一个相关的问题是PR会产生一个比dev分支还大的版本号,很多用户只看数字结果安装了PR的版本。

@Rhilip
Copy link
Collaborator

Rhilip commented May 25, 2024

  1. 我一贯是不推荐普通用户使用pr过程中的action构建产物。
  2. 从pr的角度,如果使用merge、rebase(目前使用)而非squash(合并成一次),就dev分支来说,最终还是会导致第四位patch version数字变大的,我个人是认为不用做大的修改。

一个折中的操作,我觉得可以这样:
目前在actions/checkout@v4,为了获取git rev-list --all --count的值,我们使用的是 fetch-depth: 0
则可以使用 github.event_name 等字段来判断,如果是 pull_request 类型,则将fetch-depth值更新为 1,这样对pr过程中的action构造产物,其构建的版本号永远是 1.6.1.1
而对于正常dev更新的,其版本号是1.6.1.2853这样递增的结果。

测试例见:

@trim21
Copy link
Author

trim21 commented May 25, 2024

感觉可以

@cddjr
Copy link

cddjr commented May 25, 2024

一个折中的操作,我觉得可以这样:

目前在actions/checkout@v4,为了获取git rev-list --all --count的值,我们使用的是 fetch-depth: 0

则可以使用 github.event_name 等字段来判断,如果是 pull_request 类型,则将fetch-depth值更新为 1,这样对pr过程中的action构造产物,其构建的版本号永远是 1.6.1.1

而对于正常dev更新的,其版本号是1.6.1.2853这样递增的结果。

赞同这个折中方案,避免pr的版本号大于dev

@gm-fire
Copy link

gm-fire commented May 25, 2024

其实看action的标签也就可以了啊

@trim21
Copy link
Author

trim21 commented May 25, 2024

其实看action的标签也就可以了啊

你说的有道理,但就是有人不看...

Rhilip added a commit that referenced this issue May 25, 2024
@Rhilip Rhilip closed this as completed May 25, 2024
@trim21
Copy link
Author

trim21 commented May 25, 2024

咋close了,本地自己编译的版本号不对的问题还没解决(

@cddjr
Copy link

cddjr commented May 25, 2024

@gm-fire 通常是只懂得看版本号,只认数字大小

@Rhilip Rhilip reopened this May 25, 2024
@Rhilip
Copy link
Collaborator

Rhilip commented May 25, 2024

咋close了,本地自己编译的版本号不对的问题还没解决(

我觉得会本地编译的人,应该知道build base吧

@IITII
Copy link
Member

IITII commented Jun 6, 2024

我大体上同意 @Rhilip 的做法, #1890 (comment)
本地 commit 存在 merge 和 squash 单纯靠 git count 算出来肯定是会变的, 不过对于会编译会 commit 的人, 这个好像也不是什么问题. 或者在版本号里面加一位用于区分 release, daily build, pr, mr, local build, dev

wegood9 added a commit to wegood9/PT-Plugin-Plus that referenced this issue Jun 14, 2024
* fix(audiences): 支持Microsoft Edge浏览器获取做种体积 (pt-plugins#1851)

Co-authored-by: Shl-Cool <cool@cool.com>

* fix: chrome as onBeforeSendHeaders default

* build: full use vite to build pkg

* build: ignore extra `README.md` file in resource folder

* fix(ts): add shim-env for vite

* fix(SSD): 修复SSD副标题显示问题

同时增加 MiniDB 标签

* deps: remove webpack loader

* deps: use vite plugin to provide node polyfills

* feat (x-ite): 搜索关键词替换, 结果更精确 (pt-plugins#1860)

* feat: 启用 `searchEntryConfig.area.keyAutoMatch` 正则 Unicode 支持

* feat: 增加禁用 `searchEntryConfig.area` 选项

* feat: support x-ite (pt-plugins#1862)

* build: disable rollup treeshake because we use eval

* fix(mt): 拖放链接到助手图标无效 pt-plugins#1870

* feat: qb 自定义标签 pt-plugins#1883

* 不需要留空即可,逗号分隔. 比如: PTPP,MOVIEPILOT

* fix(mt): keep upload task

* fix(hh): level requirements

* fix(hdh): pt-plugins#1850 level requirements

* fix(ss): pt-plugins#1736 uploads

* site(YemaPT): 初步支持搜索和部分个人信息获取

* ci: lock pr action build version to `1.x.x.1`

closed: pt-plugins#1890

* fix(hdd): bonusPerHour

* fix fsm

* fix(fsm): join time

* fix(pig): HnR count (pt-plugins#1898)

* fix(fsm): search result link

* feat: 适配新站点ToSky (pt-plugins#1886)

* feat(blu): remove domain xyz

* fix(userData): 升级用户数据时,先并入最新的hosts下数据(如有)

may closed: pt-plugins#1907

* fix(ad): seeding and seedingSize

* feat(u3d): seeding status (pt-plugins#1901)

* feat(blu): remove domain xyz

* feat(u3d): support seeding status

* fix(u3d): remove wrong progress

* feat(aihter): support complete status

* Revert "feat(aihter): support complete status"

This reverts commit 6735f83.

* feat(u3d): support more status

* fix(u3d): unsuitable judgment conditions

* fix(bhd): unsuitable judgment condition

* fix(u3d): progess

* fix(xhb): 更新升级条件

* fix(mt): 搜索页下载种子到本地 pt-plugins#1808

---------

Co-authored-by: SHL-COOL <31879581+SHL-COOL@users.noreply.github.com>
Co-authored-by: Shl-Cool <cool@cool.com>
Co-authored-by: IITII <ccmejx@gmail.com>
Co-authored-by: Rhilip <admin@rhilip.info>
Co-authored-by: 栽培者 <ronggang.zhou@gmail.com>
Co-authored-by: Rhilip <rhilipruan@gmail.com>
Co-authored-by: Rhilip <Rhilip@users.noreply.github.com>
Co-authored-by: Dawei Huang <davidxuang@live.com>
Co-authored-by: Trim21 <trim21.me@gmail.com>
Co-authored-by: fzlins <fzlins2013@gmail.com>
Co-authored-by: Hui-Shao <31568606+hui-shao@users.noreply.github.com>
Co-authored-by: halehal <haleyhrid@gmail.com>
Co-authored-by: ted423 <priston910423@gmail.com>
Co-authored-by: LovelyBaibai <1633480356@qq.com>
@Rhilip Rhilip closed this as not planned Won't fix, can't repro, duplicate, stale Jul 2, 2024
wegood9 added a commit to wegood9/PT-Plugin-Plus that referenced this issue Sep 21, 2024
* fix(audiences): 支持Microsoft Edge浏览器获取做种体积 (pt-plugins#1851)

Co-authored-by: Shl-Cool <cool@cool.com>

* fix: chrome as onBeforeSendHeaders default

* build: full use vite to build pkg

* build: ignore extra `README.md` file in resource folder

* fix(ts): add shim-env for vite

* fix(SSD): 修复SSD副标题显示问题

同时增加 MiniDB 标签

* deps: remove webpack loader

* deps: use vite plugin to provide node polyfills

* feat (x-ite): 搜索关键词替换, 结果更精确 (pt-plugins#1860)

* feat: 启用 `searchEntryConfig.area.keyAutoMatch` 正则 Unicode 支持

* feat: 增加禁用 `searchEntryConfig.area` 选项

* feat: support x-ite (pt-plugins#1862)

* build: disable rollup treeshake because we use eval

* fix(mt): 拖放链接到助手图标无效 pt-plugins#1870

* feat: qb 自定义标签 pt-plugins#1883

* 不需要留空即可,逗号分隔. 比如: PTPP,MOVIEPILOT

* fix(mt): keep upload task

* fix(hh): level requirements

* fix(hdh): pt-plugins#1850 level requirements

* fix(ss): pt-plugins#1736 uploads

* site(YemaPT): 初步支持搜索和部分个人信息获取

* ci: lock pr action build version to `1.x.x.1`

closed: pt-plugins#1890

* fix(hdd): bonusPerHour

* fix fsm

* fix(fsm): join time

* fix(pig): HnR count (pt-plugins#1898)

* fix(fsm): search result link

* feat: 适配新站点ToSky (pt-plugins#1886)

* feat(blu): remove domain xyz

* fix(userData): 升级用户数据时,先并入最新的hosts下数据(如有)

may closed: pt-plugins#1907

* fix(ad): seeding and seedingSize

* feat(u3d): seeding status (pt-plugins#1901)

* feat(blu): remove domain xyz

* feat(u3d): support seeding status

* fix(u3d): remove wrong progress

* feat(aihter): support complete status

* Revert "feat(aihter): support complete status"

This reverts commit 6735f83.

* feat(u3d): support more status

* fix(u3d): unsuitable judgment conditions

* fix(bhd): unsuitable judgment condition

* fix(u3d): progess

* fix(xhb): 更新升级条件

* fix(mt): 搜索页下载种子到本地 pt-plugins#1808

* fix: remove wrong config

pt-plugins#1798

* fix: category name

使用官方名

* feat(hdb): support exclusive tag

* fix(hddolby): noseed tag

* fix(ssd): system message count.

* feat(yemapt):  update level name and requirements and add extra info

* fix(yemapt): update level name and requirements (pt-plugins#1919)

* fix(yemapt): add user uploads size / seeding count and size / bonus per hour

* fix(TL): message count

* fix(pterclub): fix uploads count and rename the level name

* Revert "fix(pterclub): fix uploads count and rename the level name"

This reverts commit 68604b8.

* fix(m-team):使用api域名 (pt-plugins#1917)

* 修改馒头请求域名

* 修复种子页无法下载到

* 用户数据切换为api域名

* 搜索切换为api域名、支持种子页下载全部

* 增加api站点配置

* 适配搜索页跳转到网站

* fix(pterclub): fix uploads count and rename the level name

* fix(pterclub): make the user level name display consistent with the actual

* fix(pterclub): uploads torrent count exclude dead torrent

* fix(pter): add back check=checked

* fix(acm): domain change

* fix(mt): 流控调整 pt-plugins#1910

* feat: site down, remove ptlsp

* feat: oshen remove uneed cdn

* fix(dt): domain change

* fix(dt): domain change

* fix: formatSize

* fix(mt): 重构批量下载, 移除 `复制下载链接` 功能 pt-plugins#1910

* 优化推送消息提醒
* 复制下载链接, 功能上和解析推送种子冲突, 而且解析推送种子更方便.

* fix(mt): fix mt refresh rate limited (pt-plugins#1938)

* fix: mt refresh fails due to rate limiting

pt-plugins#1936

* change the delay from 8000 to 2100

* revert linter changes

* feat: some site change

pt-plugins#1888

* revert: collaborator

* fix(jptv): levelRequirements

* fix(putao): seeding number

* sitedown: hdfunc(hdzone)

* sitedown: hdmayi

* fix(HDDolby): levelRequirements pt-plugins#1922

* doc: update readme

* fix(star-space): 修复数据获取和搜索功能

* 修复数据获取错误

* 修复imdb搜索

* fix(ptt): user level info. pt-plugins#1955

* fix: "G"/"T" instead by "GB"/"TB" (pt-plugins#1963)

* feat: 2024-07-29 ptt user level change

* fix(mt): use new apil myPeerStatistics

* fix(ssd): levelRequirements pt-plugins#1970

* fix(HDB): update seeding size selector

* fix(btschool): 修复数据获取

* 修复数据获取

* fix(star-space):修复搜索结果时间格式不正确 (pt-plugins#1974)

* fix(star-space):修复搜索结果时间格式不正确

* 修改时间函数

* feat(PTP): add freeleech tag

* fix(Luminance): plugins, searchEntryConfig, user info

* feat(pornbay): new site

* feat(cathode-ray.tube): new site

* fix(ptvicomo): 修复搜索种子详情不显示

* feat(bitporn): new site

* fix(fsm): send torrent in detail page

* feat(milkie): new site

* fix(milkie): auth with api key

* feat: authTokenTip

* feat(superbits): searchEntry

* feat(digitalcore): searchEntry

* fix(fsm): joinTime

* fix(fsm): default apiCdn

* feat: getInfoAjaxCache

* fix pt-plugins/issues/1744

* Create .gitattributes

* fix(kamept): getInfoAjaxCache pt-plugins#1995

* fix(tjupt): 站点搜索范围功能失效

* update categories.[*].result format: &cat=$id$ changed to &cat[]=$id$

* feat:调整图表样式 (pt-plugins#1994)

* feat:调整图表样式

---------

Co-authored-by: SHL-COOL <31879581+SHL-COOL@users.noreply.github.com>
Co-authored-by: Shl-Cool <cool@cool.com>
Co-authored-by: IITII <ccmejx@gmail.com>
Co-authored-by: Rhilip <admin@rhilip.info>
Co-authored-by: 栽培者 <ronggang.zhou@gmail.com>
Co-authored-by: Rhilip <rhilipruan@gmail.com>
Co-authored-by: Rhilip <Rhilip@users.noreply.github.com>
Co-authored-by: Dawei Huang <davidxuang@live.com>
Co-authored-by: Trim21 <trim21.me@gmail.com>
Co-authored-by: fzlins <fzlins2013@gmail.com>
Co-authored-by: Hui-Shao <31568606+hui-shao@users.noreply.github.com>
Co-authored-by: halehal <haleyhrid@gmail.com>
Co-authored-by: ted423 <priston910423@gmail.com>
Co-authored-by: LovelyBaibai <1633480356@qq.com>
Co-authored-by: Bright-W <coolup9@gmail.com>
Co-authored-by: 刘志龙 <zhilong0327@gmail.com>
Co-authored-by: fzlins <100051558+fzlins@users.noreply.github.com>
Co-authored-by: Tian J <jiang925@hotmail.com>
Co-authored-by: hui-shao <hui-shao@outlook.com>
Co-authored-by: SHL-COOL <shenhuilin0@gmail.com>
Co-authored-by: dragon <dragon@dragon.com>
Co-authored-by: Araputa <6489501892@protonmail.com>
Co-authored-by: Tom Yang <20330249+tomyangsh@users.noreply.github.com>
Co-authored-by: mitlearn <64004444+mitlearn@users.noreply.github.com>
Co-authored-by: ixff <150003322+ixff@users.noreply.github.com>
Co-authored-by: dragon <37643710+declandragon@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants