使用 SVN(或 git)自动提交文件修改?

发布于 2024-11-03 09:29:05 字数 247 浏览 0 评论 0原文

我几天来一直在阅读和寻找解决方案,但没有找到任何适合我需求的东西。

我们经常更新网站,这些网站由设计师和开发人员更新,大多数时候他们不会将更改提交到 SVN。

我正在研究持续集成类型的解决方案,当临时服务器上的“版本化”文件更新时,它会自动提交到 SVN。

CruiseControl 和我看过的其他工具不会这样做;有没有一个工具可以做到这一点,或者我们可以使用更好的流程?

感谢您的帮助!

克里斯

I've been reading and searching for a solution for a couple of days but haven't found anything that suits my needs.

We have frequently updated sites being updated by designers and developers that most of the time don't commit their changes to SVN.

I'm looking at continuous integration type solutions where, when a "versionned" file on the staging server gets updated, it is automatically committed to SVN.

CruiseControl and other tools I've looked at don't do this; is there a tool that does this or a better process we could use?

Thanks for any help!

Chris

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

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

发布评论

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

评论(5

飘逸的'云 2024-11-10 09:29:05

我真的很喜欢你说的“更好的流程”,因为答案是肯定的。

让您的设计师和每个人都在存储库中工作。无论您选择 SVN 还是 git 还是其他东西,都没关系,但要使其成为“权威”副本。这样做最终会免除您的麻烦,因为您将拥有所有更改的清晰历史记录,并且可以随时恢复。

我为网页设计商店设置一些环境的方式是使用与您建议的系统相反的系统,它的工作原理如下:

  • 所有设计师都在网站的签出副本上工作,并根据需要进行更改和提交/更新。
  • 提交时,存储库将站点的副本推送到临时服务器,该服务器的配置几乎与生产环境相同。
  • 如果该网站正在登台运行,那么它在实时服务器上运行的信心非常高。
  • 准备就绪后,可以将临时服务器上的站点副本复制到实时状态,现在您已经以非常负责任的方式更新了站点,并且拥有所有更改的历史记录。 (为此,我喜欢使用 rsync,您可以按照您认为合适的方式使其工作)

我希望这可以帮助您在某种程度上思考您的流程。

回到你原来的问题:如果你真的不想改变你的进程,你可以设置一个 cron,它每隔几分钟运行一次,并添加/提交所有已更改的文件,这应该可以工作。但我不喜欢这样,因为现在你没有有意义的提交消息,并且更改历史记录也可能没有意义。当人们工作和保存文件时,他们没有意识到它们是在什么时候提交的,所以现在存储库中很可能存在处于损坏状态的修订,现在如何找到未损坏的修订?选择“自动化”提交显然不是最干净的解决方案。

I really like that you said "better process" because the answer there is yes.

Have your designers and everyone work from the repo. It doesn't matter if you choose SVN or git or something else, but make that the "authoritative" copy. Doing so will eventually save you headaches as you'll have a clear history of all changes, and can always revert.

The way I have setup a few environments for web design shops is with a system opposite to what you propose, it works like this:

  • All designers work on checkedout copies of sites, and make changes and commit/update as needed.
  • On commit, the repository pushes a copy of the site to a staging server, which is configured nearly identical to production.
  • If the site is working on staging, there is very high confidence that it will work on the live server.
  • When ready, the copy of the site on the staging server can be copied over to live, and now you have updated your site in a very responsible way and you have a history of all of your changes. (For this I like to use rsync, you can make it work however you see fit)

I hope this helps you think about your process somewhat.

Back to your original question: If you really don't want to change your process, you could set up a cron, that runs every few minutes and adds/commits all files that haves changed, and that should work. But I don't like this because now you don't have meaningful commit messages and the change history also might not make sense. As people are working and saving files, they aren't realizing at what point they are being committed, so more than likely there are now revisions in the repository that are a broken state, and now how do you find revisions that aren't broken? Choosing to "automate" the committing is obviously not the cleanest solution.

懷念過去 2024-11-10 09:29:05

我相信(虽然我还没有尝试过)你可以为看门狗编写一个观察者( http://packages. python.org/watchdog/ )将为您完成提交。

然而,我同意 ctcherry 的观点,即在破碎的状态下你会得到很多保存。你确实需要改变你的流程。

I believe (though I haven't tried it) that you could write an observer for watchdog ( http://packages.python.org/watchdog/ ) that would do the commit for you.

However, I agree with ctcherry that you are going to get a lot of saves in a broken state. You really need to change your process.

狼亦尘 2024-11-10 09:29:05

听起来您想在 Subversion 中使用 WebDAV 进行自动版本控制。 Subversion 和 WebDAV

我以前使用过这种方法。它的好处是你可以像 Windows/Linux 网络共享一样设置它。非技术人员只是将其视为存储文件的网络驱动器。每当用户在那里保存文档/文件时,它就会被静默提交。

Git 可能有类似的东西,但我没有这方面的经验。

Sounds like you want to use WebDAV for Autoversioning in Subversion. Subversion and WebDAV

I have used this methodology before. It is nice in that you can set it up like a windows/linux network share. Non-technical person just sees it as a network drive to store files on. Whenever the user saves a document/file there it is silently committed.

Git may have something similar, but I have not experience with that.

桃扇骨 2024-11-10 09:29:05

CruiseControl 和我拥有的其他工具
看了不要这样做

我不敢苟同。如果您要配置 阻止调用 SVN 命令行工具来为您提交代码,这不正是您所要求的吗?您可以使用 节点来确定哪些文件被修改。

现在,虽然你可以这样做,但我也同意 @ctcherry 的观点,如果你直接投入生产,这可能会导致破坏代码被推送。

CruiseControl and other tools I've
looked at don't do this

I would beg to differ. If you were to configure an <exec> block to make a call to the SVN command line tools to commit the code for you, wouldn't that do exactly what you're asking? You can use the <filesystem> node to determine which files were modified.

Now, though you could do this, I too agree with @ctcherry that this could cause breaking code to be pushed if you're going straight to production with this.

乄_柒ぐ汐 2024-11-10 09:29:05

在开发者网站上,你可以开发一个工具来支持这个东西,你可以看到下面的代码,下面的代码支持你如何在SVN上进行自动提交,看看:)

任何反馈或问题,留下你的评论,我们可以讨论它

请参阅此处的代码:

    public static string AppTitle = "Auto Commit";

    // AddFileToSVN
    public static bool AddFileToSVN(string strLogFile, string path, 
                                         Timer myTimer)
    {
        try
        {
            using (SharpSvn.SvnClient client = new SharpSvn.SvnClient())
            {
                Collection changeFiles = new 
                                Collection();
                client.GetStatus(path, out changeFiles);

                foreach (SharpSvn.SvnStatusEventArgs changeFile in 
                                                     changeFiles)
                {
                    if (changeFile.LocalContentStatus == 
                                       SharpSvn.SvnStatus.Missing)
                    {
                        client.Delete(changeFile.Path);
                        WriteLog(strLogFile, changeFile.Path + " Removed - 
                                 Missing files (that are not in filesystem)");

                        myTimer.Enabled = false;
                    }

                    if (changeFile.LocalContentStatus == 
                                     SharpSvn.SvnStatus.NotVersioned)
                    {
                        client.Add(changeFile.Path);
                        WriteLog(strLogFile, changeFile.Path + " Added - 
                                   This file is new in filesystem!");

                        myTimer.Enabled = false;
                    }
                }
                return true;
            }
        }
        catch (Exception ex)
        {
            myTimer.Enabled = true;
            WriteLog(strLogFile, ex);
            return false;
        }
    }

    // CommitToSVN
    public static bool CommitToSVN(string strLogFile, string workingcopy, 
                                          string message, Timer myTimer)
    {
        using (SharpSvn.SvnClient client = new SharpSvn.SvnClient())
        {
            SharpSvn.SvnCommitArgs args = new SharpSvn.SvnCommitArgs();

            args.LogMessage = message;
            args.ThrowOnError = true;
            args.ThrowOnCancel = true;

            try
            {
                myTimer.Enabled = true;
                return client.Commit(workingcopy, args);
            }
            catch (Exception ex)
            {
                myTimer.Enabled = true;
                WriteLog(strLogFile, ex);
                return false;
            }
        }
    }

查看更多信息:来自 此处

On the developer site, you can develop one tool for support this thing, you can see below code, the below code support you how to make Auto Commit on SVN, take a look :)

Any feedback or questions, leave your comment, we can discuss about it

Refer Code here:

    public static string AppTitle = "Auto Commit";

    // AddFileToSVN
    public static bool AddFileToSVN(string strLogFile, string path, 
                                         Timer myTimer)
    {
        try
        {
            using (SharpSvn.SvnClient client = new SharpSvn.SvnClient())
            {
                Collection changeFiles = new 
                                Collection();
                client.GetStatus(path, out changeFiles);

                foreach (SharpSvn.SvnStatusEventArgs changeFile in 
                                                     changeFiles)
                {
                    if (changeFile.LocalContentStatus == 
                                       SharpSvn.SvnStatus.Missing)
                    {
                        client.Delete(changeFile.Path);
                        WriteLog(strLogFile, changeFile.Path + " Removed - 
                                 Missing files (that are not in filesystem)");

                        myTimer.Enabled = false;
                    }

                    if (changeFile.LocalContentStatus == 
                                     SharpSvn.SvnStatus.NotVersioned)
                    {
                        client.Add(changeFile.Path);
                        WriteLog(strLogFile, changeFile.Path + " Added - 
                                   This file is new in filesystem!");

                        myTimer.Enabled = false;
                    }
                }
                return true;
            }
        }
        catch (Exception ex)
        {
            myTimer.Enabled = true;
            WriteLog(strLogFile, ex);
            return false;
        }
    }

    // CommitToSVN
    public static bool CommitToSVN(string strLogFile, string workingcopy, 
                                          string message, Timer myTimer)
    {
        using (SharpSvn.SvnClient client = new SharpSvn.SvnClient())
        {
            SharpSvn.SvnCommitArgs args = new SharpSvn.SvnCommitArgs();

            args.LogMessage = message;
            args.ThrowOnError = true;
            args.ThrowOnCancel = true;

            try
            {
                myTimer.Enabled = true;
                return client.Commit(workingcopy, args);
            }
            catch (Exception ex)
            {
                myTimer.Enabled = true;
                WriteLog(strLogFile, ex);
                return false;
            }
        }
    }

view more info: from here

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