[IMP] script pycharm configuration: support version control auto-fill
This commit is contained in:
parent
829f7564f4
commit
200aea9f8b
3 changed files with 59 additions and 4 deletions
|
|
@ -29,4 +29,4 @@ run_robotlibre,./odoo/odoo-bin,--limit-time-real 999999 -c config.conf -d robotl
|
|||
run_robotlibre_update,./odoo/odoo-bin,--limit-time-real 999999 --no-http --stop-after-init --dev cg -d robotlibre -i erplibre_devops -u erplibre_devops,robotlibre,
|
||||
run_robotlibre_generate,./script/code_generator/new_project.py,-f -d ./addons/ERPLibre_erplibre_addons -m erplibre_devops,robotlibre,
|
||||
run_todo,./script/todo/todo.py,,TODO,
|
||||
|
||||
pycharm_configuration_init,./script/ide/pycharm_configuration.py,--init,IDE,
|
||||
|
|
|
|||
|
|
|
@ -20,7 +20,8 @@ CST_EL_GITHUB_TOKEN = "EL_GITHUB_TOKEN"
|
|||
DEFAULT_PROJECT_NAME = "ERPLibre"
|
||||
DEFAULT_WEBSITE = "erplibre.ca"
|
||||
DEFAULT_REMOTE_URL = "https://github.com/ERPLibre/ERPLibre.git"
|
||||
DEFAULT_BRANCH = "12.0"
|
||||
with open(".odoo-version", "r") as f:
|
||||
DEFAULT_BRANCH = f.readline()
|
||||
|
||||
|
||||
class Struct(object):
|
||||
|
|
|
|||
|
|
@ -12,6 +12,13 @@ import sys
|
|||
|
||||
import xmltodict
|
||||
|
||||
new_path = os.path.normpath(
|
||||
os.path.join(os.path.dirname(__file__), "..", "..")
|
||||
)
|
||||
sys.path.append(new_path)
|
||||
|
||||
from script.git.git_tool import GitTool
|
||||
|
||||
logging.basicConfig(level=os.environ.get("LOGLEVEL", "INFO"))
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
|
@ -20,6 +27,7 @@ PROJECT_NAME = os.path.basename(os.getcwd())
|
|||
IDEA_PATH = "./.idea"
|
||||
IDEA_MISC = os.path.join(IDEA_PATH, "misc.xml")
|
||||
IDEA_WORKSPACE = os.path.join(IDEA_PATH, "workspace.xml")
|
||||
VCS_WORKSPACE = os.path.join(IDEA_PATH, "vcs.xml")
|
||||
|
||||
PATH_EXCLUDE_FOLDER = "./conf/pycharm_exclude_folder.txt"
|
||||
if os.path.isfile(PATH_EXCLUDE_FOLDER):
|
||||
|
|
@ -95,8 +103,6 @@ def main():
|
|||
config = get_config()
|
||||
_logger.info(f"Work on directory {os.getcwd()}")
|
||||
|
||||
# TODO modifier vcs.xml pour le mapping des répertoires git
|
||||
|
||||
die(
|
||||
not os.path.isdir(IDEA_PATH),
|
||||
f"Missing {IDEA_PATH} path, are you sure you run this script at root"
|
||||
|
|
@ -135,6 +141,14 @@ def main():
|
|||
IDEA_WORKSPACE, add_configuration, "workspace", config
|
||||
)
|
||||
|
||||
die(
|
||||
not os.path.isfile(VCS_WORKSPACE),
|
||||
f"Missing {VCS_WORKSPACE} file, be sure Pycharm open a project to"
|
||||
" your workspace.",
|
||||
)
|
||||
has_execute = True
|
||||
read_xml_and_execute(VCS_WORKSPACE, add_version_control, "vcs", config)
|
||||
|
||||
if not has_execute:
|
||||
_logger.info("Nothing to do")
|
||||
|
||||
|
|
@ -161,6 +175,46 @@ def read_xml_and_execute(file_name, cb, name, config):
|
|||
_logger.info(f"No change '{name}'.")
|
||||
|
||||
|
||||
def add_version_control(dct_xml, file_name, config):
|
||||
# The file .idea/vcs.xml need to be generated before
|
||||
|
||||
git_tool = GitTool()
|
||||
lst_repo = git_tool.get_repo_info_manifest_xml()
|
||||
lst_mapping_directory = []
|
||||
# Create a mapping of git directory from ERPLibre
|
||||
for dct_repo in lst_repo:
|
||||
relative_path = dct_repo.get("path")
|
||||
if not relative_path:
|
||||
continue
|
||||
vcs_path = os.path.join("$PROJECT_DIR$", relative_path)
|
||||
lst_mapping_directory.append(vcs_path)
|
||||
dct_component = dct_xml.get("project", {}).get("component", {})
|
||||
lst_mapping = dct_component.get("mapping", [])
|
||||
if not lst_mapping:
|
||||
print(
|
||||
"By default, need 1 value, the actual ERPLibre project, or create"
|
||||
" it manually ;-)"
|
||||
)
|
||||
return False
|
||||
# Detect difference
|
||||
if type(lst_mapping) is dict:
|
||||
# Transform it into list for multiple mapping
|
||||
lst_mapping = [lst_mapping]
|
||||
dct_component["mapping"] = lst_mapping
|
||||
|
||||
for dct_mapping in lst_mapping:
|
||||
directory = dct_mapping.get("@directory")
|
||||
if directory in lst_mapping_directory:
|
||||
lst_mapping_directory.remove(directory)
|
||||
# Update difference
|
||||
if lst_mapping_directory:
|
||||
for mapping_directory in lst_mapping_directory:
|
||||
dct_mapping = {"@directory": mapping_directory, "@vcs": "Git"}
|
||||
lst_mapping.append(dct_mapping)
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def add_configuration(dct_xml, file_name, config):
|
||||
has_change = False
|
||||
dct_project = dct_xml.get("project")
|
||||
|
|
|
|||
Loading…
Reference in a new issue