[ADD] script: tag push all

- git can push all tags with different organization from manifest
- Add documentation git repo before clean all repo manifest
This commit is contained in:
Mathieu Benoit 2021-07-16 00:56:30 -04:00
parent 1bf8d7da9f
commit b4ca616104
5 changed files with 96 additions and 1 deletions

View file

@ -241,6 +241,13 @@ test_code_generator_code_i18n_extra:
# To support i18n in auto_backup # To support i18n in auto_backup
./script/code_generator/check_git_change_code_generator.sh ./addons/OCA_server-tools/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 # # terminal #
############## ##############

View file

@ -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 ./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 ## 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. Tools to synchronise the repo with another project. This will show differences and try to checkout on the same commit in all repos.
```bash ```bash

View file

@ -82,6 +82,18 @@ git commit -am "[#ticket] subject: short sentence"
``` ```
### Clean all ### 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. Maybe, some version diverge from your manifest. Simply clean all and relaunch your installation.
```bash ```bash
./script/clean_repo_manifest.sh ./script/clean_repo_manifest.sh

View file

@ -83,7 +83,7 @@ git tag v#.#.#
git push --tags git push --tags
# Add tags for all repo # Add tags for all repo
./.venv/repo forall -pc "git tag ERPLibre/v#.#.#" ./.venv/repo forall -pc "git tag ERPLibre/v#.#.#"
./.venv/repo forall -pc "git push ERPLibre --tags" make tag_push_all
``` ```
## Generate and push docker ## Generate and push docker

70
script/tag_push_all.py Executable file
View file

@ -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()