-
-
Notifications
You must be signed in to change notification settings - Fork 10
[19.0][MIG] odoo_repository #149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
alan196
wants to merge
160
commits into
OCA:19.0
Choose a base branch
from
Jarsa-dev:19.0-mig-odoo_repository
base: 19.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
160 commits
Select commit
Hold shift + click to select a range
802230c
Add 'odoo_repository'
b59fc62
odoo_repository: add settings panel
863aacd
Add 'odoo_addons_analyzer' package
acf0841
New data model 'odoo.project.module'
118c0bf
Apply pre-commit
4020ba1
odoo_repository: sync data from main node
d9d9793
odoo_repository: sort on 'sequence' for 'odoo.repository'
78ee83f
odoo_repository: update 'unmerged_pr' filter label
bd58aa7
BaseScanner: rename '_get_commit_of_git_tree' method to '_get_last_co…
5642bd2
MigrationScanner: check is scanning the module is relevant
a87a0c0
MigrationScanner: no need to fetch branches
2d55712
odoo_repository_migration: fix sync data from main node
5c0b4f1
odoo_repository: remove ORM cache from '_get_module'
e619295
odoo_repository: limit the scan/force-scan to selected branches
23084da
odoo_repository: limit main node data fetch to selected branches
82944c1
odoo_repository: ability to scan a branch on demand
8805126
odoo_repository: improve branch form view
6697c66
BaseScanner: fix '_get_commits_of_git_tree' to work without commit range
a9cf7e4
BaseScanner: improve '_get_commits_of_git_tree'
68767ce
odoo_repository: test lib.scanner.BaseScanner
013da1c
odoo_repository: automatically sort 'odoo.branch' records which are O…
e1df78c
odoo_repository: fix force scan of project/specific branches
4a563cd
odoo_repository: test lib.scanner.RepositoryScanner
8a76485
odoo_repository: raise error if no branches configured when scanning
bf8bff8
odoo_repository: configure git if no config file exists
b0c6a77
BaseScanner: apply git configuration at repository level
3fa6573
odoo_repository: test repository scan
265a049
BaseScanner: remove hardcoded SSH key path
c76cbf9
odoo_repository: always link scanned module to highest priority repos…
26c5f7f
RepositoryScanner: push module versions to Odoo
6187f19
odoo_repository: add module version data model
888c543
odoo_repository: import scanned module versions
231be28
odoo_repository: compute module URL to ease its browsing in upstream …
effa0f5
odoo_repository: import module versions from main node
4b3569d
odoo_project_migration: list migration scripts to consider for a give…
9d36c57
BaseScanner: ensure to clean up local repository before checkout
a914255
odoo_repository: auto-archive odoo.repository.branch records
37d2449
odoo_repository: fix 'odoo.repository.action_scan' to not override 'b…
f2baf93
MigrationScanner: store 'oca_port' cache in repositories data folder
46ba42e
odoo_repository: handle git authentication with tokens
8a970ce
odoo_repository: handle blacklisted modules
c59b989
odoo_repository: add odoo/enterprise repository (archived by default)
4163ce8
odoo_repository: provide common addons_path
0a2c04c
odoo_repository: handle module removed from a repository branch
064dade
odoo_repository: fix singleton error in 'action_scan' method
a887fb8
odoo_repository: fix module removal
c886176
odoo_repository: do not set repo type always required
2349954
odoo_repository: add dependency levels of modules
ed61c26
BaseScanner: workaround FS errors when cloning repositories
02fc90e
odoo_repository: add option to workaround FS errors
28a9b8c
odoo_repository: fix, enable 'test_odoo_repository_scan'
cf6d260
BaseScanner: always use remote URL provided by Odoo
f6aa490
odoo_repository: list recursive dependencies from module form
21a9077
odoo_repository: remove readonly modifiers on 'odoo.repository' form
6efc615
Scanner: do not raise an error if a branch doesn't exist
00d4057
Scanner: do not clone/fetch blobs
24d3620
Scanner: disable some git GC features
28ee679
odoo_repository: fix access right on 'odoo.module.branch.version'
d18795a
Scanner: remove dangling 'git' process
8f8a792
odoo_repository: use 'queue_job__no_delay' ctx key in tests
c65911e
BaseScanner: revert changes in '_fetch'
f8cad90
BaseScanner: fix 'scan' method ('res' not defined)
009f0b0
odoo_repository: add odoo/design-themes repository
5126683
BaseScanner: fix '_get_last_fetched_commit' and '_checkout_branch'
d19a00e
BaseScanner: fix handling of ambiguous branches
18fe2d0
BaseScanner: fix _checkout_branch
407684f
odoo_repository: imp. 'odoo.module.branch' tree view
2921858
BaseScanner: fix _checkout_branch
725c58c
odoo_repository: split RepositoryScanner jobs in smaller jobs
718a265
odoo_repository_migration: split MigrationScanner jobs in smaller jobs
d60f979
BaseScanner: fix git config safe.directory
0f67567
odoo_repository: fix _detect_modules_to_scan_on_branch if no jobs
2438444
BaseScanner: improve clone IO performance
76a14a9
odoo_repository: add User and Manager user groups
d8c7fdb
odoo_repository: add OCA/stock-weighing repository
4817d6e
BaseScanner: do not raise if a branch is not found when cloning
4d6ea13
odoo_repository: update app icon + clean up static/description folder
17ffcbb
odoo_repository: limit scan of repo to selected weekdays
88ed8ae
odoo_repository: add 'button_box' div on repository form
7f3cd45
odoo_repository: option to force cloned repository name
1e86867
[REF] Allow same module name across different repositories
37c3426
odoo_repository_*: rename some filters
f9d5798
MigrationScanner: upgrade oca-port
d0753ae
fixup! MigrationScanner: upgrade oca-port
34f6e67
odoo_repository: add new OCA repositories
2dfac36
odoo_repository[_migration]: fix access to 'ir.config_parameter'
0732937
odoo_repository_migration: add tests on 'migration_scan' flag
171de7d
odoo_repository: align tests with last version of oca-port
8ede420
odoo_repository: do not create dependencies and versions from install…
526eb12
MigrationScanner: fix TypeError
a40b9a4
odoo_repository_migration: fix migration data computation
7580903
odoo_repository: add new OCA logistics repositories
e6947bd
BaseScanner: improve helper methods to work on other remotes than 'or…
b25e22e
odoo_repository_migration: support migration scan between two reposit…
56affd2
MigrationScanner: support module renaming
7a8c147
odoo_repository: give write access on module branch for managers
eed9445
odoo_repository: add new OCA stock-logistics-putaway repository
c08ba05
odoo_repository: new field '<odoo.module.branch>.full_path'
6ab8d72
odoo_repository: add new OCA shopfloor-app repository
dfc9d71
odoo_repository: add new OCA bank-payment-alternative repository
hparfr 79cbcf2
[FIX] odoo-addons-analyzer: ignore symlinks
086b542
odoo_repository: scan multiple branches of a repository
b923cee
fixup! odoo_repository: scan multiple branches of a specific (project…
3338f29
BaseScanner: fix '_get_module_paths' method if tree path we are looki…
d35086b
odoo_repository: add new OCA sale-blanket repository
bd3cad5
odoo_repository: fix '_find' method if no repository
b68fd0a
[FIX] odoo-addons-analyzer: skip file in case of parsing error
fb01e7a
[FIX] odoo_repository: remove all specific modules when removing spec…
e30f2fc
[IMP] odoo_repository: add a pivot view for 'Modules' menu entry
b0272ed
[IMP] odoo_repository: add a graph view in a 'Module Analysis' report…
c4e207f
odoo_repository: add '<odoo.branch>.next_id' field
29de03f
odoo_repository: add '<odoo.module.branch>.branch_sequence' field
62a3ba3
odoo_repository: add a root menu 'Data' to host all collected generic…
f6e4220
Add 'odoo_project_changelog' module
3646c6b
[IMP] odoo_repository: switch to 'odoo-addons-parser' package
6afdfb4
[UPD] README.rst
OCA-git-bot bdbdb4d
[FIX] odoo_repository: add 'base' dependency by default on scanned mo…
befd54b
[UPD] README.rst
OCA-git-bot 093540e
[IMP] odoo_repository: update README
0e26c50
[UPD] README.rst
OCA-git-bot 092bfa9
[FIX] odoo_repository_migration: trigger a fetch if module not found …
f1c00e8
[BOT] post-merge updates
OCA-git-bot a25c094
[FIX] odoo_repository: put repository fields readonly when some modul…
2b8a752
[BOT] post-merge updates
OCA-git-bot 5dbc1f6
[FIX] odoo_repository: prevent duplicated module versions
bd230ed
[BOT] post-merge updates
OCA-git-bot 7f28133
[FIX] odoo_repository: followup, add 'base' dependency by default on …
66d6297
[BOT] post-merge updates
OCA-git-bot c3b6ec1
Update all modules manifest and README with new repo info
df6090b
[BOT] post-merge updates
OCA-git-bot 4f16f7a
[IMP] odoo_repository: pre-commit auto fixes
sebalix 010a41a
[IMP] odoo_repository: pre-commit fixes
sebalix 64e114d
[MIG] odoo_repository: Migration to 18.0
sebalix fa55d0e
[FIX] odoo_repository: remove dangling 'git' process when running tests
sebalix 6c379b1
[UPD] Update odoo_repository.pot
5ded7ed
[BOT] post-merge updates
OCA-git-bot 4b4079e
Added translation using Weblate (Italian)
mymage 649b15a
[IMP] odoo_repository: sync OCA repositories
sebalix ac01c37
[UPD] Update odoo_repository.pot
96a717e
[BOT] post-merge updates
OCA-git-bot 5463989
Update translation files
weblate f4552fd
[IMP] odoo_repository: replace oca-port dependency in tests
sebalix bfeb670
[BOT] post-merge updates
OCA-git-bot 7b658c1
[IMP] odoo_repository: generate git repository in setUpClass
sebalix c7cdb18
[FIX] odoo_repository: fix '_get_recursive_dependencies' method
sebalix b2f70e4
[FIX] odoo_repository: fix tests cleanup and remove unused code
sebalix 016a6ca
[BOT] post-merge updates
OCA-git-bot 723b441
[DEL] explicit commits, they are not allowed in queue jobs
thomaspaulb 7d2fb66
[BOT] post-merge updates
OCA-git-bot f3d2a84
[FIX] odoo_repository: tests, apply git config in repository
sebalix 5f0cdf3
[FIX] odoo_repository: move setUp content to setUpClass
sebalix eb38b14
[BOT] post-merge updates
OCA-git-bot 815fbd6
[IMP] odoo_repository: add <odoo.branch>.previous_id field
sebalix 95bebf0
[UPD] Update odoo_repository.pot
b6ba9ad
[BOT] post-merge updates
OCA-git-bot c1c5f8b
Update translation files
weblate d6fb9b2
[MIG] odoo_repository: Migration to 19.0
alan196 b189a42
[FIX] odoo_repository: wait for GitHub API rate limit reset
alan196 435c8ac
[FIX] odoo_repository: scan of modules with a list as manifest author
alan196 f8b1c7e
[FIX] odoo_repository: do not fail scan on module code analysis error
alan196 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| .. image:: https://odoo-community.org/readme-banner-image | ||
| :target: https://odoo-community.org/get-involved?utm_source=readme | ||
| :alt: Odoo Community Association | ||
|
|
||
| ======== | ||
| Odoo MCA | ||
| ======== | ||
|
|
||
| .. | ||
| !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
| !! This file is generated by oca-gen-addon-readme !! | ||
| !! changes will be overwritten. !! | ||
| !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
| !! source digest: sha256:71e3b6009a205241f59db8ab094782861157f514480a57b630abc8e1a10c8d92 | ||
| !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
|
|
||
| .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png | ||
| :target: https://odoo-community.org/page/development-status | ||
| :alt: Beta | ||
| .. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png | ||
| :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
| :alt: License: AGPL-3 | ||
| .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmodule--composition--analysis-lightgray.png?logo=github | ||
| :target: https://github.com/OCA/module-composition-analysis/tree/19.0/odoo_repository | ||
| :alt: OCA/module-composition-analysis | ||
| .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
| :target: https://translation.odoo-community.org/projects/module-composition-analysis-19-0/module-composition-analysis-19-0-odoo_repository | ||
| :alt: Translate me on Weblate | ||
| .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png | ||
| :target: https://runboat.odoo-community.org/builds?repo=OCA/module-composition-analysis&target_branch=19.0 | ||
| :alt: Try me on Runboat | ||
|
|
||
| |badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
|
||
| Base module to host data collected from Odoo repositories. | ||
|
|
||
| It allows you to: | ||
|
|
||
| - declare the Odoo versions (last 3 versions by default) | ||
| - declare repositories containing modules (Odoo repositories included by | ||
| default, and OCA ones are synced automatically) | ||
| - scan these repositories to collect modules informations per Odoo | ||
| version | ||
|
|
||
| **Table of contents** | ||
|
|
||
| .. contents:: | ||
| :local: | ||
|
|
||
| Bug Tracker | ||
| =========== | ||
|
|
||
| Bugs are tracked on `GitHub Issues <https://github.com/OCA/module-composition-analysis/issues>`_. | ||
| In case of trouble, please check there if your issue has already been reported. | ||
| If you spotted it first, help us to smash it by providing a detailed and welcomed | ||
| `feedback <https://github.com/OCA/module-composition-analysis/issues/new?body=module:%20odoo_repository%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
|
||
| Do not contact contributors directly about support or help with technical issues. | ||
|
|
||
| Credits | ||
| ======= | ||
|
|
||
| Authors | ||
| ------- | ||
|
|
||
| * Camptocamp | ||
|
|
||
| Contributors | ||
| ------------ | ||
|
|
||
| - Camptocamp | ||
|
|
||
| - Sébastien Alix <seb@usr-src.org> | ||
|
|
||
| Maintainers | ||
| ----------- | ||
|
|
||
| This module is maintained by the OCA. | ||
|
|
||
| .. image:: https://odoo-community.org/logo.png | ||
| :alt: Odoo Community Association | ||
| :target: https://odoo-community.org | ||
|
|
||
| OCA, or the Odoo Community Association, is a nonprofit organization whose | ||
| mission is to support the collaborative development of Odoo features and | ||
| promote its widespread use. | ||
|
|
||
| This module is part of the `OCA/module-composition-analysis <https://github.com/OCA/module-composition-analysis/tree/19.0/odoo_repository>`_ project on GitHub. | ||
|
|
||
| You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| from . import models | ||
| from . import components | ||
| from . import controllers |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| # Copyright 2023 Camptocamp SA | ||
| # Copyright 2026 Sébastien Alix | ||
| # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) | ||
| { | ||
| "name": "Odoo MCA", | ||
| "summary": "Base module to host data collected from Odoo repositories.", | ||
| "version": "19.0.1.0.0", | ||
| "category": "Tools", | ||
| "author": "Camptocamp, Odoo Community Association (OCA)", | ||
| "website": "https://github.com/OCA/module-composition-analysis", | ||
| "data": [ | ||
| "security/res_groups.xml", | ||
| "security/ir.model.access.csv", | ||
| "data/ir_cron.xml", | ||
| "data/odoo_module.xml", | ||
| "data/odoo_repository_org.xml", | ||
| "data/odoo_repository_addons_path.xml", | ||
| "data/odoo_repository.xml", | ||
| "data/odoo_branch.xml", | ||
| "data/queue_job.xml", | ||
| "data/odoo_mca_backend.xml", | ||
| "data/ir_config_parameter.xml", | ||
| "views/menu.xml", | ||
| "views/authentication_token.xml", | ||
| "views/ssh_key.xml", | ||
| "views/odoo_author.xml", | ||
| "views/odoo_branch.xml", | ||
| "views/odoo_license.xml", | ||
| "views/odoo_maintainer.xml", | ||
| "views/odoo_module.xml", | ||
| "views/odoo_module_branch.xml", | ||
| "views/odoo_module_category.xml", | ||
| "views/odoo_module_dev_status.xml", | ||
| "views/odoo_python_dependency.xml", | ||
| "views/odoo_repository.xml", | ||
| "views/odoo_repository_addons_path.xml", | ||
| "views/odoo_repository_branch.xml", | ||
| "views/odoo_repository_org.xml", | ||
| "views/res_config_settings.xml", | ||
| ], | ||
| "installable": True, | ||
| "application": True, | ||
| "depends": [ | ||
| # core | ||
| "base_sparse_field", | ||
| # OCA/server-tools | ||
| "base_time_window", | ||
| # OCA/queue | ||
| "queue_job", | ||
| # OCA/connector | ||
| "component", | ||
| ], | ||
| "external_dependencies": { | ||
| "python": [ | ||
| "gitpython", | ||
| "odoo-addons-parser", | ||
| "pyyaml", | ||
| # TODO to publish | ||
| # "odoo-repository-scanner" | ||
| ], | ||
| }, | ||
| "license": "AGPL-3", | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| from . import oca_repository_synchronizer |
225 changes: 225 additions & 0 deletions
225
odoo_repository/components/oca_repository_synchronizer.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,225 @@ | ||
| # Copyright 2026 Sébastien Alix | ||
| # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) | ||
|
|
||
| import logging | ||
|
|
||
| import requests | ||
| import yaml | ||
|
|
||
| from odoo import Command | ||
|
|
||
| from odoo.addons.component.core import Component | ||
| from odoo.addons.queue_job.exception import RetryableJobError | ||
|
|
||
| from ..utils import github | ||
|
|
||
| _logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| class OCARepositorySynchronizer(Component): | ||
| """Component for synchronizing OCA repositories from GitHub configuration. | ||
|
|
||
| This component is syncing the list of OCA repositories in local database | ||
| from https://github.com/OCA/repo-maintainer-conf repository. | ||
| It creates new repositories, updates existing ones, and archive those | ||
| no longer declared in the OCA configuration. | ||
| """ | ||
|
|
||
| _name = "oca.repository.synchronizer" | ||
| _collection = "odoo.mca.backend" | ||
| _usage = "oca.repository.synchronizer" | ||
|
|
||
| github_conf_api_url = "repos/OCA/repo-maintainer-conf/contents/conf/repo" | ||
|
|
||
| def _get_oca_repo_blacklist(self): | ||
| """Get OCA repository blacklist from configuration parameter. | ||
|
|
||
| Returns: | ||
| list: List of repository names to skip during synchronization | ||
| """ | ||
| param_value = ( | ||
| self.env["ir.config_parameter"] | ||
| .sudo() | ||
| .get_param("odoo_repository.oca_repo_blacklist", default="") | ||
| ) | ||
| return [repo.strip() for repo in param_value.split(",") if repo.strip()] | ||
|
|
||
| def run(self): | ||
| """Execute OCA repository synchronization. | ||
|
|
||
| Fetches repository configurations from OCA/repo-maintainer-conf, | ||
| parses the YAML files, and synchronizes the local repository database by: | ||
| - Creating new repositories that exist in OCA config but not locally | ||
| - Updating existing repositories with any changes | ||
| - Archiving repositories that no longer exist in OCA config | ||
| """ | ||
| try: | ||
| # Fetch YAML configurations from GitHub | ||
| repo_configs = self._fetch_oca_repo_configurations() | ||
| # Parse and extract repository data | ||
| current_repos = self._parse_oca_repo_configurations(repo_configs) | ||
| # Sync repositories (create/update/archive) | ||
| stats = self._sync_oca_repositories(current_repos) | ||
| _logger.info("OCA repository sync completed: %s", stats) | ||
| return stats | ||
| except github.GitHubRateLimitError as e: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎊 |
||
| # Postpone the job until the rate limit is reset, without | ||
| # increasing its retry counter | ||
| raise RetryableJobError( | ||
| "GitHub API rate limit reached, waiting for reset", | ||
| seconds=e.retry_after, | ||
| ignore_retry=True, | ||
| ) from e | ||
| except Exception as e: | ||
| raise RetryableJobError("Failed to fetch OCA repositories") from e | ||
|
|
||
| def _fetch_oca_repo_configurations(self): | ||
| """Fetch OCA repository configurations from GitHub. | ||
|
|
||
| Returns: | ||
| dict: Repository configurations keyed by filename | ||
| """ | ||
| try: | ||
| # Get list of files in conf/repo directory | ||
| files = github.request(self.work.env, self.github_conf_api_url) | ||
| repo_configs = {} | ||
| for file_info in files: | ||
| if file_info["name"].endswith(".yml"): | ||
| # Fetch the actual YAML content | ||
| download_url = file_info["download_url"] | ||
| response = requests.get(download_url, timeout=30) | ||
| response.raise_for_status() | ||
| repo_configs[file_info["name"]] = response.text | ||
| return repo_configs | ||
| except Exception as e: | ||
| _logger.error("Failed to fetch OCA repo configurations: %s", str(e)) | ||
| raise | ||
|
|
||
| def _parse_oca_repo_configurations(self, repo_configs: dict): | ||
| """Parse YAML configurations and extract OCA repository data. | ||
|
|
||
| Args: | ||
| repo_configs: Dict of filename -> YAML content | ||
|
|
||
| Returns: | ||
| dict: Repository data keyed by repository name, only including | ||
| repositories with non-empty branches | ||
| """ | ||
| current_repos = {} | ||
| for filename, yaml_content in repo_configs.items(): | ||
| try: | ||
| # Parse YAML content | ||
| data = yaml.safe_load(yaml_content) | ||
| if not data: | ||
| continue | ||
| # Process each repository in the YAML file | ||
| for repo_name, repo_config in data.items(): | ||
| # Get blacklist from backend configuration | ||
| blacklist = self._get_oca_repo_blacklist() | ||
| if repo_name in blacklist: | ||
| _logger.info("Skipping import of OCA repository %s", repo_name) | ||
| continue | ||
| # Skip repositories with default_branch = 'master' or 'main' | ||
| # These are not hosting Odoo modules | ||
| default_branch = repo_config.get("default_branch", "") | ||
| if default_branch in ["master", "main"]: | ||
| _logger.info( | ||
| "Skipping OCA repository %s " | ||
| "(default_branch=%s, not hosting Odoo modules)", | ||
| repo_name, | ||
| default_branch, | ||
| ) | ||
| continue | ||
| # Only include repositories with branches. | ||
| # Others repositories are probably not hosting Odoo modules. | ||
| branches = repo_config.get("branches", []) | ||
| if not branches: | ||
| continue | ||
| # Construct repository URLs | ||
| repo_url = f"https://github.com/OCA/{repo_name}" # noqa: E231 | ||
| current_repos[repo_name] = { | ||
| "name": repo_name, | ||
| "repo_url": repo_url, | ||
| "clone_url": repo_url, | ||
| "repo_type": "github", | ||
| } | ||
| except yaml.YAMLError as e: | ||
| _logger.warning("Failed to parse YAML file %s: %s", filename, str(e)) | ||
| continue | ||
| except Exception as e: | ||
| _logger.warning("Error processing file %s: %s", filename, str(e)) | ||
| continue | ||
| return current_repos | ||
|
|
||
| def _sync_oca_repositories(self, current_repos): | ||
| """Synchronize OCA repositories with current configuration. | ||
|
|
||
| Args: | ||
| current_repos: Dict of repository data from OCA configuration | ||
|
|
||
| Returns: | ||
| dict: Statistics about created/updated/archived repositories | ||
| """ | ||
| stats = {"created": 0, "updated": 0, "archived": 0} | ||
| env = self.work.env | ||
| # Get OCA organization | ||
| oca_org = env.ref( | ||
| "odoo_repository.odoo_repository_org_oca", raise_if_not_found=False | ||
| ) | ||
| if not oca_org: | ||
| _logger.warning("OCA organization not found in database") | ||
| return stats | ||
| # Get existing OCA repositories | ||
| odoo_repository = env["odoo.repository"] | ||
| existing_repos = odoo_repository.with_context(active_test=False).search( | ||
| [("org_id", "=", oca_org.id)] | ||
| ) | ||
| # Process current repositories | ||
| for repo_name, repo_data in current_repos.items(): | ||
| # Check if repository already exists | ||
| repo = existing_repos.filtered( | ||
| lambda r, repo_name=repo_name: r.name == repo_name | ||
| ) | ||
| if repo: | ||
| # Update existing repository | ||
| update_vals = self._prepare_oca_repository_update_vals(repo_data) | ||
| # Only update if values have changed | ||
| if any(repo[field] != update_vals[field] for field in update_vals): | ||
| repo.write(update_vals) | ||
| stats["updated"] += 1 | ||
| else: | ||
| # Create new repository | ||
| create_vals = self._prepare_oca_repository_create_vals(repo_data) | ||
| odoo_repository.create(create_vals) | ||
| stats["created"] += 1 | ||
| # Archive repositories that no longer exist in configuration | ||
| for repo in existing_repos: | ||
| if repo.name not in current_repos and repo.active: | ||
| repo.active = repo.to_scan = False | ||
| stats["archived"] += 1 | ||
| return stats | ||
|
|
||
| def _prepare_oca_repository_update_vals(self, repo_data): | ||
| return { | ||
| "repo_url": repo_data["repo_url"], | ||
| "clone_url": repo_data["clone_url"], | ||
| "repo_type": repo_data["repo_type"], | ||
| "active": True, | ||
| } | ||
|
|
||
| def _prepare_oca_repository_create_vals(self, repo_data): | ||
| oca_org = self.work.env.ref("odoo_repository.odoo_repository_org_oca") | ||
| addons_path_community = self.work.env.ref( | ||
| "odoo_repository.odoo_repository_addons_path_community" | ||
| ) | ||
| return { | ||
| "org_id": oca_org.id, | ||
| "name": repo_data["name"], | ||
| "repo_url": repo_data["repo_url"], | ||
| "clone_url": repo_data["clone_url"], | ||
| "repo_type": repo_data["repo_type"], | ||
| "active": True, | ||
| "sequence": 200, | ||
| "to_scan": True, # Enable scanning by default | ||
| "addons_path_ids": [Command.link(addons_path_community.id)], | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| from . import main |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"oca-port" is missing