otoolbox 0.7.4__tar.gz → 0.7.6__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.6/.github/copilot-instructions.md +129 -0
  2. {otoolbox-0.7.4 → otoolbox-0.7.6}/.vscode/launch.json +2 -0
  3. {otoolbox-0.7.4/src/otoolbox.egg-info → otoolbox-0.7.6}/PKG-INFO +1 -1
  4. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/repositories/config.py +3 -5
  5. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/repositories/git.py +55 -20
  6. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/vscode/dev_env.py +0 -2
  7. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/workspace/__init__.py +31 -4
  8. otoolbox-0.7.6/src/otoolbox/addons/workspace/data/env +47 -0
  9. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/environment.py +1 -1
  10. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/utils.py +0 -37
  11. {otoolbox-0.7.4 → otoolbox-0.7.6/src/otoolbox.egg-info}/PKG-INFO +1 -1
  12. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox.egg-info/SOURCES.txt +2 -0
  13. otoolbox-0.7.6/tests/test_repositories_git.py +198 -0
  14. otoolbox-0.7.4/tests/test_repositories_git.py +0 -70
  15. {otoolbox-0.7.4 → otoolbox-0.7.6}/.coveragerc +0 -0
  16. {otoolbox-0.7.4 → otoolbox-0.7.6}/.github/workflows/python-package.yml +0 -0
  17. {otoolbox-0.7.4 → otoolbox-0.7.6}/.github/workflows/python-publish.yml +0 -0
  18. {otoolbox-0.7.4 → otoolbox-0.7.6}/.gitignore +0 -0
  19. {otoolbox-0.7.4 → otoolbox-0.7.6}/.logs.txt +0 -0
  20. {otoolbox-0.7.4 → otoolbox-0.7.6}/.pre-commit-config.yaml +0 -0
  21. {otoolbox-0.7.4 → otoolbox-0.7.6}/.pylintrc +0 -0
  22. {otoolbox-0.7.4 → otoolbox-0.7.6}/.pylintrc-mandatory +0 -0
  23. {otoolbox-0.7.4 → otoolbox-0.7.6}/.readthedocs.yml +0 -0
  24. {otoolbox-0.7.4 → otoolbox-0.7.6}/.vscode/otoolbox_debug_runner.py +0 -0
  25. {otoolbox-0.7.4 → otoolbox-0.7.6}/.vscode/settings.json +0 -0
  26. {otoolbox-0.7.4 → otoolbox-0.7.6}/.vscode/tasks.json +0 -0
  27. {otoolbox-0.7.4 → otoolbox-0.7.6}/AUTHORS.rst +0 -0
  28. {otoolbox-0.7.4 → otoolbox-0.7.6}/CHANGELOG.rst +0 -0
  29. {otoolbox-0.7.4 → otoolbox-0.7.6}/CONTRIBUTING.rst +0 -0
  30. {otoolbox-0.7.4 → otoolbox-0.7.6}/LICENSE +0 -0
  31. {otoolbox-0.7.4 → otoolbox-0.7.6}/LICENSE.txt +0 -0
  32. {otoolbox-0.7.4 → otoolbox-0.7.6}/README.rst +0 -0
  33. {otoolbox-0.7.4 → otoolbox-0.7.6}/bin/customer-common +0 -0
  34. {otoolbox-0.7.4 → otoolbox-0.7.6}/bin/customer-config +0 -0
  35. {otoolbox-0.7.4 → otoolbox-0.7.6}/bin/customer-info +0 -0
  36. {otoolbox-0.7.4 → otoolbox-0.7.6}/bin/customer-init +0 -0
  37. {otoolbox-0.7.4 → otoolbox-0.7.6}/bin/customer-shell +0 -0
  38. {otoolbox-0.7.4 → otoolbox-0.7.6}/bin/customer-update +0 -0
  39. {otoolbox-0.7.4 → otoolbox-0.7.6}/bin/customer-update-submodule +0 -0
  40. {otoolbox-0.7.4 → otoolbox-0.7.6}/bin/otoolbox-commit +0 -0
  41. {otoolbox-0.7.4 → otoolbox-0.7.6}/bin/otoolbox-common +0 -0
  42. {otoolbox-0.7.4 → otoolbox-0.7.6}/bin/otoolbox-doctor +0 -0
  43. {otoolbox-0.7.4 → otoolbox-0.7.6}/bin/otoolbox-doctor.bat +0 -0
  44. {otoolbox-0.7.4 → otoolbox-0.7.6}/bin/otoolbox-init-tests +0 -0
  45. {otoolbox-0.7.4 → otoolbox-0.7.6}/bin/otoolbox-pre-commit +0 -0
  46. {otoolbox-0.7.4 → otoolbox-0.7.6}/bin/otoolbox-pull +0 -0
  47. {otoolbox-0.7.4 → otoolbox-0.7.6}/bin/otoolbox-push +0 -0
  48. {otoolbox-0.7.4 → otoolbox-0.7.6}/bin/otoolbox-push-shielded +0 -0
  49. {otoolbox-0.7.4 → otoolbox-0.7.6}/bin/otoolbox-repo-add-all +0 -0
  50. {otoolbox-0.7.4 → otoolbox-0.7.6}/bin/otoolbox-repo-init +0 -0
  51. {otoolbox-0.7.4 → otoolbox-0.7.6}/bin/otoolbox-sync-shielded +0 -0
  52. {otoolbox-0.7.4 → otoolbox-0.7.6}/bin/otoolbox-tests-by-repo +0 -0
  53. {otoolbox-0.7.4 → otoolbox-0.7.6}/docs/Makefile +0 -0
  54. {otoolbox-0.7.4 → otoolbox-0.7.6}/docs/_static/.gitignore +0 -0
  55. {otoolbox-0.7.4 → otoolbox-0.7.6}/docs/authors.rst +0 -0
  56. {otoolbox-0.7.4 → otoolbox-0.7.6}/docs/changelog.rst +0 -0
  57. {otoolbox-0.7.4 → otoolbox-0.7.6}/docs/conf.py +0 -0
  58. {otoolbox-0.7.4 → otoolbox-0.7.6}/docs/contributing.rst +0 -0
  59. {otoolbox-0.7.4 → otoolbox-0.7.6}/docs/help-repo.txt +0 -0
  60. {otoolbox-0.7.4 → otoolbox-0.7.6}/docs/index.rst +0 -0
  61. {otoolbox-0.7.4 → otoolbox-0.7.6}/docs/license.rst +0 -0
  62. {otoolbox-0.7.4 → otoolbox-0.7.6}/docs/readme.rst +0 -0
  63. {otoolbox-0.7.4 → otoolbox-0.7.6}/docs/requirements.txt +0 -0
  64. {otoolbox-0.7.4 → otoolbox-0.7.6}/pyproject.toml +0 -0
  65. {otoolbox-0.7.4 → otoolbox-0.7.6}/setup.cfg +0 -0
  66. {otoolbox-0.7.4 → otoolbox-0.7.6}/setup.py +0 -0
  67. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/__init__.py +0 -0
  68. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/__init__.py +0 -0
  69. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/addons/README.rst +0 -0
  70. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/addons/__init__.py +0 -0
  71. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/addons/config.py +0 -0
  72. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/addons/constants.py +0 -0
  73. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/copilot/README.rst +0 -0
  74. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/copilot/__init__.py +0 -0
  75. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/copilot/copilot_utils.py +0 -0
  76. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/copilot/data/agents/Odoo_17_Backend.agent.md +0 -0
  77. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/copilot/data/agents/Odoo_18_Backend.agent.md +0 -0
  78. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/copilot/data/agents/Odoo_19_Backend.agent.md +0 -0
  79. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/copilot/data/copilot-instructions.md +0 -0
  80. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/docker/README.rst +0 -0
  81. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/docker/docker-compose.yml +0 -0
  82. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/help/README.rst +0 -0
  83. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/help/__init__.py +0 -0
  84. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/help/data/README.rst +0 -0
  85. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/help/data/docs/00-file-and-folders.md +0 -0
  86. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/help/data/docs/01-global-style.md +0 -0
  87. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/help/data/docs/02-odoo-patterns.md +0 -0
  88. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/help/data/docs/03-testing-and-validation.md +0 -0
  89. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/help/data/docs/04-security-and-secrets.md +0 -0
  90. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/help/data/docs/05-oca-contributing-reference.md +0 -0
  91. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/help/data/docs/06-odoo-test-framework-guid.md +0 -0
  92. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/help/data/docs/07-odoonix-guidline.md +0 -0
  93. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/help/data/docs/08-copilot-instructions-guideline.md +0 -0
  94. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/help/data/docs/09-team-playbook.md +0 -0
  95. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/help/help_utils.py +0 -0
  96. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/logger/README.rst +0 -0
  97. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/logger/__init__.py +0 -0
  98. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/repositories/README.rst +0 -0
  99. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/repositories/__init__.py +0 -0
  100. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/repositories/constants.py +0 -0
  101. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/repositories/data/repositories.csv +0 -0
  102. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/repositories/data/repositories.json +0 -0
  103. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/repositories/display.py +0 -0
  104. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/repositories/util.py +0 -0
  105. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/ubuntu/README.rst +0 -0
  106. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/ubuntu/__init__.py +0 -0
  107. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/ubuntu/bin/bulk-add-repos +0 -0
  108. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/ubuntu/bin/bulk-commit +0 -0
  109. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/ubuntu/bin/bulk-common +0 -0
  110. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/ubuntu/bin/bulk-init-tests +0 -0
  111. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/ubuntu/bin/bulk-pre-commit +0 -0
  112. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/ubuntu/bin/bulk-pull +0 -0
  113. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/ubuntu/bin/bulk-push +0 -0
  114. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/ubuntu/bin/bulk-push-shielded +0 -0
  115. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/ubuntu/bin/bulk-repo-add-all +0 -0
  116. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/ubuntu/bin/bulk-repo-init +0 -0
  117. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/ubuntu/bin/bulk-sync-shielded +0 -0
  118. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/ubuntu/bin/bulk-tests-by-repo +0 -0
  119. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/ubuntu/bin/customer-common +0 -0
  120. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/ubuntu/bin/customer-config +0 -0
  121. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/ubuntu/bin/customer-info +0 -0
  122. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/ubuntu/bin/customer-init +0 -0
  123. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/ubuntu/bin/customer-shell +0 -0
  124. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/ubuntu/bin/customer-update +0 -0
  125. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/ubuntu/bin/customer-update-submodule +0 -0
  126. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/ubuntu/bin/ubuntu-install-apps +0 -0
  127. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/ubuntu/bin/ubuntu-office-conf +0 -0
  128. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/unitest/__init__.py +0 -0
  129. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/unitest/data/ODOO_TEST_FRAMEWORK_GUIDE.md +0 -0
  130. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/unitest/data/conftest.py +0 -0
  131. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/unitest/data/pytest.ini +0 -0
  132. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/unitest/unitest_utils.py +0 -0
  133. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/vscode/README.rst +0 -0
  134. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/vscode/__init__.py +0 -0
  135. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/vscode/data/odools.toml +0 -0
  136. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/vscode/data/requirements.txt +0 -0
  137. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/vscode/data/workspace.json +0 -0
  138. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/vscode/extensions.py +0 -0
  139. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/vscode/odoo_conf.py +0 -0
  140. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/vscode/odools_conf.py +0 -0
  141. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/addons/workspace/README.rst +0 -0
  142. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/banner.txt +0 -0
  143. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/base.py +0 -0
  144. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox/constants.py +0 -0
  145. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox.egg-info/dependency_links.txt +0 -0
  146. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox.egg-info/entry_points.txt +0 -0
  147. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox.egg-info/not-zip-safe +0 -0
  148. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox.egg-info/requires.txt +0 -0
  149. {otoolbox-0.7.4 → otoolbox-0.7.6}/src/otoolbox.egg-info/top_level.txt +0 -0
  150. {otoolbox-0.7.4 → otoolbox-0.7.6}/tests/test_addons.py +0 -0
  151. {otoolbox-0.7.4 → otoolbox-0.7.6}/tests/test_conftest.py +0 -0
  152. {otoolbox-0.7.4 → otoolbox-0.7.6}/tests/test_copilot_utils.py +0 -0
  153. {otoolbox-0.7.4 → otoolbox-0.7.6}/tests/test_doctor_script_packaging.py +0 -0
  154. {otoolbox-0.7.4 → otoolbox-0.7.6}/tests/test_repositories_config.py +0 -0
  155. {otoolbox-0.7.4 → otoolbox-0.7.6}/tests/test_utils.py +0 -0
  156. {otoolbox-0.7.4 → otoolbox-0.7.6}/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.6
