如何获取svn日志但排除分支添加的信息?比如在'svn log -v --stop-on-copy'的输出中如何避免-r101?我正在尝试将其重定向到临时文件,只是获取文件添加/修改/删除的详细信息。因此,只需要分支创建版本的日志详细信息。
svn log -v local/svn/demo/branches/Fix --stop-on-copy
------------------------------------------------------------------------
r105 | user4 | 2013-05-24 16:27:11 -0400 (Fri, 24 May 2013) | 1 line
Changed paths:
M /branches/Fix/Code/Environment/RT/properties/build.properties
ticket-9
------------------------------------------------------------------------
r104 | user4 | 2013-05-24 16:27:07 -0400 (Fri, 24 May 2013) | 1 line
Changed paths:
M /branches/Fix/Code/Environment/DEV/properties/build.properties
ticket-7
------------------------------------------------------------------------
r103 | user2 | 2013-05-24 15:27:25 -0400 (Fri, 24 May 2013) | 2 lines
Changed paths:
M /branches/Fix/Code/SharedApp/src/gov/illinois/ies/business/rules/ed/CorticonFinIncomeEntiyLoader.java
ticket-2
------------------------------------------------------------------------
r102 | user1 | 2013-05-24 15:19:54 -0400 (Fri, 24 May 2013) | 2 lines
Changed paths:
M /branches/Fix/Code/BEAN/Framework/ejbModule/gov/illinois/ies/business/rules/entities/fin/Income.java
ticket-2
------------------------------------------------------------------------
r101 | user4 | 2013-05-24 12:46:12 -0400 (Fri, 24 May 2013) | 3 lines
Changed paths:
A /branches/Fix (from /tags/2013-05-24T08:00:01.187-04:00_DEV_branch_WP_BUILD:100)
ticket-1
Re-creating the WP_Fix branch for 8AM tag
进一步更新: - 现在我正在运行这个:::
svn log "$src_url" --stop-on-copy | grep -B 2 "$ticket" | grep "^r" | cut -d"r" -f2 | cut -d" " -f1 | sort -r
我的输出是:
105
104
103
102
101
预期输出:
105
104
103
102
答案 0 :(得分:0)
使用awk
,您可以使用regex range
。这样的东西可以跳过你不想要的部分。
awk '/r101/,/^$/ {next}1' <(svn log -v --stop-on-copy)
这将从r101开始跳到下一个空白行。
如果您只需要文件列表,那么您可以执行以下操作 -
awk '($1 == "A" || $1 == "M" || $1 == "D") && NF==2' <(svn log -v --stop-on-copy)
答案 1 :(得分:0)
选择合适的记录分隔符可以减轻问题。鉴于您的样本输入,这个 产生你想要的输出。
awk -v RS='(^|\n)-+\n' '
# ignore empty records
/^$/ {next}
# assume "A /branches/" is the the pattern for what you want to ignore
/A \/branches\// {next}
# print the revision number without its first character
{print substr($1, 2)}
'
正则表达式(^|\n)-+\n
表示:从数据的开头或换行符开始,匹配一个或多个连字符后跟换行符。