can't use git merge-base with checkout #160518
Replies: 9 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.
-
| 🕒 Discussion Activity Reminder 🕒 This Discussion has been labeled as dormant by an automated system for having no activity in the last 60 days. Please consider one the following actions: 1️⃣ Close as Out of Date: If the topic is no longer relevant, close the Discussion as  2️⃣ Provide More Information: Share additional details or context — or let the community know if you've found a solution on your own. 3️⃣ Mark a Reply as Answer: If your question has been answered by a reply, mark the most helpful reply as the solution. Note: This dormant notification will only apply to Discussions with the  Thank you for helping bring this Discussion to a resolution! 💬 | 
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
my ci script use
git merge-baseto find the common commit.but I always get
fatal: Not a valid object name masteralthough I use full clone
Beta Was this translation helpful? Give feedback.
All reactions