2

リビジョン、作成者、およびコメントを含む変更および追加されたファイルのみを svn log verbose からパターンで取得する方法:

猫のテスト:

r7351 | user01 | 2013-07-02 17:53:28 -0400 (Tue, 02 Jul 2013) | 2 lines
Changed paths:
    D /trunk/demo/proj1/.project

jira-125723
  Removing unwanted files

 ------------------------------------------------------------------------
 ------------------------------------------------------------------------
r7352 | user02 | 2013-07-02 17:54:24 -0400 (Tue, 02 Jul 2013) | 2 lines
Changed paths:
   D /trunk/demo/proj2/320-test.ert

jira-125723
Removing unwanted files
------------------------------------------------------------------------
------------------------------------------------------------------------
r7504 | user04 | 2013-07-08 14:26:36 -0400 (Mon, 08 Jul 2013) | 4 lines
Changed paths:
   M /trunk/demo/maven/Sum.jsp
   M /trunk/demo/Code/Results.jsp

jira-121639

WP-IQISU- lot of changes to fix issue
------------------------------------------------------------------------
------------------------------------------------------------------------
r7523 | user08 | 2013-07-08 16:17:52 -0400 (Mon, 08 Jul 2013) | 1 line
Changed paths:
   A /trunk/demo/ant/properties

jira-2185[/CODE]

My code and output:

cat test | awk '/^r[0-9]* \|/ { REVISION=$1; } /  [AM]/ { print REVISION": "$0; }'
r7504:    M /trunk/demo/maven/Sum.jsp
r7504:    M /trunk/demo/Code/Results.jsp
r7523:    A /trunk/demo/ant/properties[/CODE]

しかし、著者とコメントの情報も必要です。 Desired output:

r7504:  user04 jira-121639  Modified /trunk/demo/maven/Sum.jsp     WP-IQISU- lot of changes to fix issue
r7504:  user04 jira-121639  Modified /trunk/demo/Code/Results.jsp  WP-IQISU- lot of changes to fix issue
r7523:  user08 jira-2185    Added    /trunk/demo/ant/properties    
4

2 に答える 2

1

このawkを使用できます:

awk -F '[ |]+' '$1~/^r[0-9]+$/{R=$1;A=$2;next} !C{C++;M=$0} C && $2~/[AM]/{print R,A,$3,M}' OFS=': ' file
r7504: user04: /trunk/demo/maven/Sum.jsp: Changed paths:
r7504: user04: /trunk/demo/Code/Results.jsp: Changed paths:
r7523: user08: /trunk/demo/ant/properties: Changed paths:
于 2013-08-23T21:05:43.720 に答える
1
$ cat tst.awk
BEGIN{ RS="\n-+\n"; FS="\n"; OFS="\t" }
/\n   [MA]/ {
    sub(/^-+\n/,"")
    sub(/[[:space:]]+$/,"")

    split($1,hdr,/ \| /)

    numFiles=0
    for (i=3;$i;i++) {
        sub(/^ +M +/,"Modified" OFS,$i)
        sub(/^ +A +/,"Added" OFS,$i)
        file[++numFiles] = $i
    }

    user = $(i + 1)
    sub (/\[.*/,"",user)

    cmts = $(i + 3)

    for (fileNr=1;fileNr<=numFiles;fileNr++) {
        print hdr[1], hdr[2], user, file[fileNr], cmts
    }
}
$
$ awk -f tst.awk file
r7504   user04  jira-121639     Modified        /trunk/demo/maven/Sum.jsp       WP-IQISU- lot of changes to fix issue
r7504   user04  jira-121639     Modified        /trunk/demo/Code/Results.jsp    WP-IQISU- lot of changes to fix issue
r7523   user08  jira-2185       Added   /trunk/demo/ant/properties

上記では GNU awk を使用しているため、RS を複数の文字に設定できます。

理解を助けるために、変数の一時的な中間「出力」を追加します。抽出された値の間にタブを挿入するだけでなく、出力の書式設定で特定の処理を行うには、man awkを参照してくださいprintf

于 2013-08-23T21:17:22.597 に答える