Created
September 30, 2025 05:03
-
-
Save rainbow23/6c6e27e71745577cc0ce7c4587b5f559 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
| awk ' | |
| BEGIN{ g=0; inblk=0 } | |
| # TARGET 行(コミットID抽出) | |
| /^TARGET/ { | |
| # 40桁のGitハッシュ想定。必要に応じて [0-9a-f]{40} を緩めてもOK。 | |
| if (match($0, /[0-9a-f]{40}/, m)) { | |
| if (!inblk) { g++; inblk=1; first[g]=""; last[g]="" } | |
| if (first[g]=="") first[g]=m[0]; # ブロックの先頭(新しい側) | |
| last[g]=m[0]; # 常に更新→最後に見えた(古い側) | |
| } | |
| next | |
| } | |
| # NO_TARGET 行でブロック終端 | |
| /^NO_TARGET/ { | |
| if (inblk) { | |
| # 出力形式: BLOCK <index> <first> <last> | |
| printf("BLOCK %d %s %s\n", g, first[g], last[g]); | |
| inblk=0 | |
| } | |
| next | |
| } | |
| # その他の行は無視 | |
| { next } | |
| # 末尾がTARGETで終わってNO_TARGETが来ないケースの保険 | |
| END{ | |
| if (inblk && first[g] != "" && last[g] != "") { | |
| printf("BLOCK %d %s %s\n", g, first[g], last[g]); | |
| } | |
| } | |
| ' hoge.log > blocks.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment