diff --git a/Makefile b/Makefile index 65bbc35..dbbb61c 100644 --- a/Makefile +++ b/Makefile @@ -241,6 +241,13 @@ test_code_generator_code_i18n_extra: # To support i18n in auto_backup ./script/code_generator/check_git_change_code_generator.sh ./addons/OCA_server-tools/auto_backup +############## +# tag # +############## +.PHONY: tag_push_all +tag_push_all: + ./script/tag_push_all.py + ############## # terminal # ############## diff --git a/doc/DEVELOPMENT.md b/doc/DEVELOPMENT.md index fcc92e3..74c07fc 100644 --- a/doc/DEVELOPMENT.md +++ b/doc/DEVELOPMENT.md @@ -66,6 +66,12 @@ Tools to display the differences between the repo and another project. ./script/git_change_remote.py --sync_to /path/to/project/erplibre --dry_sync ``` +## Showing repo differences with manifest develop +To understand the divergence with the dev manifest. +```bash +./script/git_show_code_diff_repo_manifest.py -m ./manifest/default.dev.xml +``` + ## Sync repo with another project Tools to synchronise the repo with another project. This will show differences and try to checkout on the same commit in all repos. ```bash diff --git a/doc/GIT_REPO.md b/doc/GIT_REPO.md index 23d9660..05e9254 100644 --- a/doc/GIT_REPO.md +++ b/doc/GIT_REPO.md @@ -82,6 +82,18 @@ git commit -am "[#ticket] subject: short sentence" ``` ### Clean all +Before, check changed file in all repos. + +```bash +./.venv/repo forall -pc "git status -s" +``` + +Check the changed branch, and push changed if needed. + +```bash +./script/git_show_code_diff_repo_manifest.py -m ./manifest/default.dev.xml +``` + Maybe, some version diverge from your manifest. Simply clean all and relaunch your installation. ```bash ./script/clean_repo_manifest.sh diff --git a/doc/RELEASE.md b/doc/RELEASE.md index 06f8ac5..e912ce9 100644 --- a/doc/RELEASE.md +++ b/doc/RELEASE.md @@ -83,7 +83,7 @@ git tag v#.#.# git push --tags # Add tags for all repo ./.venv/repo forall -pc "git tag ERPLibre/v#.#.#" -./.venv/repo forall -pc "git push ERPLibre --tags" +make tag_push_all ``` ## Generate and push docker diff --git a/script/tag_push_all.py b/script/tag_push_all.py new file mode 100755 index 0000000..ed24d6e --- /dev/null +++ b/script/tag_push_all.py @@ -0,0 +1,70 @@ +#!./.venv/bin/python +import os +import sys +import argparse +import logging +from git import Repo # pip install gitpython +from retrying import retry # pip install retrying +from colorama import Fore +from colorama import Style + +new_path = os.path.normpath(os.path.join(os.path.dirname(__file__), "..")) +sys.path.append(new_path) + +from script.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="""Push all addons git.""", + epilog="""\ +""", + ) + parser.add_argument( + "-m", + "--manifest", + default="./default.xml", + help="The manifest to compare with actual code.", + ) + args = parser.parse_args() + return args + + +def main(): + config = get_config() + git_tool = GitTool() + + dct_remote, dct_project, default_remote = git_tool.get_manifest_xml_info( + filename=config.manifest, add_root=True + ) + i = 0 + total = len(dct_project) + for name, project in dct_project.items(): + i += 1 + path = project.get("@path") + print(f"{i}/{total} - {path}") + organization = project.get("@remote", git_tool.default_project_name) + + try: + git_repo = Repo(path) + retry(wait_exponential_multiplier=1000, stop_max_delay=15000)( + git_repo.git.push + )(organization, "--tags") + except: + print( + f"{Fore.RED}ERROR{Style.RESET_ALL} cannot push --tags for path" + f" {path} organization {organization}" + ) + + +if __name__ == "__main__": + main()