Skip to content

Commit

Permalink
Resolve import conflicts in one script
Browse files Browse the repository at this point in the history
  • Loading branch information
benedikt-schesch committed Sep 26, 2023
1 parent f802736 commit 6313cb0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/scripts/merge_tools/gitmerge_ort_imports.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ if "$MERGE_SCRIPTS_DIR"/gitmerge.sh "$clone_dir" "$branch1" "$branch2" "$strateg
exit
fi

(cd "$clone_dir" && "$MERGE_SCRIPTS_DIR"/resolve-import-conflicts-or-abort-merge)
(cd "$clone_dir" && "$MERGE_SCRIPTS_DIR"/resolve-import-conflicts)
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ if "$MERGE_SCRIPTS_DIR"/gitmerge.sh "$clone_dir" "$branch1" "$branch2" "$strateg
exit
fi

(cd "$clone_dir" && "$MERGE_SCRIPTS_DIR"/resolve-import-conflicts-or-abort-merge)
(cd "$clone_dir" && "$MERGE_SCRIPTS_DIR"/resolve-import-conflicts)
19 changes: 15 additions & 4 deletions src/scripts/merge_tools/resolve-import-conflicts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
# parent 2 files, all without conflict markers.
# However, this script can be run instead of a git mergetool, or after a git mergetool.

# Exit status is 1 if merging some file halted exceptionally.
# With an exit status of 0, some conflicts may still exist in the current repository.
# Exit status is 1 if conflicts remain after running this script or if
# there is an error generated in some file.
# Exit status is 0 if there are no conflicts after running this script.

if [ "$#" -eq 0 ] ; then
readarray -t files < <(grep -l -r '^<<<<<<< HEAD' .)
Expand All @@ -24,8 +25,18 @@ status=0

for file in "${files[@]}" ; do
if ! "${SCRIPTDIR}"/resolve-import-conflicts-in-file.py "$file" ; then
status=1
echo "Error in $file"
git merge --abort
exit 1
fi
done

exit $status
# From https://stackoverflow.com/questions/41246415/
if git diff --exit-code -S '<<<<<<< HEAD' -S "=======" -S ">>>>>>> $(git name-rev --name-only MERGE_HEAD)" HEAD ; then
exit 0
fi

echo "Conflict"
git merge --abort
exit 1

18 changes: 0 additions & 18 deletions src/scripts/merge_tools/resolve-import-conflicts-or-abort-merge

This file was deleted.

0 comments on commit 6313cb0

Please sign in to comment.