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

ambiguous argument unknown revision #1203

Closed
havok2063 opened this issue Jul 25, 2022 · 3 comments
Closed

ambiguous argument unknown revision #1203

havok2063 opened this issue Jul 25, 2022 · 3 comments

Comments

@havok2063
Copy link

Subject of the issue

I have a very simple workflow where I want to periodically checkout the repo, check for updated files, and then submit a PR from a new branch into main, with any committed changes for the new files. I'd like it to create a new branch, dm_update_models, to commit the changes into. Currently the action runs, finds changes that need to be committed, but fails to create a new PR. I get the following error: fatal: ambiguous argument 'origin/dm_update_models': unknown revision or path not in the working tree. Does this action expect the branch to already exist or will it create it if needed? Originally, I did not have the base option set to main, but got the following error: The 'base' and 'branch' for a pull request must be different branches. Unable to continue. Am I missing something here?

Steps to reproduce

The current github action workflow

name: Update access models

on:
  schedule:
    - cron: '0 9 * * 1'

jobs:
  createpr:
    runs-on: ubuntu-latest
    steps:

      - name: Checkout code
        uses: actions/checkout@v3

      - name: Set up Python
        uses: actions/setup-python@v3
        with:
          python-version: 3.9

      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install wheel
          pip install -e ".[dev, all]"

      - name: Update Models
        run: datamodel tree update

      - name: Create Pull Request
        id: cpr
        uses: peter-evans/create-pull-request@v4
        with:
          title: Auto update datamodel access
          body: |
            Updating new datamodels with access information.
            Auto-generated by [create-pull-request][1]

            [1]: https://github.com/peter-evans/create-pull-request
          base: main
          branch: dm_update_models
          delete-branch: true
          draft: true
          reviewers: havok2063
          labels: |
            auto-pr
            enhancement

      - name: Check outputs
        if: ${{ steps.cpr.outputs.pull-request-number }}
        run: |
          echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
          echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"

and the full traceback

  /usr/bin/git symbolic-ref HEAD --short
  dm_update_models
  Working base is branch 'dm_update_models'
  /usr/bin/git checkout --progress -B 96f4a1f7-0ebc-4a12-8709-66b438a5cbbe HEAD --
  Switched to a new branch '96f4a1f7-0ebc-4a12-8709-66b438a5cbbe'
  M	datamodel/products/access/spXCSAO.access
  M	datamodel/products/json/spXCSAO.json
  M	datamodel/products/yaml/spXCSAO.yaml
  /usr/bin/git status --porcelain -unormal --
   M datamodel/products/access/spXCSAO.access
   M datamodel/products/json/spXCSAO.json
   M datamodel/products/yaml/spXCSAO.yaml
  Uncommitted changes found. Adding a commit.
  /usr/bin/git add -A
  /usr/bin/git -c author.name=havok2063 -c author.email=havok2063@users.noreply.github.com -c committer.name=GitHub -c committer.email=noreply@github.com commit -m [create-pull-request] automated change
  [96f4a1f7-0ebc-4a12-8709-66b438a5cbbe 2a8818e] [create-pull-request] automated change
   Author: havok2063 <havok2063@users.noreply.github.com>
   3 files changed, 45 insertions(+), 14 deletions(-)
  /usr/bin/git reset --hard
  HEAD is now at 2a8818e [create-pull-request] automated change
  /usr/bin/git clean -f -d
  Resetting working base branch 'dm_update_models'
  /usr/bin/git checkout --progress dm_update_models --
  Switched to branch 'dm_update_models'
  /usr/bin/git reset --hard origin/dm_update_models
  fatal: ambiguous argument 'origin/dm_update_models': 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
@julienherrero
Copy link

Hi @havok2063, I encounter the same issue.

I firstly faced #902 because I wanted to commit before the create-pull-request step. And now by committing with the step input, I'm facing this issue. So yes, are we missing something here @peter-evans ?

@julienherrero
Copy link

julienherrero commented Aug 12, 2022

Well, after reading this advice #1191 (comment), it works for my case !

Maybe you just have to create & push the branch dm_update_models before the create-pull-request step in your case @havok2063

@peter-evans
Copy link
Owner

Hi @havok2063

Does this action expect the branch to already exist or will it create it if needed?
No, the action will create the branch. It's expected that it doesn't exist, and if it does, it will be overwritten.

I think the problem is that whatever is happening in this command datamodel tree update is leaving git checked out on the dm_update_models branch. This is not what the action expects. It expects to be checked out on the target of the PR, which in your case is main.

My advice would be to not create the dm_update_models branch in datamodel tree update. Just make the changes to the local working copy. Then just let the action create the branch and raise the PR.

derpsteb added a commit to edgelesssys/constellation that referenced this issue Apr 3, 2023
This seems to bother the create-pull-request action.
See: peter-evans/create-pull-request#1203
derpsteb added a commit to edgelesssys/constellation that referenced this issue Apr 3, 2023
This seems to bother the create-pull-request action.
See: peter-evans/create-pull-request#1203
derpsteb added a commit to edgelesssys/constellation that referenced this issue Apr 3, 2023
This seems to bother the create-pull-request action.
See: peter-evans/create-pull-request#1203
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