[IMP] script repo_remove_auto_install: add argument to support addons_dir only
This commit is contained in:
parent
47fbc6fa48
commit
2682d7a982
1 changed files with 62 additions and 29 deletions
|
|
@ -13,7 +13,7 @@ new_path = os.path.normpath(
|
||||||
)
|
)
|
||||||
sys.path.append(new_path)
|
sys.path.append(new_path)
|
||||||
|
|
||||||
from script.git.git_tool import GitTool
|
from script.git import git_tool as g_tool
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
@ -39,14 +39,32 @@ def get_config():
|
||||||
default="./",
|
default="./",
|
||||||
help="Path of repo to change remote, including submodule.",
|
help="Path of repo to change remote, including submodule.",
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--addons_dir",
|
||||||
|
help=(
|
||||||
|
"Path of addons to remove auto_install. If empty, will take all"
|
||||||
|
" repo from manifest."
|
||||||
|
),
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--ignore_commit",
|
||||||
|
action="store_true",
|
||||||
|
help="Will not do git commit and push.",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--ignore_push",
|
||||||
|
action="store_true",
|
||||||
|
help="Will not do git push.",
|
||||||
|
)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
return args
|
return args
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
config = get_config()
|
config = get_config()
|
||||||
git_tool = GitTool()
|
git_tool = g_tool.GitTool()
|
||||||
|
|
||||||
|
if not config.addons_dir:
|
||||||
lst_repo = git_tool.get_source_repo_addons(
|
lst_repo = git_tool.get_source_repo_addons(
|
||||||
repo_path=config.dir, add_repo_root=False
|
repo_path=config.dir, add_repo_root=False
|
||||||
)
|
)
|
||||||
|
|
@ -62,11 +80,24 @@ def main():
|
||||||
)
|
)
|
||||||
for a in lst_repo
|
for a in lst_repo
|
||||||
]
|
]
|
||||||
|
else:
|
||||||
|
organization = os.path.basename(config.addons_dir)
|
||||||
|
# TODO information is wrong, need to extract organisation and repo_name
|
||||||
|
lst_repo_organization = [
|
||||||
|
g_tool.Struct(
|
||||||
|
**{
|
||||||
|
"organization": organization,
|
||||||
|
"path": config.addons_dir,
|
||||||
|
"relative_path": config.addons_dir,
|
||||||
|
"repo_name": config.addons_dir,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
]
|
||||||
|
|
||||||
lst_ignore_repo = ["odoo"]
|
lst_ignore_repo = ["odoo"]
|
||||||
|
|
||||||
i = 0
|
i = 0
|
||||||
total = len(lst_repo)
|
total = len(lst_repo_organization)
|
||||||
branch_name = "12.0_dev"
|
branch_name = "12.0_dev"
|
||||||
for repo in lst_repo_organization:
|
for repo in lst_repo_organization:
|
||||||
i += 1
|
i += 1
|
||||||
|
|
@ -77,6 +108,7 @@ def main():
|
||||||
print(f"Ignore {repo.repo_name}.")
|
print(f"Ignore {repo.repo_name}.")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if not config.ignore_commit:
|
||||||
git_repo = Repo(repo.relative_path)
|
git_repo = Repo(repo.relative_path)
|
||||||
# Force checkout branch if exist
|
# Force checkout branch if exist
|
||||||
try:
|
try:
|
||||||
|
|
@ -93,12 +125,13 @@ def main():
|
||||||
|
|
||||||
has_change = get_manifest_external_dependencies(repo)
|
has_change = get_manifest_external_dependencies(repo)
|
||||||
|
|
||||||
if has_change:
|
if has_change and not config.ignore_commit:
|
||||||
if not is_checkout_branch:
|
if not is_checkout_branch:
|
||||||
git_repo.git.checkout("-b", branch_name)
|
git_repo.git.checkout("-b", branch_name)
|
||||||
# change branch, commit and push
|
# change branch, commit and push
|
||||||
git_repo.git.add(".")
|
git_repo.git.add(".")
|
||||||
git_repo.git.commit("-m", "Set all module auto_install at False")
|
git_repo.git.commit("-m", "Set all module auto_install at False")
|
||||||
|
if not config.ignore_push:
|
||||||
git_repo.git.push("-u", repo.organization, branch_name)
|
git_repo.git.push("-u", repo.organization, branch_name)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue