如何保护代码存储库免受破坏或错误提交?

发布于 2024-10-07 10:51:29 字数 433 浏览 0 评论 0原文

您如何或如何尝试保护您的源代码存储库免受引入错误或破坏构建的提交?似乎在提交时进行强制回归测试可以在很大程度上防止错误渗透到多个开发人员开发的项目中。然而,大多数常见的代码版本控制工具不提供这方面的任何功能。

这是我尝试过的一种方法。我创建了 subversion 预提交挂钩来生成项目的副本,其中合并了待提交的更改,然后对该副本运行语法检查和单元测试。如果任何测试失败,提交将被拒绝,语法检查器或单元测试的结果将被拒绝,以便为进行该提交的开发人员提供反馈。如果语法检查器和单元测试通过,提交将被接受。它有效,但代价是它使提交变得非常慢。如果代码版本控制软件提供更好的集成来促进这一点,而不是在预提交时运行外部程序,我认为速度可以提高。

我正在寻找您用来实现此目标的方法,思考为什么这是一个好主意或坏主意,或者使用代码版本控制工具的经验,这些工具为代码签入时的回归测试/构建测试提供支持。此外,它有多重要向你承诺的速度?

How do you or have tried to protect your source code repositories from commits that introduce bugs or break builds? It seems that forced regression testing upon commit can go a long way towards preventing bugs from creeping into projects worked on by multiple developers. However, most common code versioning tools don't offer any features in this area.

Here is one method I have experimented with. I created subversion pre-commit hooks to generate a copy of the project with pending commit's changes merged in, then it ran syntax check and unit tests on this copy. If any of the tests failed, commit would get rejected with results of the syntax checker or unit testing to provide feedback to developer making that commit. If syntax checker and unit tests passed, commit would get accepted. It worked but the trade off was that it made commits really slow. If code versioning software provided better integration to facilitate this other than running external programs on pre-commit, I think speed could be improved.

I'm looking for methods you've used to achieve this, thoughts on why this is a good or a bad idea, or experiences with code versioning tools that provide support for regression testing / build testing on code check in. Also how important is speed of commits to you?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

绝對不後悔。 2024-10-14 10:51:29

您应该使用某种形式的持续集成,其中环境正在使用 Hudson 、CruiseControl 或其他工具来促进此行为。

You should be making use of some form of Continuous Integration where the environment is making use of Hudson, CruiseControl, or other tool to facilitate this behavior.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文