我想格式git日誌輸出到asciidoc格式的更改日誌。我已經使用git log --format做到了這一點。接下來,我需要在提交消息中添加一個bug編號到主題中。結合2行,當後續行匹配模式
下面的輸入是使用
git log --reverse --no-merges $1..$2 --format='* %s%n+%n%b' | \
sed -e '/^Change-Id:.*$/d' | sed -e '/^Signed-off-by:.*$/d'
輸入示例生成:
* This is subject without issue number
+
There will be multiple lines of text and multiple paragraphs.
2nd paragraph of the commit message.
* This is commit with issue number
+
There can be multiple lines of comment message.
2nd paragraph of the commit message. A line with Bug: issue ###
will be the last line. I need to combine the issue ### with
the subject line.
Bug: issue 1234
* This is commit with issue number in Issue: 1235 format
+
There can be multiple lines of comment message.
2nd paragraph of the commit message. A line with Issue: ###
will be the last line. I need to combine the issue ### with
the subject line.
Issue: 1235
期望輸出
* This is subject without issue number
+
There will be multiple lines of text and multiple paragraphs.
2nd paragraph of the commit message.
* issue 1234 This is commit with issue number
+
There can be multiple lines of comment message.
2nd paragraph of the commit message. A line with Bug: issue ###
will be the last line. I need to combine the issue ### with
the subject line.
* issue 1235 This is commit with issue number in Issue: 1235 format
+
There can be multiple lines of comment message.
2nd paragraph of the commit message. A line with Issue: ###
will be the last line. I need to combine the issue ### with
the subject line.
我想知道是否這可以使用awk中來完成。你能提供可以完成的Awk代碼嗎?如果不是什麼其他選擇?我想創建一個生成所需輸出的shell腳本。
謝謝!這是一個非常好的解決方案。當我將第一部分傳遞給它時,它會起作用。但是,該腳本會在每個主題行下面生成額外的空白行。我可以添加另一個條件,一個錯誤信息可以在行Issue:###中描述。我發佈後我才發現這個案例。 – DeenSeth 2012-02-25 10:20:54