Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected v7 error fatal: ambiguous argument on diff --stat #3311

Open
fatbasstard opened this issue Sep 4, 2024 · 5 comments
Open

Unexpected v7 error fatal: ambiguous argument on diff --stat #3311

fatbasstard opened this issue Sep 4, 2024 · 5 comments

Comments

@fatbasstard
Copy link

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/create-pull-request@v7.0.0
      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

@fatbasstard
Copy link
Author

Reverted, output from 6.1.0:

  /usr/bin/git symbolic-ref HEAD --short
  staging
  Working base is branch 'staging'
  /usr/bin/git checkout --progress -B 1e85ea96-86ff-4bb2-8710-7d0e8b720737 HEAD --
  Switched to a new branch '1e85ea96-86ff-4bb2-8710-7d0e8b720737'
  /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 #4926 from xxx/develop
  /usr/bin/git rev-list --right-only --count staging...1e85ea96-86ff-4bb2-8710-7d0e8b720737
  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..1e85ea96-86ff-4bb2-8710-7d0e8b720737
  /usr/bin/git rev-list --right-only --count origin/develop...develop
  0
  /usr/bin/git rev-list --left-only --count origin/develop...develop
  0
  Branch 'develop' is even with its remote and will not be updated
  /usr/bin/git rev-list --right-only --count staging...develop
  8391
  /usr/bin/git rev-parse HEAD
  8dbc75970dd07e073ccb96f3fe709dfa5da76831
  /usr/bin/git branch --delete --force 1e85ea96-86ff-4bb2-8710-7d0e8b720737
  Deleted branch 1e85ea96-86ff-4bb2-8710-7d0e8b720737 (was 8dbc7597).
  /usr/bin/git checkout --progress staging --
  Switched to branch 'staging'
  Your branch is up to date with 'origin/staging'.
Create or update the pull request
  Attempting creation of pull request
  A pull request already exists for xxx:develop
  Fetching existing pull request
  Attempting update of pull request
  Updated pull request #4929 (xxx:develop => staging)
Setting outputs
Restore git configuration

@davidjb
Copy link

davidjb commented Sep 5, 2024

Can confirm this happened to me as well when migrating between the same versions - 6.1.0 to 7.0.0. The only difference between my workflow config and @fatbasstard's above is I don't have a token specified; they're otherwise identical. Had to roll back to 6.1.0.

@peter-evans
Copy link
Owner

peter-evans commented 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.

@peter-evans peter-evans changed the title Unexpected error when upgrading to V7 Unexpected v7 error fatal: ambiguous argument on diff --stat Sep 5, 2024
@fatbasstard
Copy link
Author

Thanks @peter-evans,

Will try it out ❤️

@fatbasstard
Copy link
Author

Functionality works as expected again with 7.0.1

Thanks for the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants