Detect demo branch based on software version (#12531)

This commit is contained in:
Oliver
2026-08-01 14:43:29 +10:00
committed by GitHub
parent 70dee5c145
commit 9dc8261b51
+9 -8
View File
@@ -1863,7 +1863,7 @@ def _detect_ci_branch() -> Optional[str]:
'dev': 'Set up development environment at the end', 'dev': 'Set up development environment at the end',
'validate_files': 'Validate media files are correctly copied', 'validate_files': 'Validate media files are correctly copied',
'use_ssh': 'Use SSH protocol for cloning the demo dataset (requires SSH key)', 'use_ssh': 'Use SSH protocol for cloning the demo dataset (requires SSH key)',
'branch': 'Specify branch of demo-dataset to clone (default = auto-detected target branch in CI, else main)', 'branch': 'Specify branch of demo-dataset to clone',
'verbose': 'Print verbose output from management commands', 'verbose': 'Print verbose output from management commands',
} }
) )
@@ -1898,9 +1898,14 @@ def setup_test(
URL = 'git@github.com:inventree/demo-dataset.git' URL = 'git@github.com:inventree/demo-dataset.git'
if not branch: if not branch:
branch = _detect_ci_branch() # No branch specified - determine the InvenTree version
if branch: version = get_inventree_version()
info(f"Auto-detected target branch from CI: '{branch}'")
# If the version is a stable release (e.g. "1.4.3")
# then we can try to use the corresponding branch in the demo-dataset repository
# (e.g. "1.4.x")
if re.match(r'^\d+\.\d+\.\d+$', version):
branch = f'{version.rsplit(".", 1)[0]}.x'
# InvenTree's trunk branch is named "master", but the demo-dataset # InvenTree's trunk branch is named "master", but the demo-dataset
# repository uses "main" as its trunk branch - map this automatically # repository uses "main" as its trunk branch - map this automatically
@@ -1912,10 +1917,6 @@ def setup_test(
info(f"Cloning demo dataset (branch '{branch}') ...") info(f"Cloning demo dataset (branch '{branch}') ...")
run(c, f'git clone {URL} {template_dir} -b {branch} -v --depth=1') run(c, f'git clone {URL} {template_dir} -b {branch} -v --depth=1')
# Make sure migrations are done - might have just deleted sqlite database
if not ignore_update:
migrate(c, verbose=verbose)
# Load data # Load data
info('Loading database records ...') info('Loading database records ...')
import_records( import_records(