如何让 Subversion(或任何程序)执行定期提交?

发布于 2024-07-17 04:04:16 字数 319 浏览 10 评论 0原文

我想配置我的计算机,以便每半小时自动提交我正在处理的程序。 我正在使用 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 技术交流群。

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

发布评论

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

评论(7

断舍离 2024-07-24 04:04:16

与明显流行的观点相反,我认为这是 svn 在作业环境中的一个很好的用途。

像 kdesvn 这样的工具(或者更好的是 tortoisesvn,但这只适用于 Windows)可能会让您深入了解日志视图、差异和责任视觉效果。

如果您使用的是 ubuntu,请从与您正在使用的控制台不同的控制台运行此 bash 脚本。

#!/bin/bash
while [ 1 ]
do
        # Do the commit
        svn ci --message "Automated commit" ~/yourworkingcopy

        # Wait until next commit time
        sleep 1800
done

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.

#!/bin/bash
while [ 1 ]
do
        # Do the commit
        svn ci --message "Automated commit" ~/yourworkingcopy

        # Wait until next commit time
        sleep 1800
done
想挽留 2024-07-24 04:04:16

您可以尝试运行 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.

半透明的墙 2024-07-24 04:04:16

我不会用这样一系列的自动提交来弄脏你的控制版本系统。 但我同意使用控制版本系统来提供该信息的想法。

然后,我的建议是:为您的软件使用一个存储库,并使用另一个存储库来存储自动提交。 工作完成后,将主存储库中的所有自动提交合并为一个逻辑提交。

使用 git,我会这样做:

  1. Repo 'foo':主存储库
    1. refs/heads/...:开发分支的位置
    2. refs/sessions/...:包含脏提交的工作位置。
  2. 您的工作副本:
    1. “git 初始化”
    2. “git 远程添加 foo git://foo/...;git fetch foo”
  3. 创建分支: "git checkout -b bar foo/master"
  4. 标记分支的开头: "git tag barbegin”
  5. 激活脚本:“while true; do git add -A .; git commit -m 'autocommit'; did”
  6. 我不会使用 cron 作业,因此您可以轻松激活/停用自动提交。
  7. 完成工作后完成工作
  8. ,立即停用脚本
  9. 提交挂起的更改
  10. ,分支栏中有很多自动提交,并且您已使用 barbegin 标记了分支的初始提交,
  11. 开始发布您的自动提交:
    1. “git tag barend”
    2. “git push foo barbegin:refs/sessions/你的用户id/会话id/begin”
    3. "git push foo barend:refs/sessions/你的用户 ID/会话 ID/end"
  12. now ,您已经发布了您的作品,您的讲师可以访问它
  13. 以更新您的 foo 存储库:
    1. “git rebase -i --onto barbegin barbegin”并按照描述进行这里
    2. 我会压缩所有提交:“最终,只能有一个”。
    3. "git push foo bar:master" # 只会推送一个提交
  14. clean:
    1. “git tag -d barbegin”
    2. “git tag -d barend”
    3. “git分支-d栏”

毕竟,我认为此类数据可能无法收集到有用的信息。 所以,我会尽量避免这个工作流程。 但如果真的需要的话,我会这样做。

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:

  1. Repo 'foo': the main repository
    1. refs/heads/...: the location of your development branches
    2. refs/sessions/...: the location of your work with dirty commits.
  2. Your working copy:
    1. "git init"
    2. "git remote add foo git://foo/...; git fetch foo"
  3. create the branch: "git checkout -b bar foo/master"
  4. tag the begining of the branch: "git tag barbegin"
  5. activate the script: "while true; do git add -A .; git commit -m 'autocommit'; done"
  6. I would not use a cron job, so you can activate/deactivate the autocommits easily.
  7. do your job
  8. after your job done, deactivate the script
  9. commit pending changes
  10. now, you have a lot of auto commits in branch bar, and you have tagged the initial commit of the branch with barbegin
  11. publish your auto commits:
    1. "git tag barend"
    2. "git push foo barbegin:refs/sessions/your user id/the session id/begin"
    3. "git push foo barend:refs/sessions/your user id/the session id/end"
  12. now, you have published your work and your lecturer may access it
  13. for update your foo repository:
    1. "git rebase -i --onto barbegin barbegin" and proceed as described here
    2. I would squash all commits: "in the end, there can be only one".
    3. "git push foo bar:master" # only one commit will be pushed
  14. cleaning:
    1. "git tag -d barbegin"
    2. "git tag -d barend"
    3. "git branch -d bar"

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.

So要识趣 2024-07-24 04:04:16

我不认为按时间表设置提交是一个特别好的主意。 特别是当您开始进行测试和持续集成时。 按设定的时间间隔提交将破坏构建,因为无法保证您将在时间范围内完成变更集。

如果您想自动提交,更好的方法是将提交作为构建过程本身的一部分。 只需将构建过程的最后一步提交到存储库即可。 这样,如果构建失败,您就不会提交垃圾。

所有类型的 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.

终遇你 2024-07-24 04:04:16

我会使用 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.

雨夜星沙 2024-07-24 04:04:16

如果您在 UNIX 风格上运行,请考虑创建一个 cron 作业来运行定期发出命令。

If you are running on a flavor of UNIX consider creating a cron job to run commands at a regular interval.

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