如何让 Subversion(或任何程序)执行定期提交?
我想配置我的计算机,以便每半小时自动提交我正在处理的程序。 我正在使用 svn 存储库,因此即使它只是一个每 30 分钟运行一次“svn ci”的脚本也没关系。 问题是我不知道该怎么做。
有人可以告诉我,或者指导我去做一些事情,让我让这个定期提交的东西发挥作用吗?
提前致谢。
编辑:抱歉,我似乎让人们困惑我为什么要这样做。 我想要这样做的唯一原因是因为我的一位讲师希望我们了解我们的代码如何随着时间的推移而发展,并且我认为使用 svn 来实现此目的将是一个好主意。 最新的提交是否有效并不重要。 它只需要显示我随着时间的推移对代码所做的更改。
I want to configure my computer so that say every half an hour it automatically commits the program I am working on. I am using a svn repository so even if it was just a script that ran 'svn ci' every 30 min that would be okay. The problem is that I don't know how to do that.
Could somebody please tell me, or direct me to something, that would let me get this periodic commit stuff working?
Thanks in advance.
EDIT: Sorry it appears that I have confused people as to why I would want to do this. The sole reason that I want to do this is because a lecturer of mine wants us to know how our code develops over time and I thought that it would be a great idea to use svn for this purpose. It does not matter if the latest commit works or not. It just has to show the changes I have made to the code over time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
与明显流行的观点相反,我认为这是 svn 在作业环境中的一个很好的用途。
像 kdesvn 这样的工具(或者更好的是 tortoisesvn,但这只适用于 Windows)可能会让您深入了解日志视图、差异和责任视觉效果。
如果您使用的是 ubuntu,请从与您正在使用的控制台不同的控制台运行此 bash 脚本。
Contrary to apparent popular opinion, I think this is a great use of svn, in the context of the assignment.
Tools like kdesvn (or even better, tortoisesvn, but that's only on windows) might give you great insight into what's happening with their log views, diffs and blame visuals.
If you're using ubuntu, run this bash script from a console that's separate to the one you're working on.
您可以尝试运行 shell 脚本的 cron 作业。 你使用什么操作系统?
但我很好奇你为什么要这样做。 您的提交应该包含功能或错误修复,而不是基于时间间隔。 您可能会在更改(针对一组文件)的过程中提交,这将使您的修订毫无用处。
You could try a cron job that runs a shell script. What OS are you on?
But I'm curious as to why you'd want to do this. Your commits should consist of pieces of functionality or bug fixes, and not based on a time interval. You're likely to commit in the middle of a change (on a group of files) which will render your revisions useless.
我不会用这样一系列的自动提交来弄脏你的控制版本系统。 但我同意使用控制版本系统来提供该信息的想法。
然后,我的建议是:为您的软件使用一个存储库,并使用另一个存储库来存储自动提交。 工作完成后,将主存储库中的所有自动提交合并为一个逻辑提交。
使用 git,我会这样做:
毕竟,我认为此类数据可能无法收集到有用的信息。 所以,我会尽量避免这个工作流程。 但如果真的需要的话,我会这样做。
I would not dirty your control version system with such series of auto commits. But I agree with the idea of using a control version system to provide that information.
Then, my suggestion is: use a repository for your software and another one for store the auto commits. When the work is done, merge all auto commits in the main repository in only one logical commit.
With git, I would do this:
After all this, I think no useful information may be gathered with such kind of data. So, I would try to avoid this workflow. But if really needed, I would do that way.
我不认为按时间表设置提交是一个特别好的主意。 特别是当您开始进行测试和持续集成时。 按设定的时间间隔提交将破坏构建,因为无法保证您将在时间范围内完成变更集。
如果您想自动提交,更好的方法是将提交作为构建过程本身的一部分。 只需将构建过程的最后一步提交到存储库即可。 这样,如果构建失败,您就不会提交垃圾。
所有类型的 make 都完全有可能,而且我知道 Visual Studio 有构建前和构建后事件,可以将其设置为执行类似的操作。 所以我很确定大多数现代 IDE 都可以处理这个问题。
作为对这个问题的特别考虑:
将提交挂钩移至流程的开头,这样您就可以跟踪您何时搞砸以及如何修复错误。
I don't think setting commits on a timed schedule is a particularly good idea. Especially if you start getting into testing and continuous integration. Committing at set intervals will break the build because there is no guarantee that you will have completed the changeset in the time frame.
A better way, if you want to auto-commit is to make the commit part of the build process itself. Just make the last step of the build process a commit to the repository. That way, if the build fails, you won't commit garbage.
Totally possible with all flavors of make and I know Visual Studio has pre and post build events that can be set to do something like this. So I'm pretty sure that most modern IDEs can handle this.
As a special consideration for this problem in particular:
Move the commit hook to the beginning of the process so you can track when you mess up royally as well and how you come to fix the errors.
我会使用 Subversion,但我会养成处理单个更改并将其提交到存储库的习惯。
这样,如果讲师愿意,他不仅可以查看更改的内容,还可以查看更改的原因。 我想这会更有用。
I would use Subversion, but I would instead just get into the habit of working on single changes, and comitting those to a repository.
This way the lecturer, if he wants to, can look at not only what changed, but why it changed. This would be much more useful I would imagine.
你可以试试这个食谱:
http://code.activestate。 com/recipes/577570-watch-directory-and-do-periodic-commits-to-subvers/
You can try this recipe:
http://code.activestate.com/recipes/577570-watch-directory-and-do-periodic-commits-to-subvers/
如果您在 UNIX 风格上运行,请考虑创建一个 cron 作业来运行定期发出命令。
If you are running on a flavor of UNIX consider creating a cron job to run commands at a regular interval.