@@ -88,18 +88,16 @@ def datetime_str() -> str:
8888
8989
9090def clone_and_merge (
91- dependency : str , opts : Union [list , dict ], loc : Path , use_mirrors : bool , mirror_loc : Path
91+ opts : Union [list , dict ], loc : Path , use_mirrors : bool , mirror_loc : Path
9292) -> None :
9393 """
9494 Wrapper script for calling get_source and merge_source for a single dependency
9595
96- dependency: name of the dependency
9796 opts: dict or list of dicts for a dependency in the dependencies file
9897 loc: path to location to clone to
9998 use_mirrors: bool, use local git mirrors if true
10099 mirror_loc: path to local git mirrors
101100 """
102-
103101 if not isinstance (opts , list ):
104102 opts = [opts ]
105103
@@ -113,7 +111,6 @@ def clone_and_merge(
113111 values ["source" ],
114112 values ["ref" ],
115113 loc ,
116- dependency ,
117114 use_mirrors ,
118115 mirror_loc ,
119116 )
@@ -123,7 +120,6 @@ def clone_and_merge(
123120 values ["source" ],
124121 values ["ref" ],
125122 loc ,
126- dependency ,
127123 use_mirrors ,
128124 mirror_loc ,
129125 )
@@ -133,7 +129,6 @@ def get_source(
133129 source : str ,
134130 ref : str ,
135131 dest : Path ,
136- repo : str ,
137132 use_mirrors : bool = False ,
138133 mirror_loc : Path = Path ("" ),
139134) -> None :
@@ -144,26 +139,23 @@ def get_source(
144139 if ".git" in source :
145140 if use_mirrors :
146141 logger .info (
147- f"[{ datetime_str ()} ] Cloning { repo } from { mirror_loc } at ref { ref } "
142+ f"[{ datetime_str ()} ] Cloning { dest . name } from { mirror_loc } at ref { ref } "
148143 )
149- mirror_repo = repo
150- if "jules-internal" in source :
151- mirror_repo = "jules-internal"
144+ mirror_repo = re .split ("[:/]" , source )[- 1 ]
152145 mirror_loc = Path (mirror_loc ) / "MetOffice" / mirror_repo
153146 clone_repo_mirror (source , ref , mirror_loc , dest )
154147 else :
155- logger .info (f"[{ datetime_str ()} ] Cloning { repo } from { source } at ref { ref } " )
148+ logger .info (f"[{ datetime_str ()} ] Cloning { dest . name } from { source } at ref { ref } " )
156149 clone_repo (source , ref , dest )
157150 else :
158- logger .info (f"[{ datetime_str ()} ] Syncing { repo } at ref { ref } " )
151+ logger .info (f"[{ datetime_str ()} ] Syncing { dest . name } at ref { ref } " )
159152 sync_repo (source , ref , dest )
160153
161154
162155def merge_source (
163156 source : str ,
164157 ref : str ,
165158 dest : Path ,
166- repo : str ,
167159 use_mirrors : bool = False ,
168160 mirror_loc : Path = Path ("" ),
169161) -> None :
@@ -174,11 +166,12 @@ def merge_source(
174166
175167 logger .info (
176168 f"[{ datetime .now ().strftime ('%Y-%m-%d %H:%M:%S' )} ] Merging "
177- f"{ source } at ref { ref } into { repo } "
169+ f"{ source } at ref { ref } into { dest . name } "
178170 )
179171
180172 if use_mirrors :
181- remote_path = Path (mirror_loc ) / "MetOffice" / repo
173+ mirror_repo = re .split ("[:/]" , source )[- 1 ]
174+ remote_path = Path (mirror_loc ) / "MetOffice" / mirror_repo
182175 else :
183176 remote_path = source
184177 run_command (f"git -C { dest } remote add local { remote_path } " )
@@ -194,7 +187,7 @@ def merge_source(
194187 if result .returncode :
195188 unmerged_files = get_unmerged (dest )
196189 if unmerged_files :
197- handle_merge_conflicts (source , ref , dest , repo )
190+ handle_merge_conflicts (source , ref , dest , dest . name )
198191 else :
199192 raise subprocess .CalledProcessError (
200193 result .returncode , command , result .stdout , result .stderr
0 commit comments