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

Why exisiting commits are removed? #1828

Closed
pawellabaj opened this issue Apr 4, 2023 · 5 comments
Closed

Why exisiting commits are removed? #1828

pawellabaj opened this issue Apr 4, 2023 · 5 comments

Comments

@pawellabaj
Copy link

pawellabaj commented Apr 4, 2023

Exisiting commits in branch are removed

I have a branch 'release/v1.2.3' with commits created by maven release:prepare:

  • [ci skip] prepare release v1.2.3
  • [ci skip] prepare for next development iteration

I have workflow with following step:

      - name: Create Pull request
        id: pr
        uses: peter-evans/create-pull-request@v4
        with:
          base: main
          branch: release/v1.2.3
          commit-message: "build: [ci skip] automated PR"

After that, existing commits are removed and not merged into main branch, when the PR is merged

How to keep existing commits in the branch?

If this issue is describing a possible bug please provide (or link to) your GitHub Actions workflow.
My workflow: https://github.com/pawellabaj/auto-record/blob/main/.github/workflows/release-published.yml

@taliesins
Copy link

taliesins commented Apr 4, 2023

I think whats happening is that we are reseting our temporary branch by running /usr/bin/git checkout --progress -B 72b2fac1-b7b7-4060-95a3-1a24a54115e7 HEAD -- when we are checked out on the master branch.

We probably want to delete the second check out that is overwriting the base

   /usr/bin/git symbolic-ref HEAD --short
  release/v0.1.10
  Working base is branch 'release/v0.1.10'
  /usr/bin/git checkout --progress -B 72b2fac1-b7b7-4060-95a3-1a24a54115e7 HEAD --
....
 /usr/bin/git checkout --progress main --
  Switched to branch 'main'
  /usr/bin/git rev-list --reverse release/v0.1.10..72b2fac1-b7b7-4060-95a3-1a24a54115e7 .
  /usr/bin/git checkout --progress -B 72b2fac1-b7b7-4060-95a3-1a24a54115e7 HEAD --

@taliesins
Copy link

Actually I think the problem might be:

[`${workingBase}..${tempBranch}`, '.'],

this line should probably:

[`${base}..${tempBranch}`, '.'],

as the temp branch is created from the workingBase there will never be a difference. What we want is the base branch plus any changes that happened in the temp branch/workingBase

@pawellabaj
Copy link
Author

@taliesins wow! What a quick reaction. Thanks

@peter-evans
Copy link
Owner

Hi @pawellabaj

The problem is that you are using an existing branch for the branch input. That is not how this action is designed to work. This action creates and updates the pull request branch itself. That's why the commits are being removed.

For your use case, you can either follow this example, or simply use the gh command line tool to create the PR.

@pawellabaj
Copy link
Author

Thanks @peter-evans for calrification

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

Successfully merging a pull request may close this issue.

3 participants