Skip to content

Option to disable resetting working base branch to its remote #609

Closed
@ttshivers

Description

@ttshivers

I am trying to use this action to add new commits to a PR rather than having it replace the commits. I am running into issues with this action when it tries to reset the working base branch to its remote:

await git.fetch([`${workingBase}:${workingBase}`], baseRemote, ['--force'])

What I am trying:

      - name: Checkout the testauthor/testrepo repo
        uses: actions/checkout@v2
        with:
          path: testrepo
          repository: testauthor/testrepo

      - name: Track our fork
        run: |
          cd testrepo
          git config user.email "${{ github.actor }}@users.noreply.github.com"
          git config user.name "${{ github.actor }}"
          git remote add bot-fork https://github.com/myuser/testrepo
          git fetch bot-fork
          git checkout -b mybranch --track bot-fork/mybranch

      # Step here that makes changes in testrepo dir

      - name: Commit changes
        run: |
          cd testrepo
          git add -A
          git diff-index --quiet HEAD || git commit -m "MyChange: ${{ github.event.pull_request.title }}"

      - name: Create PR in testauthor/testrepo
        id: create-pr
        uses: peter-evans/create-pull-request@v3
        with:
          token: ${{ secrets.PAT }}
          push-to-fork: myuser/testrepo
          path: testrepo
          base: master
          branch: mybranch
          title: "MyChange: ${{ github.event.pull_request.title }}"
          body: |
            Pull Request: ${{ github.event.pull_request.html_url }}
            @myuser

What happens:
The action ends up failing at

await git.fetch([`${workingBase}:${workingBase}`], baseRemote, ['--force'])

because it tries to:

/usr/bin/git -c protocol.version=2 fetch --no-tags --progress --no-recurse-submodules --unshallow --force origin mybranch:mybranch
  fatal: couldn't find remote ref node
  Error: The process '/usr/bin/git' failed with exit code 128

This fails because there is no mybranch branch on the origin. It only exists on my fork. And even then, it's certainly possible to have the working branch not track any remote, and I would like this action to work in that case. It would be nice to be able to stop this action from trying to reset the working base branch to its remote in cases like these.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions