otoolbox 0.7.4__tar.gz → 0.7.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. otoolbox-0.7.5/.github/copilot-instructions.md +129 -0
  2. {otoolbox-0.7.4 → otoolbox-0.7.5}/.vscode/launch.json +2 -0
  3. {otoolbox-0.7.4/src/otoolbox.egg-info → otoolbox-0.7.5}/PKG-INFO +1 -1
  4. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/repositories/config.py +4 -5
  5. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/repositories/git.py +31 -17
  6. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/vscode/dev_env.py +0 -2
  7. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/workspace/__init__.py +36 -4
  8. otoolbox-0.7.5/src/otoolbox/addons/workspace/data/env +41 -0
  9. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/environment.py +1 -1
  10. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/utils.py +0 -36
  11. {otoolbox-0.7.4 → otoolbox-0.7.5/src/otoolbox.egg-info}/PKG-INFO +1 -1
  12. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox.egg-info/SOURCES.txt +2 -0
  13. otoolbox-0.7.5/tests/test_repositories_git.py +162 -0
  14. otoolbox-0.7.4/tests/test_repositories_git.py +0 -70
  15. {otoolbox-0.7.4 → otoolbox-0.7.5}/.coveragerc +0 -0
  16. {otoolbox-0.7.4 → otoolbox-0.7.5}/.github/workflows/python-package.yml +0 -0
  17. {otoolbox-0.7.4 → otoolbox-0.7.5}/.github/workflows/python-publish.yml +0 -0
  18. {otoolbox-0.7.4 → otoolbox-0.7.5}/.gitignore +0 -0
  19. {otoolbox-0.7.4 → otoolbox-0.7.5}/.logs.txt +0 -0
  20. {otoolbox-0.7.4 → otoolbox-0.7.5}/.pre-commit-config.yaml +0 -0
  21. {otoolbox-0.7.4 → otoolbox-0.7.5}/.pylintrc +0 -0
  22. {otoolbox-0.7.4 → otoolbox-0.7.5}/.pylintrc-mandatory +0 -0
  23. {otoolbox-0.7.4 → otoolbox-0.7.5}/.readthedocs.yml +0 -0
  24. {otoolbox-0.7.4 → otoolbox-0.7.5}/.vscode/otoolbox_debug_runner.py +0 -0
  25. {otoolbox-0.7.4 → otoolbox-0.7.5}/.vscode/settings.json +0 -0
  26. {otoolbox-0.7.4 → otoolbox-0.7.5}/.vscode/tasks.json +0 -0
  27. {otoolbox-0.7.4 → otoolbox-0.7.5}/AUTHORS.rst +0 -0
  28. {otoolbox-0.7.4 → otoolbox-0.7.5}/CHANGELOG.rst +0 -0
  29. {otoolbox-0.7.4 → otoolbox-0.7.5}/CONTRIBUTING.rst +0 -0
  30. {otoolbox-0.7.4 → otoolbox-0.7.5}/LICENSE +0 -0
  31. {otoolbox-0.7.4 → otoolbox-0.7.5}/LICENSE.txt +0 -0
  32. {otoolbox-0.7.4 → otoolbox-0.7.5}/README.rst +0 -0
  33. {otoolbox-0.7.4 → otoolbox-0.7.5}/bin/customer-common +0 -0
  34. {otoolbox-0.7.4 → otoolbox-0.7.5}/bin/customer-config +0 -0
  35. {otoolbox-0.7.4 → otoolbox-0.7.5}/bin/customer-info +0 -0
  36. {otoolbox-0.7.4 → otoolbox-0.7.5}/bin/customer-init +0 -0
  37. {otoolbox-0.7.4 → otoolbox-0.7.5}/bin/customer-shell +0 -0
  38. {otoolbox-0.7.4 → otoolbox-0.7.5}/bin/customer-update +0 -0
  39. {otoolbox-0.7.4 → otoolbox-0.7.5}/bin/customer-update-submodule +0 -0
  40. {otoolbox-0.7.4 → otoolbox-0.7.5}/bin/otoolbox-commit +0 -0
  41. {otoolbox-0.7.4 → otoolbox-0.7.5}/bin/otoolbox-common +0 -0
  42. {otoolbox-0.7.4 → otoolbox-0.7.5}/bin/otoolbox-doctor +0 -0
  43. {otoolbox-0.7.4 → otoolbox-0.7.5}/bin/otoolbox-doctor.bat +0 -0
  44. {otoolbox-0.7.4 → otoolbox-0.7.5}/bin/otoolbox-init-tests +0 -0
  45. {otoolbox-0.7.4 → otoolbox-0.7.5}/bin/otoolbox-pre-commit +0 -0
  46. {otoolbox-0.7.4 → otoolbox-0.7.5}/bin/otoolbox-pull +0 -0
  47. {otoolbox-0.7.4 → otoolbox-0.7.5}/bin/otoolbox-push +0 -0
  48. {otoolbox-0.7.4 → otoolbox-0.7.5}/bin/otoolbox-push-shielded +0 -0
  49. {otoolbox-0.7.4 → otoolbox-0.7.5}/bin/otoolbox-repo-add-all +0 -0
  50. {otoolbox-0.7.4 → otoolbox-0.7.5}/bin/otoolbox-repo-init +0 -0
  51. {otoolbox-0.7.4 → otoolbox-0.7.5}/bin/otoolbox-sync-shielded +0 -0
  52. {otoolbox-0.7.4 → otoolbox-0.7.5}/bin/otoolbox-tests-by-repo +0 -0
  53. {otoolbox-0.7.4 → otoolbox-0.7.5}/docs/Makefile +0 -0
  54. {otoolbox-0.7.4 → otoolbox-0.7.5}/docs/_static/.gitignore +0 -0
  55. {otoolbox-0.7.4 → otoolbox-0.7.5}/docs/authors.rst +0 -0
  56. {otoolbox-0.7.4 → otoolbox-0.7.5}/docs/changelog.rst +0 -0
  57. {otoolbox-0.7.4 → otoolbox-0.7.5}/docs/conf.py +0 -0
  58. {otoolbox-0.7.4 → otoolbox-0.7.5}/docs/contributing.rst +0 -0
  59. {otoolbox-0.7.4 → otoolbox-0.7.5}/docs/help-repo.txt +0 -0
  60. {otoolbox-0.7.4 → otoolbox-0.7.5}/docs/index.rst +0 -0
  61. {otoolbox-0.7.4 → otoolbox-0.7.5}/docs/license.rst +0 -0
  62. {otoolbox-0.7.4 → otoolbox-0.7.5}/docs/readme.rst +0 -0
  63. {otoolbox-0.7.4 → otoolbox-0.7.5}/docs/requirements.txt +0 -0
  64. {otoolbox-0.7.4 → otoolbox-0.7.5}/pyproject.toml +0 -0
  65. {otoolbox-0.7.4 → otoolbox-0.7.5}/setup.cfg +0 -0
  66. {otoolbox-0.7.4 → otoolbox-0.7.5}/setup.py +0 -0
  67. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/__init__.py +0 -0
  68. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/__init__.py +0 -0
  69. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/addons/README.rst +0 -0
  70. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/addons/__init__.py +0 -0
  71. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/addons/config.py +0 -0
  72. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/addons/constants.py +0 -0
  73. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/copilot/README.rst +0 -0
  74. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/copilot/__init__.py +0 -0
  75. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/copilot/copilot_utils.py +0 -0
  76. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/copilot/data/agents/Odoo_17_Backend.agent.md +0 -0
  77. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/copilot/data/agents/Odoo_18_Backend.agent.md +0 -0
  78. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/copilot/data/agents/Odoo_19_Backend.agent.md +0 -0
  79. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/copilot/data/copilot-instructions.md +0 -0
  80. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/docker/README.rst +0 -0
  81. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/docker/docker-compose.yml +0 -0
  82. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/help/README.rst +0 -0
  83. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/help/__init__.py +0 -0
  84. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/help/data/README.rst +0 -0
  85. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/help/data/docs/00-file-and-folders.md +0 -0
  86. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/help/data/docs/01-global-style.md +0 -0
  87. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/help/data/docs/02-odoo-patterns.md +0 -0
  88. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/help/data/docs/03-testing-and-validation.md +0 -0
  89. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/help/data/docs/04-security-and-secrets.md +0 -0
  90. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/help/data/docs/05-oca-contributing-reference.md +0 -0
  91. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/help/data/docs/06-odoo-test-framework-guid.md +0 -0
  92. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/help/data/docs/07-odoonix-guidline.md +0 -0
  93. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/help/data/docs/08-copilot-instructions-guideline.md +0 -0
  94. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/help/data/docs/09-team-playbook.md +0 -0
  95. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/help/help_utils.py +0 -0
  96. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/logger/README.rst +0 -0
  97. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/logger/__init__.py +0 -0
  98. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/repositories/README.rst +0 -0
  99. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/repositories/__init__.py +0 -0
  100. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/repositories/constants.py +0 -0
  101. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/repositories/data/repositories.csv +0 -0
  102. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/repositories/data/repositories.json +0 -0
  103. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/repositories/display.py +0 -0
  104. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/repositories/util.py +0 -0
  105. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/ubuntu/README.rst +0 -0
  106. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/ubuntu/__init__.py +0 -0
  107. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/ubuntu/bin/bulk-add-repos +0 -0
  108. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/ubuntu/bin/bulk-commit +0 -0
  109. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/ubuntu/bin/bulk-common +0 -0
  110. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/ubuntu/bin/bulk-init-tests +0 -0
  111. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/ubuntu/bin/bulk-pre-commit +0 -0
  112. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/ubuntu/bin/bulk-pull +0 -0
  113. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/ubuntu/bin/bulk-push +0 -0
  114. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/ubuntu/bin/bulk-push-shielded +0 -0
  115. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/ubuntu/bin/bulk-repo-add-all +0 -0
  116. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/ubuntu/bin/bulk-repo-init +0 -0
  117. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/ubuntu/bin/bulk-sync-shielded +0 -0
  118. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/ubuntu/bin/bulk-tests-by-repo +0 -0
  119. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/ubuntu/bin/customer-common +0 -0
  120. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/ubuntu/bin/customer-config +0 -0
  121. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/ubuntu/bin/customer-info +0 -0
  122. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/ubuntu/bin/customer-init +0 -0
  123. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/ubuntu/bin/customer-shell +0 -0
  124. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/ubuntu/bin/customer-update +0 -0
  125. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/ubuntu/bin/customer-update-submodule +0 -0
  126. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/ubuntu/bin/ubuntu-install-apps +0 -0
  127. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/ubuntu/bin/ubuntu-office-conf +0 -0
  128. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/unitest/__init__.py +0 -0
  129. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/unitest/data/ODOO_TEST_FRAMEWORK_GUIDE.md +0 -0
  130. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/unitest/data/conftest.py +0 -0
  131. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/unitest/data/pytest.ini +0 -0
  132. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/unitest/unitest_utils.py +0 -0
  133. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/vscode/README.rst +0 -0
  134. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/vscode/__init__.py +0 -0
  135. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/vscode/data/odools.toml +0 -0
  136. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/vscode/data/requirements.txt +0 -0
  137. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/vscode/data/workspace.json +0 -0
  138. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/vscode/extensions.py +0 -0
  139. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/vscode/odoo_conf.py +0 -0
  140. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/vscode/odools_conf.py +0 -0
  141. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/addons/workspace/README.rst +0 -0
  142. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/banner.txt +0 -0
  143. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/base.py +0 -0
  144. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox/constants.py +0 -0
  145. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox.egg-info/dependency_links.txt +0 -0
  146. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox.egg-info/entry_points.txt +0 -0
  147. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox.egg-info/not-zip-safe +0 -0
  148. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox.egg-info/requires.txt +0 -0
  149. {otoolbox-0.7.4 → otoolbox-0.7.5}/src/otoolbox.egg-info/top_level.txt +0 -0
  150. {otoolbox-0.7.4 → otoolbox-0.7.5}/tests/test_addons.py +0 -0
  151. {otoolbox-0.7.4 → otoolbox-0.7.5}/tests/test_conftest.py +0 -0
  152. {otoolbox-0.7.4 → otoolbox-0.7.5}/tests/test_copilot_utils.py +0 -0
  153. {otoolbox-0.7.4 → otoolbox-0.7.5}/tests/test_doctor_script_packaging.py +0 -0
  154. {otoolbox-0.7.4 → otoolbox-0.7.5}/tests/test_repositories_config.py +0 -0
  155. {otoolbox-0.7.4 → otoolbox-0.7.5}/tests/test_utils.py +0 -0
  156. {otoolbox-0.7.4 → otoolbox-0.7.5}/tox.ini +0 -0
