55from unittest import mock
66
77import pytest
8+ from git .config import GitConfigParser
89
910from odoo_tools .exceptions import Exit , PathNotFound
1011from odoo_tools .utils import pending_merge as pm_utils
@@ -110,6 +111,14 @@ def test_add_pending_pr_from_scratch():
110111 repo_name = "edi-framework"
111112 mock_pending_merge_repo_paths (repo_name , pending = False )
112113 repo = Repo (repo_name , path_check = False )
114+ # Setup .gitmodules pointing to the upstream (OCA)
115+ with Path (".gitmodules" ).open ("w" ) as f :
116+ f .write (
117+ f'[submodule "{ repo .path } "]\n '
118+ f"\t path = { repo .path } \n "
119+ f"\t url = git@github.com:OCA/{ repo_name } .git\n "
120+ f"\t branch = 16.0\n "
121+ )
113122 repo .generate_pending_merges_file_template ("OCA" )
114123 repo .add_pending_pull_request ("OCA" , 778 )
115124 expected = {
@@ -121,6 +130,10 @@ def test_add_pending_pr_from_scratch():
121130 "target" : "camptocamp merge-branch-1234-master" ,
122131 }
123132 compare_dict (repo .merges_config (), expected )
133+ # .gitmodules should now point to the company fork
134+ config = GitConfigParser (".gitmodules" , read_only = True )
135+ url = config .get (f'submodule "{ repo .path } "' , "url" )
136+ assert url == f"git@github.com:camptocamp/{ repo_name } .git"
124137
125138
126139# TODO: test all cases
@@ -152,6 +165,14 @@ def test_add_pending_pr():
152165@pytest .mark .project_setup (proj_tmpl_ver = 1 )
153166def test_add_pending_odoo_pr_v1 ():
154167 repo = Repo ("odoo" , path_check = False )
168+ # Setup .gitmodules pointing to the upstream (odoo)
169+ with Path (".gitmodules" ).open ("w" ) as f :
170+ f .write (
171+ f'[submodule "{ repo .path } "]\n '
172+ f"\t path = { repo .path } \n "
173+ f"\t url = git@github.com:odoo/odoo.git\n "
174+ f"\t branch = 14.0\n "
175+ )
155176 # 1: start with no pending merges, generate the pending merges file
156177 assert not repo .has_pending_merges ()
157178 with mock .patch ("odoo_tools.utils.ui.ask_confirmation" , return_value = True ):
@@ -170,6 +191,10 @@ def test_add_pending_odoo_pr_v1():
170191 "target" : "camptocamp merge-branch-1234-master" ,
171192 },
172193 )
194+ # .gitmodules should now point to the company fork
195+ config = GitConfigParser (".gitmodules" , read_only = True )
196+ url = config .get (f'submodule "{ repo .path } "' , "url" )
197+ assert url == "git@github.com:camptocamp/odoo.git"
173198 # 2: add a pending merge
174199 with mock .patch ("odoo_tools.utils.ui.ask_confirmation" , return_value = True ):
175200 repo .add_pending_pull_request ("odoo" , 778 )
0 commit comments