vuejs-translations / ryu-cho

The GitHub Action to track diffs between 2 repositories.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[bug] False positive on merge conflict

tony19 opened this issue · comments

Ryu-Cho failed to merge a commit, indicating that there were conflicts:

New commit on head repo: "docs: fix deploy type var (#9290)"
Issue created: https://github.com/tony19/vite-docs-template/issues/18
Conflicts occurred. Please make a pull request by yourself.

However, I was able to cherry-pick the commit without any conflicts.

This also occurred with tony19/vite-docs-template#19, where the cherry-pick was fine.

It seems this can also occur when the cherry-pick contains files that are not present in the target repo. The Ryu-Cho logs don't show the exact error, but running git am locally to cherry-pick the commit from vite reveals this error:

error: could not build fake ancestor

For this instance, the cherry-pick contains a change for packages/vite/src/node/constants.ts, which does not exist in vite-docs-template.

To resolve this manually from the command line, I have to specify git am --include paths for which files to accept during the merge. I created a couple scripts to do this:

  1. Create gitcp.sh:
#!/bin/bash -ex
REPO_DIR=$1
SHA1=$2
GIT_AM_PARMS=${@:3}

git --git-dir=$REPO_DIR/.git \
format-patch -k -1 --stdout $SHA1 | \
git am -3 -k $GIT_AM_PARMS
  1. Create vitedocs-cp.sh:
#!/bin/bash -ex
SHA1=$1
GIT_AM_PARMS=--include=docs/\*\.md
VITE_REPO_DIR=$HOME/src/vite

pushd $VITE_REPO_DIR
git pull origin main
popd

$HOME/bin/gitcp.sh $VITE_REPO_DIR $SHA1 $GIT_AM_PARMS ${@:2}
  1. Use the script, e.g., to cherry-pick b82ee5d from vite to your translations repo:
cd $HOME/src/my-translations-repo
sh vitedocs-cp.sh b82ee5d