From 80c47884f6f83976936433a0591e122e570e08ed Mon Sep 17 00:00:00 2001 From: Matthew Brett Date: Wed, 30 Oct 2024 12:15:10 +0000 Subject: [PATCH] Get edition from Git --- scripts/set_version.py | 11 ++++++++++- source/config_variables.yml | 8 ++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/scripts/set_version.py b/scripts/set_version.py index ff980043..891b6290 100755 --- a/scripts/set_version.py +++ b/scripts/set_version.py @@ -4,6 +4,7 @@ from argparse import ArgumentParser, RawDescriptionHelpFormatter from pathlib import Path +from subprocess import check_output import yaml # Template that fill be format-filled to write output file. @@ -43,12 +44,20 @@ def version_to_top(var_dict, version, other_version): return {**var_dict, **version_dict} +def get_edition(): + branch_name = check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD'], + text=True).strip() + return 'latest' if branch_name == 'main' else branch_name + + def main(): parser = get_parser() args = parser.parse_args() version = args.version.lower() other_version = OTHER_VERSIONS[version] - start_dict = {'version': version, 'other-version': other_version} + start_dict = {'version': version, + 'other-version': other_version, + 'edition': get_edition()} config_vars = recursive_fill_vars(CONFIG_VARS, start_dict) config_vars = version_to_top(config_vars, version, other_version) print(f"Writing configuration to {args.output}...") diff --git a/source/config_variables.yml b/source/config_variables.yml index 1152d256..e7abd2a8 100644 --- a/source/config_variables.yml +++ b/source/config_variables.yml @@ -1,12 +1,12 @@ # Variables to fill _quarto.yml and _variables.yml files. -# Filled recursively, so variables fully defined here +# This file filled recursively, so variables fully defined here # can also be format-filled into this same file. url-root: https://resampling-stats.github.io -edition: latest -interact-sdir: interact -# version, other-vesrion filled from dictionary initializing read. +# edition, version, other-vesrion filled from dictionary initializing read. +edition: {edition} version: {version} other-version: {other-version} +interact-sdir: interact r: filter_divspans: "['python']" nb_flatten_divspans: "['+', 'r']"