Created
October 3, 2025 06:15
-
-
Save rainbow23/9165748137f6b841134b7fe42f3f320d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # commit_to_csv.awk | |
| # 1列目: 40桁の commit id | |
| # 2列目: author 行から (先頭空白可の) Change-Id 行まで(Change-Id行を含む) | |
| # CSVセルはダブルクオートで囲み、内部の " は "" にエスケープ | |
| function csv_escape(s, t) { | |
| t = s | |
| gsub(/"/, "\"\"", t) # " -> "" | |
| return "\"" t "\"" | |
| } | |
| function flush_record( t) { | |
| if (commit_id == "") return | |
| t = range_block | |
| sub(/\n$/, "", t) # 最後の余分な改行を1つ削る | |
| print commit_id "," csv_escape(t) | |
| } | |
| BEGIN { | |
| commit_id = "" | |
| capturing = 0 | |
| range_block = "" | |
| } | |
| # 例: "commit<TAB>2dff7bce64eeccb636118eaa77e853e1a4b29dbe" | |
| # タブ/スペースどちらでもOK | |
| /^commit[ \t]+[0-9a-f]{40}$/ { | |
| flush_record() | |
| match($0, /^commit[ \t]+([0-9a-f]{40})$/, m) | |
| commit_id = m[1] | |
| capturing = 0 | |
| range_block = "" | |
| next | |
| } | |
| # author 行で開始 | |
| /^author[ \t]/ { | |
| capturing = 1 | |
| range_block = $0 "\n" | |
| next | |
| } | |
| # 範囲中はどんどん追加。Change-Id(先頭空白可)を含めて終了 | |
| capturing { | |
| range_block = range_block $0 "\n" | |
| if ($0 ~ /^[ \t]*Change-Id[ \t]*:/) { | |
| capturing = 0 | |
| } | |
| next | |
| } | |
| END { | |
| flush_record() | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment