Skip to content

Commit f1fcd84

Browse files
Fixes when merging in extraction (#223)
* tweaks to merging * fix * add comment * Update github_scripts/get_git_sources.py Co-authored-by: Erica Neininger <107684099+ericaneininger@users.noreply.github.com> --------- Co-authored-by: Erica Neininger <107684099+ericaneininger@users.noreply.github.com>
1 parent 0e0b225 commit f1fcd84

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

github_scripts/get_git_sources.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@
55
# -----------------------------------------------------------------------------
66
"""
77
Helper 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
1015
import re
1116
import subprocess
1217
from 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\nThese 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

258274
def get_unmerged(loc: Path) -> list[str]:
259275
"""

0 commit comments

Comments
 (0)