いろいろあって必要になって作った。 ひょっとすると他に必要な人がいるかもしれないので残しておく。
特定のprojectのissueのdescriptionにあるチェックボックスの数を数えてHTMLにする。
$REPORT_GENERATOR_TOKEN
と$PROJECT_ID
をセットして実行する。
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
json=(curl−s−−header"PRIVATE−TOKEN:REPORT_GENERATOR_TOKEN" https://gitlab.com/api/v4/projects/$PROJECT_ID/issues?state=opened) | |
len=(echojson | jq length) | |
echo '<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head><body>' | |
echo "<h1>" $(date) "</h1>" | |
for i in (seq0(($len - 1)) ); do | |
item=(echojson | jq ".[$i]") | |
title=(echoitem | jq ".title") | |
description=(echoitem | jq ".description") | |
all=(echo−edescription | grep -c "\[.\]") | |
complete=(echo−edescription | grep -c "[x]") | |
if [ ! $all = "0" ]; then | |
ratio=(echo"scale=2;complete/$all" | bc | tail -c 3) | |
echo "<h3>" (echotitle | tr -d '"') "</h3>" | |
if [ all=complete ]; then | |
echo "<p>completed!</p>" | |
else | |
echo "<p>" complete"/"all "(" $ratio "%)" "</p>" | |
fi | |
fi | |
done | |
echo "</body>" |
- 追記 完了率が100%のときにうまく動かない不具合があったため修正。 上のコードは修正後のもの。 まあ自分用に書いたものなので別に直してもここを更新しなくてもいいのだが……
- 追記 何回も更新することになったのでgistにあげた。