在干运行或警告模式下运行Gazelle

huangapple go评论83阅读模式
英文:

Run Gazelle in dry-run or warn mode

问题

上下文

有没有一种方法可以让gazelle以干运行模式运行?

我想创建一个CI作业,以干运行模式运行gazelle,并在gazelle发现任何更改时失败。

类似于这样的命令

$ bazel run //:gazelle --dry-run || exit 1

不同的方法

我认为可以通过运行该命令并查看git是否发现任何更改来实现,但我更喜欢一种非git的方法。

英文:

Context

Is there a way to have gazelle run in dry-run mode?

I'd like to create a CI job that runs gazelle with dry-run and fails if gazelle finds any changes.

Something like this

$ bazel run //:gazelle --dry-run || exit 1

Different Approach

I think this can be accomplished by running the command and seeing if git finds any changes, but I would prefer a non-git approach.

答案1

得分: 1

"-mode diff"标志在以"update"模式(默认模式)运行时应该能够完美工作:

https://github.com/bazelbuild/bazel-gazelle#fix-and-update

$ bazel run //:gazelle -- -mode diff || exit 1

我正在努力创建一个bazel测试,以强制执行这个操作,如果成功了,我会分享给你!

英文:

The -mode diff flag should work perfectly here when running in update mode (the default):

https://github.com/bazelbuild/bazel-gazelle#fix-and-update

$ bazel run //:gazelle -- -mode diff || exit 1

I'm working on making a bazel test that would enforce this, will share if/when I get something working!

huangapple
  • 本文由 发表于 2022年3月25日 15:27:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/71613426.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定