简体   繁体   English

将“svn st”管道化为“svn commit”

[英]Piping “svn st” into “svn commit”

I've got a project that has a config file which I've modified. 我有一个项目有一个我修改过的配置文件。 I want to commit everything I have except the config file. 我想提交除配置文件之外的所有内容。 This is the status of svn. 这是svn的状态。

?       web/trunk/webroot/tmp
M       web/trunk/webroot/css/styles.css
M       web/trunk/views/posts/list_all.ctp
M       web/trunk/config/core.php

And this is the command I run. 这就是我跑的命令。

svn st | grep ? -v | grep config/core.php -v | awk '{print $2;}' | xargs sudo svn commit

But I keep getting this message. 但我不断收到这条消息。

Received SIGHUP or SIGTERM
svn: Commit failed (details follow):
svn: system('/usr/bin/editor svn-commit.tmp') returned 256

Any suggestions on how to fix this problem would be really appreciated. 任何关于如何解决这个问题的建议都会非常感激。

EDIT: This is kinda interesting. 编辑:这有点儿有趣。 I echoed the result one and this is what I got. 我回应了结果,这就是我得到的。

svn st | grep ? -v | grep gearman -v | awk '{print $2;}' | xargs echo | awk '{ print "sudo svn commit " $0; }'

Output: 输出:

sudo svn commit web/trunk/webroot/css/backend.css web/trunk/views/store_subscribers/list_all.ctp

Running the above result manually works fine but when I piped it into sh, 手动运行上面的结果工作正常,但当我把它输入sh,

svn st | grep ? -v | grep gearman -v | awk '{print $2;}' | xargs echo | awk '{ print "sudo svn commit " $0; }' | sh

Output: 输出:

Received SIGHUP or SIGTERM
svn: Commit failed (details follow):
svn: system('/usr/bin/editor svn-commit.tmp') returned 256

Try: 尝试:

sudo svn -q commit

-q is the silent switch and should not force svn to open up the editor to put in a commit message :) -q是静默开关,不应强制svn打开编辑器以输入提交消息:)

Ideally you should also specify a message via the -m switch 理想情况下,您还应通过-m开关指定消息

http://svnbook.red-bean.com/en/1.1/re06.html http://svnbook.red-bean.com/en/1.1/re06.html

You can simulate the convenience of xargs with backticks 您可以使用backticks模拟xargs的便利性

Instead of: 代替:

svn st | grep ? -v | grep config/core.php -v | awk '{print $2;}' | xargs sudo svn commit

You can try: 你可以试试:

svn ci `svn st | grep ? -v | grep config/core.php -v | awk '{print $2;}'`

Just drop the xargs command at the end, wrap your query in backticks , and add svn ci to the front of your example. 只需将xargs命令放在最后,将查询包装在backticks ,然后将svn ci添加到示例的前面。

Mainly you need to svn add before you svn commit . 主要是你需要在svn commit之前svn add svn commit For example, this doesn't work: 例如,这不起作用:

$ touch testfile
$ svn st
$ svn commit testfile -m 'playing with svn'
svn: Commit failed (details follow):
svn: '/cygdrive/c/web/cpoe_ordersets/testfile' is not under version control

But if I remember to svn add it it works. 但是,如果我记得svn add它它是有效的。

$ svn add testfile
A         testfile

$ svn commit testfile -m 'playing with svn'
Adding         testfile
Transmitting file data .
Committed revision 1505.

So you might want to add an svn add command to your pipeline before the commit, or more likely what you really want is to 因此,您可能希望在提交之前向管道添加svn add命令,或者更可能是您真正想要的那样

  1. run svn add * --force in the root directory to add all unversioned files, then 然后在根目录中运行svn add * --force以添加所有未版本控制的文件
  2. svn revert config/core.php which you don't want added svn revert config/core.php你不想添加的svn revert config/core.php
  3. run svn commit -m "I added some unversioned files" in the root directory to commit all the added files. 运行svn commit -m "I added some unversioned files"在根目录中svn commit -m "I added some unversioned files"以提交所有添加的文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM