Skip to content

Commit

Permalink
Get edition from Git
Browse files Browse the repository at this point in the history
  • Loading branch information
matthew-brett committed Oct 30, 2024
1 parent 14e22e2 commit 80c4788
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
11 changes: 10 additions & 1 deletion scripts/set_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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}...")
Expand Down
8 changes: 4 additions & 4 deletions source/config_variables.yml
Original file line number Diff line number Diff line change
@@ -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']"
Expand Down

0 comments on commit 80c4788

Please sign in to comment.