forked from libre-chip/grant-tracking
final script fixes
This commit is contained in:
parent
cc7aa3c7b1
commit
f9bff4c415
1 changed files with 19 additions and 16 deletions
|
@ -52,7 +52,7 @@ function matches_split_prefix() {
|
|||
for split_token in "$@"; do
|
||||
text_prefix="$text"
|
||||
until [[ -z "$text_prefix" ]]; do
|
||||
if [[ "$expected" = "$text_prefix" ]]; then
|
||||
if [[ "$text_prefix" =~ ^"$expected"[[:blank:]]*$ ]]; then
|
||||
return 0
|
||||
else
|
||||
next_text_prefix="${text_prefix%"$split_token"*}"
|
||||
|
@ -86,23 +86,21 @@ function check_issue()
|
|||
nlnet_id="$2"
|
||||
subtask_title="$3"
|
||||
subtask_body="$4"
|
||||
if [[ -z "$FORGEJO_TOKEN" ]]; then
|
||||
return
|
||||
fi
|
||||
example_title="NLnet $nlnet_id $subtask_title"
|
||||
body_prefix="Issue for tracking progress of a subtask of [NLnet grant $nlnet_id]($(grant_url "$nlnet_id")):
|
||||
$subtask_title
|
||||
$subtask_body
|
||||
"
|
||||
body_suffix="" # TODO
|
||||
example_body_middle=$'\n<!-- add additional content here if you like -->\n'
|
||||
body_middle_comment=$'<!-- add additional content here if you like -->'
|
||||
example_body_middle=$'\n'"$body_middle_comment"$'\n'
|
||||
function error() {
|
||||
# emit escape sequence for a hyperlink to the issue
|
||||
bar="---------------------------------------------------------------------------"
|
||||
body="$body_prefix"
|
||||
body_middle="${example_body_middle%$'\n'}"
|
||||
body+="${body_middle#$'\n'}"
|
||||
body+="$body_suffix"
|
||||
# emit escape sequence for a hyperlink to the issue
|
||||
printf '\n\n\e]8;;%s\e\\Issue #%s\e]8;;\e\\: error: %s\nExample Issue:\nTitle: %s\nDescription:\n%s\n%s\n%s\n' \
|
||||
"$(issue_url "$issue_number")" "$issue_number" "$*" \
|
||||
"$example_title" "$bar" "$body" "$bar" >&2
|
||||
|
@ -117,28 +115,33 @@ $subtask_body
|
|||
-H "Accept: application/json" \
|
||||
-H "Authorization: token $FORGEJO_TOKEN")" || error "can't retrieve issue"
|
||||
else
|
||||
error "FORGEJO_TOKEN is not set, can't check issue (this is expected outside of CI)"
|
||||
# emit escape sequence for a hyperlink to the issue
|
||||
printf '\n\n\e]8;;%s\e\\Issue #%s\e]8;;\e\\: warning: %s\n' \
|
||||
"$(issue_url "$issue_number")" "$issue_number" \
|
||||
"FORGEJO_TOKEN is not set, can't check issue (this is expected outside of CI)" >&2
|
||||
return
|
||||
fi
|
||||
issue_title="$(echo "$issue_json" | jq -r '.title')"
|
||||
issue_body="$(echo "$issue_json" | jq -r '.body')"
|
||||
issue_title="$(echo "$issue_json" | jq -r '.title|gsub("\r\n"; "\n")')"
|
||||
issue_body="$(echo "$issue_json" | jq -r '.body|gsub("\r\n"; "\n")')"
|
||||
[[ "$issue_title" =~ ^"NLnet $nlnet_id "(.*)$ ]] || error "title must start with \`NLnet $nlnet_id \`"
|
||||
issue_title_tail="${BASH_REMATCH[1]}"
|
||||
split_punct=(',' '-' ';' ':')
|
||||
split_punct=(',' '-' ';' ':' '. ')
|
||||
matches_split_prefix "$issue_title_tail" "$subtask_title" "${split_punct[@]}" || \
|
||||
error "issue title must be \`NLnet $nlnet_id \` followed by the subtask title, or a prefix of the subtask title that ends right before one of:$(printf ' `%s`' "${split_punct[@]}")"
|
||||
if [[ "$issue_body" =~ ^"$body_prefix".*"$body_suffix"$ ]]; then
|
||||
: # all good
|
||||
elif [[ "$issue_body" =~ ^"$body_prefix"(.*)"$example_body_middle"(.*)$ || \
|
||||
elif [[ "$issue_body" =~ ^"$body_prefix"(.*)"$body_middle_comment"(.*)$ || \
|
||||
"$issue_body" =~ ^"$body_prefix"(.*)()$ ]]; then
|
||||
example_body_middle="${BASH_REMATCH[1]}$example_body_middle${BASH_REMATCH[2]}"
|
||||
example_body_middle="${BASH_REMATCH[1]}$body_middle_comment${BASH_REMATCH[2]}"
|
||||
error "issue description is missing required suffix"
|
||||
elif [[ "$issue_body" =~ ^(.*)"$example_body_middle"(.*)"$body_suffix"$ || \
|
||||
elif [[ "$issue_body" =~ ^(.*)"$body_middle_comment"(.*)"$body_suffix"$ || \
|
||||
"$issue_body" =~ ^(.*)()"$body_suffix"$ ]]; then
|
||||
example_body_middle="${BASH_REMATCH[1]}$example_body_middle${BASH_REMATCH[2]}"
|
||||
printf '%q\n' "$body_prefix" "$issue_body"
|
||||
example_body_middle="${BASH_REMATCH[1]}$body_middle_comment${BASH_REMATCH[2]}"
|
||||
error "issue description is missing required prefix"
|
||||
elif [[ "$issue_body" =~ ^(.*)"$example_body_middle"(.*)$ || \
|
||||
elif [[ "$issue_body" =~ ^(.*)"$body_middle_comment"(.*)$ || \
|
||||
"$issue_body" =~ ^(.*)()$ ]]; then
|
||||
example_body_middle="${BASH_REMATCH[1]}$example_body_middle${BASH_REMATCH[2]}"
|
||||
example_body_middle="${BASH_REMATCH[1]}$body_middle_comment${BASH_REMATCH[2]}"
|
||||
error "issue description is missing both the required prefix and suffix"
|
||||
fi
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue