can't use git merge-base with checkout #423
Replies: 8 comments 1 reply
-
@xiqingongzi I got this to work using |
Beta Was this translation helpful? Give feedback.
-
This is still a problem, even with
Note how on the second line above the action uses |
Beta Was this translation helpful? Give feedback.
-
Jan 2024, git merge-base still doesn't work in this action |
Beta Was this translation helpful? Give feedback.
-
Not working in May 2024 |
Beta Was this translation helpful? Give feedback.
-
Found this solution: (use fetch-depth: 0 for full checkout)
Later this works for me. " git merge-base" is sub-command |
Beta Was this translation helpful? Give feedback.
-
It only took me 18 commits to confirm that this is in fact not working in June 2024. @zcao's solution works tho |
Beta Was this translation helpful? Give feedback.
-
+1 I'm experiencing the same issue. Interestingly though, it used to work nicely until last week. Now |
Beta Was this translation helpful? Give feedback.
-
Hi, This is how I got around this problem: - name: Get Affected
id: get-affected
shell: bash
run: |
set -x
GIT_BASE=${GITHUB_BASE_REF:-master}
HEAD_REF=$(echo ${{ github.ref }} | sed -e 's#/merge#/head#')
git fetch origin +${GIT_BASE}:${GIT_BASE}
git fetch origin +${HEAD_REF}:${HEAD_REF}
NX_HEAD=$(git rev-parse ${HEAD_REF})
NX_BASE=$(git merge-base origin/${GIT_BASE} ${HEAD_REF})
AFFECTED_JSON=$(npx nx show projects --affected --base "${NX_BASE}" --head "${NX_HEAD}" --verbose | jq -rc -nR '[inputs | select(length>0)] as $projects | { "projects": $projects, "count": ($projects | length)}')
AFFECTED_COUNT=$(echo $AFFECTED_JSON | jq -rc '.count')
AFFECTED_PROJECTS=$(echo $AFFECTED_JSON | jq -rc '.projects')
echo "affected-json=${AFFECTED_JSON}" >> "$GITHUB_OUTPUT"
echo "affected-projects=${AFFECTED_PROJECTS}" >> "$GITHUB_OUTPUT"
echo "affected-count=${AFFECTED_COUNT}" >> "$GITHUB_OUTPUT" The main thing was to fetch branch/PR reference and master. Then we can correctly use Hopefully that helps someone :) |
Beta Was this translation helpful? Give feedback.
-
my ci script use
git merge-base
to find the common commit.but I always get
fatal: Not a valid object name master
although I use full clone
Beta Was this translation helpful? Give feedback.
All reactions