Jvlegod/go2spec:feat/spdx-file-contributor-author
master
本次更改是添加了提交签名的选项
GO2SPEC_AUTHOR
姓名 <邮箱>
-author
手动演示如下.
假设已经构建完了工程, 并安装.
go build -o /tmp/go2spec .
以 github.com/xeipuuv/gojsonschema 为例.
tmp=$(mktemp -d /tmp/go2spec-pack-no-author.XXXXXX) cd "$tmp" env -u GO2SPEC_AUTHOR /tmp/go2spec pack github.com/xeipuuv/gojsonschema spec=$(find "$tmp" -name '*.spec' -print -quit) echo "$spec" rg -n '^# SPDX-FileContributor:' "$spec" || echo "no contributor"
no contributor
tmp=$(mktemp -d /tmp/go2spec-pack-env.XXXXXX) cd "$tmp" GO2SPEC_AUTHOR="Env Author <env-author@example.invalid>" \ /tmp/go2spec pack github.com/xeipuuv/gojsonschema spec=$(find "$tmp" -name '*.spec' -print -quit) rg -n '^# SPDX-FileContributor:' "$spec"
3:# SPDX-FileContributor: Env Author <env-author@example.invalid>
tmp=$(mktemp -d /tmp/go2spec-pack-cli.XXXXXX) cd "$tmp" GO2SPEC_AUTHOR="Env Author <env-author@example.invalid>" \ /tmp/go2spec pack \ -author "CLI Author <cli-author@example.invalid>" \ github.com/xeipuuv/gojsonschema spec=$(find "$tmp" -name '*.spec' -print -quit) rg -n '^# SPDX-FileContributor:' "$spec"
3:# SPDX-FileContributor: CLI Author <cli-author@example.invalid>
tmp=$(mktemp -d /tmp/go2spec-pack-bad.XXXXXX) cd "$tmp" /tmp/go2spec pack \ -author "Bad Author" \ github.com/xeipuuv/gojsonschema
2026/07/19 15:37:21 resolve author: author must use Name <email> format
tmp=$(mktemp -d /tmp/go2spec-update-no-author.XXXXXX) cd "$tmp" GO2SPEC_AUTHOR="Seed Author <seed-author@example.invalid>" \ /tmp/go2spec pack github.com/xeipuuv/gojsonschema spec=$(find "$tmp" -name '*.spec' -print -quit) perl -0pi -e 's/^(Version:\s*)\S+/${1}0.0.1/m; s/^# SPDX-FileContributor: .*\n//m' "$spec" env -u GO2SPEC_AUTHOR /tmp/go2spec update "$tmp" rg -n '^Version:\s*1\.2\.0' "$spec" rg -n '^# SPDX-FileContributor:' "$spec" || echo "no contributor"
10:Version: 1.2.0 no contributor
tmp=$(mktemp -d /tmp/go2spec-update-env.XXXXXX) cd "$tmp" env -u GO2SPEC_AUTHOR /tmp/go2spec pack github.com/xeipuuv/gojsonschema spec=$(find "$tmp" -name '*.spec' -print -quit) perl -0pi -e 's/^(Version:\s*)\S+/${1}0.0.1/m' "$spec" GO2SPEC_AUTHOR="Update Author <update-author@example.invalid>" \ /tmp/go2spec update "$tmp" rg -n '^# SPDX-FileContributor:' "$spec"
4:# SPDX-FileContributor: Update Author <update-author@example.invalid>
tmp=$(mktemp -d /tmp/go2spec-update-same.XXXXXX) cd "$tmp" GO2SPEC_AUTHOR="Same Author <same-author@example.invalid>" \ /tmp/go2spec pack github.com/xeipuuv/gojsonschema spec=$(find "$tmp" -name '*.spec' -print -quit) perl -0pi -e 's/^(Version:\s*)\S+/${1}0.0.1/m' "$spec" GO2SPEC_AUTHOR="Same Author <same-author@example.invalid>" \ /tmp/go2spec update "$tmp" rg -n '^# SPDX-FileContributor:' "$spec"
3:# SPDX-FileContributor: Same Author <same-author@example.invalid>
tmp=$(mktemp -d /tmp/go2spec-update-second.XXXXXX) cd "$tmp" GO2SPEC_AUTHOR="First Author <first-author@example.invalid>" \ /tmp/go2spec pack github.com/xeipuuv/gojsonschema spec=$(find "$tmp" -name '*.spec' -print -quit) perl -0pi -e 's/^(Version:\s*)\S+/${1}0.0.1/m' "$spec" GO2SPEC_AUTHOR="Second Author <second-author@example.invalid>" \ /tmp/go2spec update "$tmp" rg -n '^# SPDX-FileContributor:' "$spec"
3:# SPDX-FileContributor: First Author <first-author@example.invalid> 4:# SPDX-FileContributor: Second Author <second-author@example.invalid>
tmp=$(mktemp -d /tmp/go2spec-update-cli.XXXXXX) cd "$tmp" env -u GO2SPEC_AUTHOR /tmp/go2spec pack github.com/xeipuuv/gojsonschema spec=$(find "$tmp" -name '*.spec' -print -quit) perl -0pi -e 's/^(Version:\s*)\S+/${1}0.0.1/m' "$spec" GO2SPEC_AUTHOR="Env Author <env-author@example.invalid>" \ /tmp/go2spec update \ -author "CLI Author <cli-author@example.invalid>" \ "$tmp" rg -n '^# SPDX-FileContributor:' "$spec"
4:# SPDX-FileContributor: CLI Author <cli-author@example.invalid>
Signed-off-by: Jvle <keke.oerv@isrc.iscas.ac.cn>
"SPDX-FileContributor" 应该只有人类进行手动更改的情况下才加上,直接使用的话不应该加上这个;如果这样看的话,这也意味着不应该由机器生成?🤔
确实, 如果这么来看, 这个 feature 确实和工具的初衷相违背了
No dependencies set.
The note is not visible to the blocked user.
本次更改是添加了提交签名的选项
GO2SPEC_AUTHOR配置签名, 内容为姓名 <邮箱>-author选项覆盖环境变量的签名-author和GO2SPEC_AUTHOR为空则不添加签名手动演示如下.
假设已经构建完了工程, 并安装.
以 github.com/xeipuuv/gojsonschema 为例.
pack, 不设置 author, 不生成 contributor
pack, 使用 GO2SPEC_AUTHOR
pack, -author 优先于环境变量
pack, author 格式错误会报错
update, 不设置 author, 正常更新但不补 contributor
update, 使用 GO2SPEC_AUTHOR 追加 contributor
update, 同 author 不重复
update, 不同 author 追加新署名
update, -author 优先于环境变量
Feat/spdx file contributor authorto feat: add contributor author"SPDX-FileContributor" 应该只有人类进行手动更改的情况下才加上,直接使用的话不应该加上这个;如果这样看的话,这也意味着不应该由机器生成?🤔
确实, 如果这么来看, 这个 feature 确实和工具的初衷相违背了
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.