4
4
  Summary: Utilities for Odoo from Odoonix
5
5
  Home-page: https://odoonix.com/apps/otoolbox
6
6
  Author: Odoonix
@@ -104,11 +104,9 @@ 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 repository_entry.is_dir() and git._is_git_repository(
108
+ repository_entry.path
109
+ ):
112
110
  repo_list.append(
113
111
  {
114
112
  "repository": repository_entry.name,
@@ -74,16 +74,15 @@ def _get_branch_name(context: Resource):
74
74
 
75
75
 
76
76
  def _get_repo_path(context: Resource):
77
- git_repository_policy = env.get_env_variable("GIT_REPOSITORIES_POLICY")
78
77
  repo_path = ""
79
- if git_repository_policy == "standalone":
80
- repo_path = env.get_workspace_path(context.path)
81
- else:
78
+ if _use_multi_worktree():
82
79
  git_repositories_root = env.get_env_variable("GIT_REPOSITORIES_ROOT")
83
80
  assert (
84
81
  git_repositories_root
85
82
  ), "Root path of repositories is required set GIT_REPOSITORIES_ROOT"
86
83
  repo_path = env.get_workspace_path(git_repositories_root, context.path)
84
+ else:
85
+ repo_path = env.get_workspace_path(context.path)
87
86
  return repo_path
88
87
 
89
88
 
@@ -153,6 +152,20 @@ def _is_git_repository_main(repository_path):
153
152
  return False
154
153
 
155
154
 
155
+ def _is_git_worktree(repository_path):
156
+ """Return True only for linked worktrees where .git is a file."""
157
+ if not os.path.isdir(repository_path):
158
+ return False
159
+ return os.path.isfile(os.path.join(repository_path, ".git"))
160
+
161
+
162
+ def _use_multi_worktree():
163
+ """Check if should use a single repository with multi worktree"""
164
+ git_repository_policy = env.get_env_variable("GIT_REPOSITORIES_POLICY")
165
+ assert git_repository_policy, "Policy is required"
166
+ return git_repository_policy != "standalone"
167
+
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,9 +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
-
244
257
  if _is_git_repository(context_path):
245
258
  return PROCESS_SUCCESS, _get_branch_name(context=context)
246
259
  branch_name = (
@@ -346,7 +359,29 @@ def git_checkout(context: Resource):
346
359
 
347
360
  def git_add_safe_directory(context: Resource):
348
361
  """Add repository path to global git safe.directory list."""
349
- repository_path = env.get_workspace_path(context.path)
362
+ repository_path = _get_repo_path(context=context)
363
+
364
+ # Check existing safe.directory values to avoid duplicate entries.
365
+ check_result = utils.call_process_safe(
366
+ [
367
+ GIT_COMMAND,
368
+ "config",
369
+ "--global",
370
+ "--get-all",
371
+ "safe.directory",
372
+ ],
373
+ cwd=env.get_workspace(),
374
+ )
375
+ if check_result.returncode not in (0, 1):
376
+ raise RuntimeError(check_result.stderr)
377
+
378
+ existing_paths = {
379
+ line.strip() for line in check_result.stdout.splitlines() if line.strip()
380
+ }
381
+ if repository_path in existing_paths:
382
+ return PROCESS_SUCCESS, f"safe.directory already exists: {repository_path}"
383
+
384
+ # Add to the confiuration
350
385
  result = utils.call_process_safe(
351
386
  [
352
387
  GIT_COMMAND,
@@ -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,43 @@ 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=[utils.constructor_copy_resource("addons/workspace/data/env")],
54
+ update=[utils.constructor_copy_resource("addons/workspace/data/env")],
55
+ destroy=[utils.delete_file],
56
+ verify=[
57
+ utils.is_file,
58
+ utils.is_readable,
59
+ utils.is_writable,
60
+ ],
61
+ tags=[RESOURCE_TAGS_ENV, RESOURCE_TAGS_AUTO_UPDATE, RESOURCE_TAGS_AUTO_VERIFY],
62
+ )
47
63
  env.add_resource(
48
64
  priority=RESOURCE_PRIORITY_ROOT,
49
65
  path=RESOURCE_ENV_FILE,
50
66
  parent=RESOURCE_ROOT,
51
67
  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],
68
+ description="The env variables file is a readonly file. Fill the file to "
69
+ "controll the workspace behavior",
70
+ init=[
71
+ utils.touch_file,
72
+ # .env is readonly file
73
+ ],
74
+ update=[
75
+ # .env is readonly file
76
+ ],
55
77
  destroy=[utils.delete_file],
56
- verify=[utils.is_file, utils.is_readable, utils.is_writable],
78
+ verify=[
79
+ utils.is_file,
80
+ utils.is_readable,
81
+ utils.is_writable,
82
+ # Checking Variables
83
+ ],
57
84
  tags=[RESOURCE_TAGS_ENV, RESOURCE_TAGS_AUTO_UPDATE, RESOURCE_TAGS_AUTO_VERIFY],
58
85
  )
59
86
  env.add_resource(
@@ -0,0 +1,47 @@
1
+ # Git
2
+ #-----------------------------------------------------------------------------
3
+ SSH_AUTH="yes"
4
+ GIT_REPOSITORIES_POLICY="multi-worktrees"
5
+ GIT_REPOSITORIES_ROOT="/home/maso/Repositories"
6
+
7
+ # Which repository is target
8
+ TARGET_REPOSITORIES="odoonix"
9
+
10
+ # Git Organization
11
+ ORGANIZATIONS=("odoonix" "oca" "odoo")
12
+
13
+ # Recommanded Repositories
14
+ REPOSITORIES=()
15
+
16
+
17
+
18
+
19
+ # Protected Git
20
+ #-----------------------------------------------------------------------------
21
+ WORKER_USER="worker"
22
+
23
+ # Git organizations
24
+ PROTECTED_ORGANIZATIONS=("moonsun")
25
+
26
+ # Recommanded Repositories
27
+ PROTECTED_REPOSITORIES=()
28
+
29
+
30
+
31
+ # Python
32
+ #-----------------------------------------------------------------------------
33
+ VENV_PATH=".venv"
34
+
35
+
36
+
37
+ # Odoo
38
+ #-----------------------------------------------------------------------------
39
+ # Set Odoo Version
40
+ # Odoo has many major branches such as 19.0, 18.0 and 17.0. Each workspace can
41
+ # works on an specific version of odoo. This variable controlle the version.
42
+ ODOO_VERSION="17.0"
43
+
44
+
45
+ # Customers
46
+ #-----------------------------------------------------------------------------
47
+ CUSTOMER_ROOT_DIR="../customers"
@@ -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
 
@@ -5,7 +5,6 @@ import sys
5
5
  from pathlib import Path
6
6
  from urllib.parse import urlparse
7
7
 
8
- from dotenv import dotenv_values
9
8
 
10
9
  from otoolbox.base import Resource
11
10
  from otoolbox import env
@@ -274,42 +273,6 @@ def __is_not_primitive(value):
274
273
  return not isinstance(value, primitive_types)
275
274
 
276
275
 
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
276
  def print_result(result=None):
314
277
  """Print resource executors"""
315
278
  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.6
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