在命令行上,它的工作方式如下:
svn log "$src_url" --stop-on-copy \
| awk -v RS="--+" -F'|' ' /ticket-101/{print $1}' \
| grep "^r" \
| cut -d"r" -f2 \
| cut -d" " -f1
输出:
6359
6358
6263
6241
6240
6239
6238
6237
6236
该脚本在硬编码票号时有效,但在我将其分配为变量时无效。我可能需要提供不止一张票,因此需要这个工作。
#!/usr/bin/bash
src_url="$1"
itrack=ticket-101
for ticket in "$itrack"; do
echo $ticket
revs=($(IFS=$'\n';
svn log "$src_url" --stop-on-copy \
| awk -v RS="--+" -F'|' ' /"$ticket"/{print $1}' \
| grep "^r" \
| cut -d"r" -f2 \
| cut -d" " -f1 \
| sort -r
))
for revision in ${!revs[*]} ; do
echo ${revs[$revision]}
done
done
Output gives nothing.
svn
我试图解析的命令的输出是:
$ svn log http://test.svn.com/svn/demo_project --limit 5
------------------------------------------------------------------------
r1000 | testuser25 | 2013-06-13 13:37:10 -0400 (Thu, 13 Jun 2013) | 1 line
ticket-1135
------------------------------------------------------------------------
r999 | testuser20 | 2013-06-13 13:26:46 -0400 (Thu, 13 Jun 2013) | 2 lines
ticket-1135
------------------------------------------------------------------------
r998 | testuser30 | 2013-06-13 12:12:12 -0400 (Thu, 13 Jun 2013) | 1 line
ticket-122
------------------------------------------------------------------------
r997 | testuser25 | 2013-06-13 12:09:56 -0400 (Thu, 13 Jun 2013) | 1 line
ticket-11
------------------------------------------------------------------------
r900 | testuser40 | 2013-06-13 12:09:53 -0400 (Thu, 13 Jun 2013) | 1 line
ticket-113
------------------------------------------------------------------------
如果输入是:/run.sh http://test.svn.com/svn/demo_project ticket-1135 ticket-122 ticket-113
所需的输出将是:
900
998
999
1000