55# -----------------------------------------------------------------------------
66"""
77Helper functions for cloning git sources in command line builds
8+
9+ Reads CONFLICT_IGNORES environment variable to get a list of comma-separated
10+ files/directories to ignore merge conflicts in. These should be relative to the
11+ top-level of the repo. If not set, then a default list is defined below.
812"""
913
14+ import os
1015import re
1116import subprocess
1217from datetime import datetime
@@ -231,17 +236,24 @@ def handle_merge_conflicts(source: str, ref: str, loc: Path, dependency: str) ->
231236 If merge conflicts are in `rose-stem/` or `dependencies.yaml` then accept the
232237 current changes and mark as resolved.
233238 If others remain then raise an error
239+ If CONFLICT_IGNORES environment variable is set, use that as a comma-separated list
240+ of files/directories to ignore. If not set, use a default list below.
234241 """
235242
236243 # For suites, merge conflicts in these files/directories are unimportant so accept
237244 # the current changes
238- for filepath in ("dependencies.yaml" , "rose-stem" ):
245+ ignores = os .environ .get (
246+ "CONFLICT_IGNORES" , "dependencies.yaml,rose-stem,CONTRIBUTORS.md"
247+ ).split ("," )
248+ need_commit = False
249+ for filepath in ignores :
239250 full_path = loc / filepath
240251 if not full_path .exists ():
241252 continue
242253 logger .warning (f"Ignoring merge conflicts in { filepath } " )
243254 run_command (f"git -C { loc } checkout --ours -- { filepath } " )
244- run_command (f"git -C { loc } add { filepath } " )
255+ run_command (f"git -C { loc } add -f { filepath } " )
256+ need_commit = True
245257
246258 # Check if there are any remaining merge conflicts
247259 unmerged = get_unmerged (loc )
@@ -254,6 +266,10 @@ def handle_merge_conflicts(source: str, ref: str, loc: Path, dependency: str) ->
254266 "\n \n These will need changing in the source branches to be useable together"
255267 )
256268
269+ # Need to commit the ignored conflict fixes
270+ if need_commit :
271+ run_command (f"git -C { loc } commit -m 'fix conflict'" )
272+
257273
258274def get_unmerged (loc : Path ) -> list [str ]:
259275 """
0 commit comments