diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..c50c6e3 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,4 @@ +[submodule "MAPS"] + path = MAPS + url = https://github.com/drflei/MSM_maps.git + branch = master diff --git a/MAPS_UPDATE.md b/MAPS_UPDATE.md new file mode 100644 index 0000000..df914b7 --- /dev/null +++ b/MAPS_UPDATE.md @@ -0,0 +1,29 @@ +# MAPS submodule: tracking latest maps + +This repository contains a MAPS submodule that points to the MSM_maps repository. The submodule has been configured to track the upstream branch `master` so you can update it to the latest maps with Git or with the provided helper script. + +Options to get the latest maps: + +- Using Git (recommended for developers / CI): + + From the repository root: + + ```bash + git submodule sync --recursive + git submodule update --init --remote MAPS + # If you want to persist the new submodule commit in the superproject: + git add MAPS + git commit -m "Update MAPS submodule to latest" + ``` + +- Using the helper script (convenient for users who don't want to run git submodule commands): + + From the repository root: + + ```bash + python3 scripts/update_maps.py + ``` + +Notes: +- The submodule is configured with `branch = master`. If the upstream branch name changes, update `.gitmodules` accordingly. +- The helper script calls `git clone` / `git pull` and therefore requires `git` to be installed and network access. diff --git a/scripts/update_maps.py b/scripts/update_maps.py new file mode 100755 index 0000000..39fbe22 --- /dev/null +++ b/scripts/update_maps.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python3 +""" +scripts/update_maps.py + +Helper to clone or update the MAPS subrepository (MSM_maps). +Run from the repository root (or via python -m scripts.update_maps) to ensure the MAPS directory is populated/updated. +""" +import os +import subprocess +import sys + +REPO_URL = "https://github.com/drflei/MSM_maps.git" + +# MAPS directory relative to repository root: repo_root/MAPS +here = os.path.dirname(os.path.abspath(__file__)) +REPO_ROOT = os.path.normpath(os.path.join(here, os.pardir)) +MAPS_DIR = os.path.join(REPO_ROOT, "MAPS") + + +def run(cmd, check=True): + print('> ' + ' '.join(cmd)) + return subprocess.run(cmd, check=check) + + +def ensure_maps(): + maps_path = os.path.abspath(MAPS_DIR) + if not os.path.exists(maps_path): + print("Cloning MSM_maps into", maps_path) + run(["git", "clone", REPO_URL, maps_path]) + # ensure the tracked branch exists locally + try: + run(["git", "-C", maps_path, "checkout", "master"]) + except subprocess.CalledProcessError: + # continue if branch not present locally + pass + else: + print("Pulling latest changes into", maps_path) + # fetch and pull the configured remote/master + run(["git", "-C", maps_path, "fetch", "--all"]) + run(["git", "-C", maps_path, "pull", "origin", "master"]) + + +if __name__ == "__main__": + try: + ensure_maps() + except subprocess.CalledProcessError as e: + print("Error updating MAPS:", e, file=sys.stderr) + sys.exit(2)