erplibre/script/git/git_repo_manifest.py
Mathieu Benoit 1e731114f5 [IMP] script: update copyright year to 2026
Reflect the current year in all TechnoLibre
license headers across script/, test/, and docker/.

Generated by Claude Code 2.1.74 model claude-sonnet-4-6

Co-Authored-By: Mathieu Benoit <mathben@technolibre.ca>
2026-03-11 23:16:05 -04:00

109 lines
2.7 KiB
Python
Executable file

#!/usr/bin/env python3
# © 2021-2026 TechnoLibre (http://www.technolibre.ca)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
import argparse
import logging
import os
import sys
new_path = os.path.normpath(
os.path.join(os.path.dirname(__file__), "..", "..")
)
sys.path.append(new_path)
from script.git.git_tool import GitTool
_logger = logging.getLogger(__name__)
def get_config():
"""Parse command line arguments, extracting the config file name,
returning the union of config file and command line arguments
:return: dict of config file settings and command line arguments
"""
# TODO update description
parser = argparse.ArgumentParser(
formatter_class=argparse.RawDescriptionHelpFormatter,
description="""\
""",
epilog="""\
""",
)
parser.add_argument(
"-d",
"--dir",
dest="dir",
default="./",
help="Path of repo to change remote, including submodule.",
)
parser.add_argument(
"--clear",
action="store_true",
help="Create a new manifest and clear old configuration.",
)
parser.add_argument(
"--keep_origin",
action="store_true",
help="Create origin remote. TODO.",
)
parser.add_argument(
"-m",
"--manifest",
default="manifest/default.dev.xml",
help="The manifest file path to generate.",
)
parser.add_argument(
"--default_branch",
default=False,
help="The manifest default branch.",
)
args = parser.parse_args()
return args
def main():
config = get_config()
git_tool = GitTool()
repos = git_tool.get_source_repo_addons(
repo_path=config.dir, add_repo_root=True
)
repo_list = [
git_tool.get_transformed_repo_info_from_url(
a.get("url"),
repo_path=config.dir,
get_obj=True,
is_submodule=a.get("is_submodule"),
sub_path=a.get("sub_path"),
revision=a.get("revision"),
clone_depth=a.get("clone_depth"),
)
for a in repos
]
# Update origin to new repo
if not config.clear:
remotes, projects, _ = git_tool.get_manifest_xml_info(
repo_path=config.dir, add_root=True
)
else:
remotes = {}
projects = {}
kwargs = {}
if config.default_branch:
kwargs["default_branch"] = config.default_branch
git_tool.generate_repo_manifest(
repo_list,
output=f"{config.dir}{config.manifest}",
remotes_config=remotes,
projects_config=projects,
keep_original=config.keep_origin,
**kwargs,
)
git_tool.generate_generate_config()
if __name__ == "__main__":
main()