@@ -11,6 +11,7 @@ latex_output=""
1111pdflog_output=" "
1212table_rules=" no"
1313block_quotes_are_informative_text=" no"
14+ versioned_filenames=" no"
1415
1516# Start up the dbus daemon (drawio will use it later)
1617dbus-daemon --system || echo " Failed to start dbus daemon"
@@ -49,10 +50,11 @@ print_usage() {
4950 echo " --table_rules: legacy flag, no effect (default starting with 0.9.0)"
5051 echo " --plain_quotes: legacy flag, no effect (default starting with 0.9.0)"
5152 echo " --noplain_quotes: use block-quote syntax as informative text"
53+ echo " --versioned_filenames: insert version information before the file extension for outputs"
5254}
5355
5456
55- if ! options=$( getopt --longoptions=help,puppeteer,notmp,gitversion,gitstatus,nogitversion,table_rules,plain_quotes,noplain_quotes,pdf:,latex:,pdflog:,docx:,html:,resourcedir: --options=" " -- " $@ " ) ; then
57+ if ! options=$( getopt --longoptions=help,puppeteer,notmp,gitversion,gitstatus,nogitversion,table_rules,plain_quotes,noplain_quotes,versioned_filenames, pdf:,latex:,pdflog:,docx:,html:,resourcedir: --options=" " -- " $@ " ) ; then
5658 echo " Incorrect options provided"
5759 print_usage
5860 exit 1
@@ -118,6 +120,10 @@ while true; do
118120 table_rules=" yes"
119121 shift
120122 ;;
123+ --versioned_filenames)
124+ versioned_filenames=" yes"
125+ shift
126+ ;;
121127 --help)
122128 print_usage
123129 shift
@@ -263,6 +269,48 @@ if test "${do_gitversion}" == "yes"; then
263269
264270fi # Done with git version handling
265271
272+ prefix_filename () {
273+ local PREFIX=$1
274+ local FULL_FILENAME=$2
275+ local DIRNAME=$( dirname " ${FULL_FILENAME} " )
276+ local FILENAME=$( basename " ${FULL_FILENAME} " )
277+ local EXTENSION=" ${FILENAME##* .} "
278+ local STRIPPED=" ${FILENAME% .* } "
279+ local RESULT=" "
280+ if [ ! -z " ${DIRNAME} " ]; then
281+ RESULT=" ${DIRNAME} /"
282+ fi
283+ RESULT=" ${RESULT}${STRIPPED}${PREFIX} .${EXTENSION} "
284+ echo " ${RESULT} "
285+ }
286+
287+ # Rename output files based on version info
288+ if [ " ${versioned_filenames} " == " yes" ]; then
289+ version_prefix=" "
290+ if [ ! -z " ${GIT_VERSION} " ]; then
291+ version_prefix=" ${version_prefix} .${GIT_VERSION} "
292+ fi
293+ if [ ! -z " ${GIT_PRERELEASE} " ]; then
294+ version_prefix=" ${version_prefix} .${GIT_PRERELEASE} "
295+ fi
296+ if [ ! -z " ${GIT_REVISION} " ]; then
297+ version_prefix=" ${version_prefix} .${GIT_REVISION} "
298+ fi
299+
300+ if [ ! -z " ${docx_output} " ]; then
301+ docx_output=$( prefix_filename " ${version_prefix} " " ${docx_output} " )
302+ fi
303+ if [ ! -z " ${pdf_output} " ]; then
304+ pdf_output=$( prefix_filename " ${version_prefix} " " ${pdf_output} " )
305+ fi
306+ if [ ! -z " ${latex_output} " ]; then
307+ latex_output=$( prefix_filename " ${version_prefix} " " ${latex_output} " )
308+ fi
309+ if [ ! -z " ${html_output} " ]; then
310+ html_output=$( prefix_filename " ${version_prefix} " " ${html_output} " )
311+ fi
312+ fi
313+
266314echo " Starting Build with"
267315echo " file: ${input_file} "
268316echo " docx: ${docx_output:- none} "
0 commit comments