2 # SPDX-FileCopyrightText: 2024 Julien Moutinho (adh14) <julm+rezine@autogeree.net>
3 # SPDX-License-Identifier: AGPL-3.0-or-later
4 # shellcheck disable=SC2034
5 # shellcheck disable=SC2046
6 # shellcheck disable=SC2086
7 # shellcheck disable=SC2119
8 # shellcheck disable=SC2154
13 # FIXME: host it on rezine.org?
14 rfcGitweb
="https://git.sourcephile.fr/julm/$rfcRepo.git"
17 rfcRoot
=$(realpath --relative-to . "${0%/*}"/..)
18 rfcDir
=$(realpath --relative-to "$rfcRoot" "$rfcDir")
19 rfcBranch
=$(realpath --relative-to "$rfcRoot"/rfcs "$rfcDir")
20 rfcYear
=$(git log -1 --pretty=%cd --date=format:%Y "$rfcDir/advocacy.md")
21 rfcDate
=$(git log -1 --pretty=%cd --date=short "$rfcDir/advocacy.md")
25 local advocacyLatestCommit criticismsLatestCommit
26 advocacyLatestCommit
=$(git rev-list --max-count=1 HEAD -- "$rfcDir/advocacy.html")
27 criticismsLatestCommit
=$(git rev-list --max-count=1 HEAD -- "$rfcDir/criticisms.html")
28 rfcTagAdvocacyOld
="$(git describe --tags "$advocacyLatestCommit")" || true
29 rfcTagCriticismsOld
="$(git describe --tags "$criticismsLatestCommit")" || true
30 if test "${rfcTagAdvocacyOld#"${rfcBranch}v"}" != "$rfcTagAdvocacyOld"
31 then IFS
=psvc
read -r _num rfcRevAdvocacy _
<<<"$rfcTagAdvocacyOld"
32 else rfcRevAdvocacy
=0; rfcTagAdvocacyOld
=init
34 if test "${rfcTagCriticismsOld#"${rfcBranch}v"}" != "$rfcTagCriticismsOld"
35 then IFS
=psvc
read -r _num _rfcRevAdvocacy rfcRevCriticisms _
<<<"$rfcTagCriticismsOld"
36 else rfcRevCriticisms
=0; rfcTagCriticismsOld
=init
38 rfcRevision
=v
"$rfcRevAdvocacy"c
"$rfcRevCriticisms"
39 rfcTag
="$rfcBranch$rfcRevision"
43 if test ! "${rfcNoAdvocacy:+set}"; then
44 cat - "$rfcDir"/advocacy.md
<<EOF
46 Ce document est publié sous licence
47 [\${SPDX-License-Identifier}](https://spdx.org/licenses/\${SPDX-License-Identifier}.html).
51 > \${rfcOrga} <[RFC\${rfcTag}](mailto:\${rfcList}+\${rfcTag}@\${rfcDomain})>
52 > — « *\${title}* » — \${rfcDate} — série *Requests for Criticisms*
53 > — \${RFC-Category} « \` \${rfcBranch}\` »,
54 > plaidoirie « \` \${rfcRevisionAdvocacy}\` »,
55 > critiques « \` \${rfcRevisionCriticisms}\` »
56 > — \${for(RFC-Compasses)}boussole \${it}\${sep} & \${endfor}
57 > — <<\${rfcGitweb}/blob_plain/\${rfcTag}:/rfcs/\${rfcBranch}/index.html>>.
59 Vous _devriez_ consulter en priorité sa dernière version
60 qui est disponible en ligne à l'adresse :
61 <<\${rfcGitweb}/blob_plain/\${rfcBranch}:/rfcs/\${rfcBranch}/index.html>>
67 if test ! "${rfcNoCriticisms:+set}"; then
68 cat "$rfcDir"/criticisms.md
81 printf ' --metadata %s' \
82 rfcBranch
="$rfcBranch" \
85 rfcDomain
="$rfcDomain" \
86 rfcGitweb
="$rfcGitweb" \
90 rfcRevision
="$rfcRevision" \
91 rfcRevisionAdvocacy
="v$rfcRevAdvocacy" \
92 rfcRevisionCriticisms
="c$rfcRevCriticisms" \
99 src
=$(mktemp --suffix ".md")
111 pandoc
--from markdown
+emoji
--to plain \
113 --csl "$rfcRoot"/styles
/rfc.csl \
114 $(printf " --bibliography %s" "$rfcRoot"/refs/*.json) \
115 --lua-filter "$rfcRoot"/styles
/rfc.lua \
116 --variable lang
=fr
-FR \
122 pandoc
--from markdown
+emoji
--to markdown
+emoji \
123 --table-of-contents \
127 --csl "$rfcRoot"/styles
/rfc.csl \
128 $(printf " --bibliography %s" "$rfcRoot"/refs/*.json) \
129 --lua-filter "$rfcRoot"/styles
/rfc.lua \
130 --variable lang
=fr
-FR \
136 pandoc
--from markdown
+emoji
--to html5 \
139 --include-in-header "$rfcRoot"/styles
/rfc.header.html \
140 --table-of-contents \
144 --csl "$rfcRoot"/styles
/rfc.csl \
145 $(printf " --bibliography %s" "$rfcRoot"/refs/*.json) \
146 --lua-filter "$rfcRoot"/styles
/rfc.lua \
147 --variable lang
=fr
-FR \
153 pandoc
--from markdown
+emoji
--to pdf \
154 --pdf-engine lualatex \
155 --include-in-header "$rfcRoot"/styles
/rfc.header.tex \
158 --table-of-contents \
162 --csl "$rfcRoot"/styles
/rfc.csl \
163 $(printf " --bibliography %s" "$rfcRoot"/refs/*.json) \
164 --lua-filter "$rfcRoot"/styles
/rfc.lua \
165 --variable colorlinks
=true \
166 --variable lang
=fr
-FR \
167 --variable links
-as-notes=true \
175 # Check if $rfcRevAdvocacy must be increased.
176 rfcNoCriticisms
="set" \
177 rfcHTML
-o "$rfcDir"/advocacy.html
178 git add
"$rfcDir"/advocacy.html
179 if ! git
diff --cached --quiet "$rfcDir"/advocacy.html
; then
180 rfcRevAdvocacyIncrement
=1
181 # Note that $rfcRevCriticisms is not reset:
182 # criticisms have their own independant revisions
183 # because, in practice, criticisms to an old $rfcRevAdvocacy
184 # can be received and added after a new $rfcRevAdvocacy has been tagged.
187 # Check if $rfcRevCriticisms must be increased.
188 rfcNoAdvocacy
="set" \
190 -o "$rfcDir"/criticisms.html \
191 --metadata title
="[RFC${rfcTag}] Critiques"
192 git add
"$rfcDir"/criticisms.html
193 if ! git
diff --cached --quiet "$rfcDir"/criticisms.html
; then
194 rfcRevCriticismsIncrement
=1
197 if test "${rfcRevAdvocacyIncrement-0}" -gt 0 ||
198 test "${rfcRevCriticismsIncrement-0}" -gt 0
200 rfcRevAdvocacy
=$((rfcRevAdvocacy + rfcRevAdvocacyIncrement))
201 rfcRevCriticisms
=$((rfcRevCriticisms + rfcRevCriticismsIncrement))
202 rfcRevision
=v
"$rfcRevAdvocacy"c
"$rfcRevCriticisms"
203 rfcTag
="$rfcBranch$rfcRevision"
204 rfcNoCriticisms
="set" \
205 rfcHTML
-o "$rfcDir"/advocacy.html
206 rfcNoAdvocacy
="set" \
207 rfcHTML
-o "$rfcDir"/criticisms.html
208 rfcHTML
-o "$rfcDir"/index.html
209 #rfcPDF -o "$rfcDir/${rfcRepo}-${rfcBranch}".pdf
210 git add
"$rfcDir"/{advocacy
,criticisms
,index
}.html
211 #git add "$rfcDir/${rfcRepo}-${rfcBranch}".pdf
212 git
diff --cached --quiet ||
213 git commit
-m "$rfcBranch: v$rfcRevAdvocacy c$rfcRevCriticisms"
214 git tag
--force --sign --message "${rfcOrga} RFC${rfcTag}" "$rfcTag"
217 git_push_remote
=${git_push_remote-origin}
218 if test ! "${no_git_push:+set}"; then
219 git push
${git_push-} --follow-tags "$git_push_remote" "$rfcTag"
220 git push
${git_push-} "$git_push_remote" "$(git rev-list "$rfcTag" -1):${rfcBranch}"
221 git push
${git_push-} "$git_push_remote"