@@ -0,0 +1,129 @@
1
+ # Copilot Instructions — otoolbox
2
+
3
+ ## Purpose
4
+
5
+ `otoolbox` is a utility tool to maintain Odoo **development environments** and **production source code**.
6
+ It manages a collection of *resources* (git repositories, config files, VS Code workspaces, addons, etc.)
7
+ through a structured lifecycle with well-defined processes at each step.
8
+
9
+ ---
10
+
11
+ ## Core Architecture
12
+
13
+ ### Environment
14
+
15
+ `Environment` (see `src/otoolbox/environment.py`) is the top-level container.
16
+ - Holds a `ResourceSet` — the collection of all resources loaded for the current run.
17
+ - Provides `context` (author, organisation metadata) passed into processes.
18
+ - Entry point for all CLI commands.
19
+
20
+ ### Resource
21
+
22
+ `Resource` (see `src/otoolbox/base.py`) is the fundamental unit of the system.
23
+ - Represents a single managed entity: a git repo, a config file, a workspace, a VS Code extension, etc.
24
+ - Has a `path` (unique key), `tags` list, `priority`, `parent`, and lifecycle processors.
25
+ - Is identified and filtered by its `tags`.
26
+
27
+ ### Resource Lifecycle
28
+
29
+ Every resource moves through a fixed set of steps (defined in `src/otoolbox/constants.py`):
30
+
31
+ | Step | Constant | Meaning |
32
+ |------------|----------------|---------------------------------------------|
33
+ | `init` | `STEP_INIT` | Initialise / create the resource |
34
+ | `build` | `STEP_BUILD` | Build or clone the resource |
35
+ | `verify` | `STEP_VERIFY` | Verify the resource is healthy |
36
+ | `update` | `STEP_UPDATE` | Update / synchronise the resource |
37
+ | `destroy` | `STEP_DESTROY` | Remove or tear down the resource |
38
+
39
+ ### ResourceProcessor
40
+
41
+ `ResourceProcessor` (see `src/otoolbox/base.py`) wraps a single callable *process function*.
42
+ - Bound to one `Resource` and one `step`.
43
+ - When executed, calls `process(context=resource, **kargs)`.
44
+ - Returns a `(result, message)` tuple where result is `PROCESS_SUCCESS`, `PROCESS_FAIL`, or `PROCESS_WAR`.
45
+
46
+ ### ResourceExecutor / ResourceSetExecutor
47
+
48
+ - `ResourceExecutor` runs all processors of a resource for a given set of steps, in registration order.
49
+ - `ResourceSetExecutor` runs all executors in the set, sorted by `resource.priority` (highest first).
50
+
51
+ ---
52
+
53
+ ## Process Function Contract
54
+
55
+ Every process function **must** follow this signature:
56
+
57
+ ```python
58
+ def my_process(context: Resource, **kargs) -> tuple[str, str]:
59
+ """Brief description of what this process does."""
60
+ # context is the Resource being processed
61
+ # return (result_constant, human_readable_message)
62
+ return PROCESS_SUCCESS, ""
63
+ ```
64
+
65
+ Result constants (import from `otoolbox.constants`):
66
+ - `PROCESS_SUCCESS` — step completed successfully.
67
+ - `PROCESS_FAIL` — step failed; execution continues but the failure is logged.
68
+ - `PROCESS_WAR` — step completed with a warning.
69
+
70
+ ---
71
+
72
+ ## Tags and Filtering
73
+
74
+ - Resources declare `tags` (a list of strings). `path` is always added as a tag.
75
+ - Standard tag constants are in `otoolbox.constants` (`RESOURCE_TAGS_GIT`, `RESOURCE_TAGS_ENV`, etc.).
76
+ - CLI commands accept `--tags` to filter which resources are processed.
77
+ - Use `resource.has_tags(*tags)` to check tag membership (all tags must match).
78
+
79
+ ---
80
+
81
+ ## Adding a New Resource Type
82
+
83
+ 1. Subclass `Resource` in the appropriate addon package under `src/otoolbox/addons/`.
84
+ 2. Register processors with `resource.add_processor(process_fn, step=STEP_BUILD, title="...")`.
85
+ 3. Add the resource to the environment's `ResourceSet` via an addon `__init__.py` setup hook.
86
+ 4. Tag the resource appropriately so CLI filters work correctly.
87
+
88
+ ## Adding a New Process
89
+
90
+ 1. Define the process function with the contract above.
91
+ 2. Register it on the target resource at the right step.
92
+ 3. Keep each process function focused on a single responsibility.
93
+ 4. Do not raise exceptions for expected failures — return `PROCESS_FAIL` with a descriptive message.
94
+
95
+ ---
96
+
97
+ ## Addon Structure
98
+
99
+ Each addon lives under `src/otoolbox/addons/<name>/` and follows this layout:
100
+
101
+ ```
102
+ <name>/
103
+ __init__.py # registers resources / processors into the environment
104
+ config.py # addon-specific configuration constants
105
+ constants.py # addon-specific string/value constants
106
+ <name>_utils.py # utility helpers (no side effects at import time)
107
+ data/ # static data files (templates, CSVs, JSON, etc.)
108
+ README.rst # human-readable addon description
109
+ ```
110
+
111
+ ---
112
+
113
+ ## Code Style
114
+
115
+ - Follow PEP 8. Maximum line length 100 characters.
116
+ - Imports order: Python standard library → third-party → `otoolbox` modules → current addon.
117
+ - Use `logging.getLogger(__name__)` — never `print()` for operational output; use `rich` console for user-facing output.
118
+ - Constants belong in `otoolbox/constants.py` (global) or `<addon>/constants.py` (addon-scoped).
119
+ - Do not add logic to `__init__.py` beyond registration calls.
120
+
121
+ ---
122
+
123
+ ## Testing
124
+
125
+ - Tests live in `tests/` at the repo root.
126
+ - Use `pytest`. Run with: `source .venv/bin/activate && python -m pytest tests/`
127
+ - Each test file mirrors a source module: `test_<module>.py`.
128
+ - Process functions should be unit-testable by calling them directly with a mock `Resource` context.
129
+ - Use `PROCESS_SUCCESS`/`PROCESS_FAIL` assertions — do not assert on message strings unless necessary.
@@ -14,8 +14,10 @@
14
14
  "options": [
15
15
  "run --help",
16
16
  "run init --help",
17
+ "run init",
17
18
  "run init --tags copilot",
18
19
  "run update --help",
20
+ "run update",
19
21
  "run update --tags odools.toml",
20
22
  "run update --tags README.rst",
21
23
  "run update --tags documentation",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: otoolbox
3
- Version: 0.7.4
3
+ Version: 0.7.5
4
4
  Summary: Utilities for Odoo from Odoonix
5
5
  Home-page: https://odoonix.com/apps/otoolbox
6
6
  Author: Odoonix
@@ -104,11 +104,10 @@ def _discover_workspace_repositories():
104
104
  for repository_entry in sorted(
105
105
  os.scandir(organization_entry.path), key=lambda entry: entry.name
106
106
  ):
107
- if not repository_entry.is_dir():
108
- continue
109
-
110
- git_dir = os.path.join(repository_entry.path, ".git")
111
- if os.path.isdir(git_dir):
107
+ if (
108
+ repository_entry.is_dir()
109
+ and git._is_git_repository(repository_entry.path)
110
+ ):
112
111
  repo_list.append(
113
112
  {
114
113
  "repository": repository_entry.name,
@@ -76,14 +76,14 @@ def _get_branch_name(context: Resource):
76
76
  def _get_repo_path(context: Resource):
77
77
  git_repository_policy = env.get_env_variable("GIT_REPOSITORIES_POLICY")
78
78
  repo_path = ""
79
- if git_repository_policy == "standalone":
80
- repo_path = env.get_workspace_path(context.path)
81
- else:
79
+ if _use_multi_worktree():
82
80
  git_repositories_root = env.get_env_variable("GIT_REPOSITORIES_ROOT")
83
81
  assert (
84
82
  git_repositories_root
85
83
  ), "Root path of repositories is required set GIT_REPOSITORIES_ROOT"
86
84
  repo_path = env.get_workspace_path(git_repositories_root, context.path)
85
+ else:
86
+ repo_path = env.get_workspace_path(context.path)
87
87
  return repo_path
88
88
 
89
89
 
@@ -153,6 +153,19 @@ def _is_git_repository_main(repository_path):
153
153
  return False
154
154
 
155
155
 
156
+ def _is_git_worktree(repository_path):
157
+ """Return True only for linked worktrees where .git is a file."""
158
+ if not os.path.isdir(repository_path):
159
+ return False
160
+ return os.path.isfile(os.path.join(repository_path, ".git"))
161
+
162
+
163
+ def _use_multi_worktree():
164
+ """Check if should use a single repository with multi worktree"""
165
+ git_repository_policy = env.get_env_variable("GIT_REPOSITORIES_POLICY")
166
+ assert git_repository_policy, "Policy is required"
167
+ return git_repository_policy != "standalone"
168
+
156
169
  ######################################################################################
157
170
  # Resource Processors #
158
171
  # Resource processors are used to process resources from the workspace. The resource #
@@ -161,6 +174,9 @@ def _is_git_repository_main(repository_path):
161
174
 
162
175
 
163
176
  def git_link_to_repositoires_root(context: Resource):
177
+ if not _use_multi_worktree():
178
+ return PROCESS_SUCCESS, _get_branch_name(context=context)
179
+
164
180
  # Get root path
165
181
  path_root = env.get_env_variable("GIT_REPOSITORIES_ROOT", "~/Repositories")
166
182
  path_root = os.path.abspath(os.path.expanduser(path_root))
@@ -174,16 +190,16 @@ def git_link_to_repositoires_root(context: Resource):
174
190
  )
175
191
  assert branch_name, "Branch name is required"
176
192
 
177
- # if repo_path is in path_root then return sucess
178
- c_repo_path = _get_repo_path(context)
179
- if (
180
- _is_path_in_root(c_repo_path, path_root)
181
- and not _is_git_repository_main(repo_path)
182
- and _is_git_repository_main(repository_root_path)
183
- ):
193
+ # Nothing to do when the workspace repository is already a linked worktree.
194
+ if _is_git_worktree(repo_path) and _is_git_repository_main(repository_root_path):
195
+ return PROCESS_SUCCESS, _get_branch_name(context=context)
196
+
197
+ if _is_git_repository_main(repo_path) and _is_path_in_root(repo_path, path_root):
184
198
  return PROCESS_SUCCESS, _get_branch_name(context=context)
185
199
 
186
- if not _is_git_repository(repo_path):
200
+ if not _is_git_repository(repo_path) and not _is_git_repository_main(
201
+ repository_root_path
202
+ ):
187
203
  raise RuntimeError(f"Not a git repository: {repo_path}")
188
204
 
189
205
  if not _is_git_repository(repository_root_path):
@@ -201,7 +217,9 @@ def git_link_to_repositoires_root(context: Resource):
201
217
  random_branch_name = _create_random_branch_name()
202
218
  _run_git(["checkout", "-B", random_branch_name], cwd=repository_root_path)
203
219
 
204
- shutil.rmtree(repo_path)
220
+ if os.path.exists(repo_path):
221
+ shutil.rmtree(repo_path)
222
+
205
223
  _run_git(
206
224
  [
207
225
  "worktree",
@@ -224,9 +242,7 @@ def git_link_to_repositoires_root(context: Resource):
224
242
 
225
243
  def git_worktree_create(context: Resource):
226
244
  """Create a git worktree for the given branch."""
227
- git_repository_policy = env.get_env_variable("GIT_REPOSITORIES_POLICY")
228
- assert git_repository_policy, "Policy is required"
229
- if git_repository_policy == "standalone":
245
+ if not _use_multi_worktree():
230
246
  _logger.debug(
231
247
  "Repository policy is standalone, using single worktree for each repo"
232
248
  )
@@ -238,8 +254,6 @@ def git_worktree_create(context: Resource):
238
254
  git_repository_root = env.get_workspace_path(git_repositories_root, context.path)
239
255
  context_path = env.get_workspace_path(context.path)
240
256
 
241
- # repo_path = _get_repo_path(context)
242
- # context_pat = env.get_workspace_path(context.path)
243
257
 
244
258
  if _is_git_repository(context_path):
245
259
  return PROCESS_SUCCESS, _get_branch_name(context=context)
@@ -16,8 +16,6 @@ def pyenv_create(context: Resource):
16
16
  It install and init .venv to the workspace. It also install all required
17
17
  tools for the development env. All odoo dependencies are installed
18
18
  in the .venv.
19
-
20
-
21
19
  """
22
20
  result = subprocess.run(
23
21
  [
@@ -44,16 +44,48 @@ def init(addon):
44
44
  verify=[utils.is_dir, utils.is_readable],
45
45
  tags=[RESOURCE_TAGS_AUTO_UPDATE, RESOURCE_TAGS_AUTO_VERIFY],
46
46
  )
47
+ env.add_resource(
48
+ priority=RESOURCE_PRIORITY_ROOT,
49
+ path=".env~",
50
+ parent=RESOURCE_ROOT,
51
+ title="Envirenments Variables Template",
52
+ description="The env variables file template",
53
+ init=[
54
+ utils.constructor_copy_resource("addons/workspace/data/env")
55
+ ],
56
+ update=[
57
+ utils.constructor_copy_resource("addons/workspace/data/env")
58
+ ],
59
+ destroy=[utils.delete_file],
60
+ verify=[
61
+ utils.is_file,
62
+ utils.is_readable,
63
+ utils.is_writable,
64
+ ],
65
+ tags=[RESOURCE_TAGS_ENV, RESOURCE_TAGS_AUTO_UPDATE, RESOURCE_TAGS_AUTO_VERIFY],
66
+ )
47
67
  env.add_resource(
48
68
  priority=RESOURCE_PRIORITY_ROOT,
49
69
  path=RESOURCE_ENV_FILE,
50
70
  parent=RESOURCE_ROOT,
51
71
  title="Envirenments Variables",
52
- description="The env variables file",
53
- init=[utils.touch_file, utils.set_to_env_all],
54
- update=[utils.set_to_env_all],
72
+ description="The env variables file is a readonly file. Fill the file to "
73
+ "controll the workspace behavior",
74
+ init=[
75
+ utils.touch_file,
76
+ # .env is readonly file
77
+ ],
78
+ update=[
79
+ # .env is readonly file
80
+ ],
55
81
  destroy=[utils.delete_file],
56
- verify=[utils.is_file, utils.is_readable, utils.is_writable],
82
+ verify=[
83
+ utils.is_file,
84
+ utils.is_readable,
85
+ utils.is_writable,
86
+ # Checking Variables
87
+
88
+ ],
57
89
  tags=[RESOURCE_TAGS_ENV, RESOURCE_TAGS_AUTO_UPDATE, RESOURCE_TAGS_AUTO_VERIFY],
58
90
  )
59
91
  env.add_resource(
@@ -0,0 +1,41 @@
1
+ # Git
2
+ #-----------------------------------------------------------------------------
3
+ SSH_AUTH="yes"
4
+ GIT_REPOSITORIES_POLICY="multi-worktrees"
5
+ GIT_REPOSITORIES_ROOT="/home/maso/Repositories"
6
+
7
+ # Git Organization
8
+ ORGANIZATIONS=("odoonix" "oca" "odoo")
9
+
10
+ # Recommanded Repositories
11
+ REPOSITORIES=()
12
+
13
+
14
+
15
+
16
+ # Protected Git
17
+ #-----------------------------------------------------------------------------
18
+ WORKER_USER="worker"
19
+
20
+ # Git organizations
21
+ PROTECTED_ORGANIZATIONS=("moonsun")
22
+
23
+ # Recommanded Repositories
24
+ PROTECTED_REPOSITORIES=()
25
+
26
+
27
+
28
+ # Python
29
+ #-----------------------------------------------------------------------------
30
+ VENV_PATH=".venv"
31
+
32
+
33
+
34
+ # Odoo
35
+ #-----------------------------------------------------------------------------
36
+ # Set Odoo Version
37
+ # Odoo has many major branches such as 19.0, 18.0 and 17.0. Each workspace can
38
+ # works on an specific version of odoo. This variable controlle the version.
39
+ ODOO_VERSION="17.0"
40
+
41
+
@@ -68,7 +68,7 @@ class Environment:
68
68
  if os.path.isfile(dotenv_path):
69
69
  dotenv.load_dotenv(dotenv_path)
70
70
  value = os.environ.get(name, default)
71
- if isinstance(default, list):
71
+ if isinstance(default, list) and isinstance(value, str):
72
72
  value = value.split(",")
73
73
  return value
74
74
 
@@ -274,42 +274,6 @@ def __is_not_primitive(value):
274
274
  return not isinstance(value, primitive_types)
275
275
 
276
276
 
277
- def set_to_env(path, key, value):
278
- """Adds new environment variable to the .env file and optionally to the current
279
- process environment."""
280
-
281
- if __is_not_primitive(value):
282
- return
283
- key = key.upper()
284
- value = str(value)
285
-
286
- if key in ["PATH"]:
287
- _logger.warning(
288
- "Forbiden to change Linux default environment variables: %s", key
289
- )
290
- return
291
-
292
- env_vars = dotenv_values(path)
293
- env_vars[key] = value
294
-
295
- # Write all variables back to the .env file
296
- with open(path, "w", encoding="utf8") as f:
297
- for k, v in env_vars.items():
298
- f.write(f'{k}="{v}"\n')
299
-
300
- # Optionally, update the current process environment
301
- os.environ[key] = str(value)
302
-
303
-
304
- def set_to_env_all(context: Resource):
305
- """Adds all environment variables to the .env file and optionally to the current
306
- process environment."""
307
- path = env.get_workspace_path(context.path)
308
- for k, v in env.context.items():
309
- set_to_env(path, k, v)
310
- return PROCESS_SUCCESS, PROCESS_EMPTY_MESSAGE
311
-
312
-
313
277
  def print_result(result=None):
314
278
  """Print resource executors"""
315
279
  if not result:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: otoolbox
3
- Version: 0.7.4
3
+ Version: 0.7.5
4
4
  Summary: Utilities for Odoo from Odoonix
5
5
  Home-page: https://odoonix.com/apps/otoolbox
6
6
  Author: Odoonix
@@ -15,6 +15,7 @@ pyproject.toml
15
15
  setup.cfg
16
16
  setup.py
17
17
  tox.ini
18
+ .github/copilot-instructions.md
18
19
  .github/workflows/python-package.yml
19
20
  .github/workflows/python-publish.yml
20
21
  .vscode/launch.json
@@ -143,6 +144,7 @@ src/otoolbox/addons/vscode/data/requirements.txt
143
144
  src/otoolbox/addons/vscode/data/workspace.json
144
145
  src/otoolbox/addons/workspace/README.rst
145
146
  src/otoolbox/addons/workspace/__init__.py
147
+ src/otoolbox/addons/workspace/data/env
146
148
  tests/test_addons.py
147
149
  tests/test_conftest.py
148
150
  tests/test_copilot_utils.py
@@ -0,0 +1,162 @@
1
+ from types import SimpleNamespace
2
+
3
+ import pytest
4
+
5
+ from otoolbox import env
6
+ from otoolbox.constants import PROCESS_SUCCESS
7
+ from otoolbox.addons.repositories import git
8
+
9
+
10
+ def test_git_add_safe_directory_executes_expected_command(monkeypatch, tmp_path):
11
+ monkeypatch.setitem(env.context, "path", str(tmp_path))
12
+ context = SimpleNamespace(path="moonsunsoft/payment")
13
+ calls = {}
14
+
15
+ def fake_call_process_safe(command, cwd=None, **kwargs):
16
+ calls["command"] = command
17
+ calls["cwd"] = cwd
18
+ return SimpleNamespace(returncode=0, stderr="")
19
+
20
+ monkeypatch.setattr(git.utils, "call_process_safe", fake_call_process_safe)
21
+
22
+ result, message = git.git_add_safe_directory(context)
23
+
24
+ expected_path = str(tmp_path / "moonsunsoft" / "payment")
25
+ assert calls["command"] == [
26
+ "git",
27
+ "config",
28
+ "--global",
29
+ "--add",
30
+ "safe.directory",
31
+ expected_path,
32
+ ]
33
+ assert calls["cwd"] == str(tmp_path)
34
+ assert result == PROCESS_SUCCESS
35
+ assert expected_path in message
36
+
37
+
38
+ def test_git_add_safe_directory_raises_on_error(monkeypatch, tmp_path):
39
+ monkeypatch.setitem(env.context, "path", str(tmp_path))
40
+ context = SimpleNamespace(path="moonsunsoft/payment")
41
+
42
+ monkeypatch.setattr(
43
+ git.utils,
44
+ "call_process_safe",
45
+ lambda *args, **kwargs: SimpleNamespace(returncode=1, stderr="boom"),
46
+ )
47
+
48
+ with pytest.raises(RuntimeError, match="boom"):
49
+ git.git_add_safe_directory(context)
50
+
51
+
52
+ def test_get_branch_name_uses_abbrev_ref_and_returns_clean_output(
53
+ monkeypatch, tmp_path
54
+ ):
55
+ monkeypatch.setitem(env.context, "path", str(tmp_path))
56
+ context = SimpleNamespace(path="moonsunsoft/payment")
57
+ calls = {}
58
+
59
+ def fake_subprocess_run(command, capture_output, text, cwd, check):
60
+ calls["command"] = command
61
+ calls["cwd"] = cwd
62
+ return SimpleNamespace(returncode=0, stdout="17.0\n", stderr="")
63
+
64
+ monkeypatch.setattr(git.subprocess, "run", fake_subprocess_run)
65
+
66
+ branch_name = git._get_branch_name(context)
67
+
68
+ assert calls["command"] == ["git", "rev-parse", "--abbrev-ref", "HEAD"]
69
+ assert calls["cwd"] == str(tmp_path / "moonsunsoft" / "payment")
70
+ assert branch_name == "17.0"
71
+
72
+
73
+ def test_git_link_to_repositories_root_noop_when_workspace_is_worktree(
74
+ monkeypatch, tmp_path
75
+ ):
76
+ monkeypatch.setitem(env.context, "path", str(tmp_path))
77
+ context = SimpleNamespace(path="moonsunsoft/payment", branch="17.0")
78
+
79
+ workspace_repo_path = str(tmp_path / "moonsunsoft" / "payment")
80
+ root_base = str(tmp_path / "central")
81
+ root_repo_path = str(tmp_path / "central" / "moonsunsoft" / "payment")
82
+
83
+ monkeypatch.setattr(git, "_use_multi_worktree", lambda: True)
84
+ monkeypatch.setattr(
85
+ env,
86
+ "get_env_variable",
87
+ lambda name, default=None: (
88
+ root_base
89
+ if name == "GIT_REPOSITORIES_ROOT"
90
+ else ("17.0" if name == "ODOO_VERSION" else default)
91
+ ),
92
+ )
93
+ monkeypatch.setattr(git, "_is_git_worktree", lambda path: path == workspace_repo_path)
94
+ monkeypatch.setattr(
95
+ git, "_is_git_repository_main", lambda path: path == root_repo_path
96
+ )
97
+ monkeypatch.setattr(git, "_get_branch_name", lambda context: "17.0")
98
+
99
+ run_git_calls = []
100
+ monkeypatch.setattr(
101
+ git,
102
+ "_run_git",
103
+ lambda command, cwd: run_git_calls.append((command, cwd)),
104
+ )
105
+
106
+ result, message = git.git_link_to_repositoires_root(context)
107
+
108
+ assert result == PROCESS_SUCCESS
109
+ assert message == "17.0"
110
+ assert run_git_calls == []
111
+
112
+
113
+ def test_git_link_to_repositories_root_creates_worktree_when_missing(
114
+ monkeypatch, tmp_path
115
+ ):
116
+ monkeypatch.setitem(env.context, "path", str(tmp_path))
117
+ context = SimpleNamespace(path="moonsunsoft/payment", branch="17.0")
118
+
119
+ workspace_repo_path = str(tmp_path / "moonsunsoft" / "payment")
120
+ root_base = str(tmp_path / "central")
121
+ root_repo_path = str(tmp_path / "central" / "moonsunsoft" / "payment")
122
+
123
+ monkeypatch.setattr(git, "_use_multi_worktree", lambda: True)
124
+ monkeypatch.setattr(
125
+ env,
126
+ "get_env_variable",
127
+ lambda name, default=None: (
128
+ root_base
129
+ if name == "GIT_REPOSITORIES_ROOT"
130
+ else ("17.0" if name == "ODOO_VERSION" else default)
131
+ ),
132
+ )
133
+ monkeypatch.setattr(git, "_is_git_worktree", lambda path: False)
134
+ monkeypatch.setattr(
135
+ git,
136
+ "_is_git_repository_main",
137
+ lambda path: path == root_repo_path,
138
+ )
139
+ monkeypatch.setattr(
140
+ git,
141
+ "_is_git_repository",
142
+ lambda path: path == root_repo_path,
143
+ )
144
+ monkeypatch.setattr(git, "_get_branch_name_from_path", lambda path: "main")
145
+ monkeypatch.setattr(git, "_get_branch_name", lambda context: "17.0")
146
+
147
+ run_git_calls = []
148
+
149
+ def fake_run_git(command, cwd):
150
+ run_git_calls.append((command, cwd))
151
+ return SimpleNamespace(returncode=0, stderr="")
152
+
153
+ monkeypatch.setattr(git, "_run_git", fake_run_git)
154
+
155
+ result, message = git.git_link_to_repositoires_root(context)
156
+
157
+ assert result == PROCESS_SUCCESS
158
+ assert message == "17.0"
159
+ assert run_git_calls == [
160
+ (["worktree", "prune"], root_repo_path),
161
+ (["worktree", "add", workspace_repo_path, "origin/17.0"], root_repo_path),
162
+ ]