Repository navigation
Unexpected v7 error fatal: ambiguous argument on diff --stat #3311
Copy link
Copy link
Open
Description
Hi,
We've updated to V7 and now getting an (unexpected) error. Checked the "what's new" and changes and it didn't mention anything that could impact, but it did.
Error
Create or update the pull request branch
/usr/bin/git symbolic-ref HEAD --short
staging
Working base is branch 'staging'
/usr/bin/git checkout --progress -B 0fe2ab1b-5922-4136-bf19-07b126f04ed7 HEAD --
Switched to a new branch '0fe2ab1b-5922-4136-bf19-07b126f04ed7'
/usr/bin/git status --porcelain -unormal --
/usr/bin/git diff --quiet --
/usr/bin/git diff --quiet --staged --
/usr/bin/git stash push --include-untracked
No local changes to save
Resetting working base branch 'staging'
/usr/bin/git checkout --progress staging --
Switched to branch 'staging'
Your branch and 'origin/staging' have diverged,
and have 8390 and 1 different commits each, respectively.
(use "git pull" if you want to integrate the remote branch with yours)
/usr/bin/git reset --hard origin/staging
HEAD is now at 9ddb1d2a Merge pull request #[49](https://github.com/xxx/repository/actions/runs/xxx/job/xxx?pr=4929#step:4:55)26 from xxx/develop
/usr/bin/git rev-list --right-only --count staging...0fe2ab1b-5922-4136-bf19-07b126f04ed7
8391
/usr/bin/git -c protocol.version=2 fetch --no-tags --progress --no-recurse-submodules --force --depth=8401 origin develop:refs/remotes/origin/develop
remote: Total 0 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
Pull request branch 'develop' already exists as remote branch 'origin/develop'
/usr/bin/git checkout --progress develop --
Switched to branch 'develop'
/usr/bin/git rev-list --right-only --count staging...develop
8391
/usr/bin/git diff --quiet develop..0fe2ab1b-[59](https://github.com/xxx/repository/actions/runs/xxx/job/xxx?pr=4929#step:4:65)22-4136-bf19-07b126f04ed7
/usr/bin/git diff --stat develop..develop~8391
fatal: ambiguous argument 'develop..develop~8391': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
Error: The process '/usr/bin/git' failed with exit code 128
Configuration
---
name: Create Develop to Staging branch Pull Request
on:
push:
branches:
- develop
workflow_call:
jobs:
sync-to-staging:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
with:
ref: staging
- name: Reset promotion branch
run: |
git fetch origin develop:develop
git reset --hard develop
- name: Create Pull Request
uses: peter-evans/[email protected]
with:
title: Sync (Develop) to Staging
body: Synchronize all changes from `develop` to `staging`
branch: develop
token: ${{ secrets.OUR_CUSTOM_TOKEN }}In short, we have bunch or repositories which have a DTAP setup (develop->staging->main) where we use branch promotion to push changes to main. So simplify this process we use this action to automatically create a Sync to staging PR with changes from the develop branch.
Works like a charm with 6.1.0, breaks in 7.0
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
fatbasstard commentedon Sep 4, 2024
Reverted, output from 6.1.0:
davidjb commentedon Sep 5, 2024
Can confirm this happened to me as well when migrating between the same versions -
6.1.0to7.0.0. The only difference between my workflow config and @fatbasstard's above is I don't have atokenspecified; they're otherwise identical. Had to roll back to 6.1.0.peter-evans commentedon Sep 5, 2024
Thank you for reporting this. I've released a fix for this in
v7.0.1/v7.https://github.com/peter-evans/create-pull-request/releases/tag/v7.0.1
I'm going to keep this issue open for now because the "fix" is more of a workaround, and I would like to try and reproduce this error so I can solve it in a more satisfactory way.
[-]Unexpected error when upgrading to V7[/-][+]Unexpected v7 error `fatal: ambiguous argument` on `diff --stat`[/+]fatbasstard commentedon Sep 5, 2024
Thanks @peter-evans,
Will try it out ❤️
fatbasstard commentedon Sep 6, 2024
Functionality works as expected again with 7.0.1
Thanks for the quick fix!
vparmeland commentedon Feb 18, 2025
Hi @peter-evans. I also encountered this issue with v6.0.1, v7, and v7.0.6 #3311 (comment).
CI Logs
peter-evans commentedon Feb 18, 2025
@vparmeland Your issue is different. It's caused because you are trying the create the pull request branch with
git checkout -b "$BRANCH_NAME". You don't need to do that, just make the changes locally and let the action create the branch for you.fabioguarrasi commentedon Mar 3, 2025
@peter-evans I'm having the same problem. Is there a way to work around this? The reason is that my action is updating the packages.json version and then opening a PR. Doing this locally would erase the purpose of this automation. Thanks!!
peter-evans commentedon Mar 3, 2025
By locally, I mean make the changes during the workflow on the runner. Don't try and create the branch yourself, or use a remote branch, the action will create and update the branch itself.
This is off-topic now so if you need further help please open a new issue.