peter-evans / create-pull-request

A GitHub action to create a pull request for changes to your repository in the actions workspace
MIT License
2.18k stars 434 forks source link

Branch X no longer differs from base branch Y #921

Closed billsioros closed 3 years ago

billsioros commented 3 years ago

Subject of the issue

I am unable to create a pull request to a different repository. It looks like it might relate to #902 & #792, but I'm not quite sure.

Steps to reproduce

The workflow can be found here, whilst a run of the specific workflow can be found here

I am also providing the workflow logs

/usr/bin/git symbolic-ref HEAD --short
master
Working base is branch 'master'
/usr/bin/git checkout --progress -B dfb2c36e-f874-4752-a64d-d0512a82b5d2 HEAD
Switched to a new branch 'dfb2c36e-f874-4752-a64d-d0512a82b5d2'
/usr/bin/git status --porcelain -unormal
/usr/bin/git diff --quiet
/usr/bin/git diff --quiet --staged
Resetting working base branch 'master'
/usr/bin/git checkout --progress master
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
/usr/bin/git reset --hard origin/master
HEAD is now at 2509cd0 Initial commit
/usr/bin/git -c protocol.version=2 fetch --no-tags --progress --no-recurse-submodules --unshallow origin development:refs/remotes/origin/development
remote: Total 0 (delta 0), reused 0 (delta 0), pack-reused 0        
From https://github.com/billsioros/cookiecutter-pypackage-instance
 * [new branch]      development -> origin/development
Pull request branch 'development' already exists as remote branch 'origin/development'
/usr/bin/git checkout --progress development
Switched to a new branch 'development'
Branch 'development' set up to track remote branch 'development' from 'origin'.
/usr/bin/git diff --quiet development..dfb2c36e-f874-4752-a64d-d0512a82b5d2
/usr/bin/git rev-list --right-only --count master...dfb2c36e-f874-4752-a64d-d0512a82b5d2
0
Resetting 'development'
/usr/bin/git checkout --progress -B development dfb2c36e-f874-4752-a64d-d0512a82b5d2
Reset branch 'development'
Your branch is up to date with 'origin/development'.
/usr/bin/git rev-list --right-only --count origin/development...development
0
/usr/bin/git rev-list --left-only --count origin/development...development
0
Branch 'development' is even with its remote and will not be updated
/usr/bin/git rev-list --right-only --count master...development
0
/usr/bin/git branch --delete --force dfb2c36e-f874-4752-a64d-d0512a82b5d2
Deleted branch dfb2c36e-f874-4752-a64d-d0512a82b5d2 (was 2509cd0).
Branch 'development' no longer differs from base branch 'master'
peter-evans commented 3 years ago

Hi @billsioros

It looks like you are using the action correctly, but there are no changes to raise in the pull request. I think the problem is in the Invoke cookiecutter step before. I don't think you need the cd ../. At the start of each step you are already at the root of the repository. It looks like you are creating the files in the wrong path.

      - name: Invoke cookiecutter
        run: |
-         cd ../
          cookiecutter https://github.com/${GITHUB_REPOSITORY} --overwrite-if-exists --no-input project_name=cookiecutter-pypackage-instance
          cd cookiecutter-pypackage-instance

I might be misunderstanding what you are trying to do, but I'm fairly sure the problem is in the step(s) before you are executing the create-pull-request action.

billsioros commented 3 years ago

Hi @peter-evans,

Thanks for the advice. I was able to create a pull request following your advice but not with the desired outcome 😒. As you can see from this closed pull request, as well as the source code on the master branch, a folder is created containing all the changes. The additional cd ../ was there in order to avoid this exact behavior. My intention is for all changes to be made on the cwd and not a subdir.

Any ideas πŸ˜„ ?

Edit: I was able to manually move the resulting files outside the subdir like so

...
- name: Invoke cookiecutter
  run: |
    cookiecutter https://github.com/${GITHUB_REPOSITORY} --overwrite-if-exists --no-input project_name=cookiecutter-pypackage-instance
    mv -f cookiecutter-pypackage-instance/* .
...

but the resulting pull request does not contain the .github folder

peter-evans commented 3 years ago

If you look at the cookiecutter docs here it says you can use the flag --output-dir to specify the output directory.

Try this:

- name: Invoke cookiecutter
  run: |
    cookiecutter https://github.com/${GITHUB_REPOSITORY} --output-dir="${GITHUB_WORKSPACE}" --overwrite-if-exists --no-input project_name=cookiecutter-pypackage-instance
billsioros commented 3 years ago

If you look at the cookiecutter docs here it says you can use the flag --output-dir to specify the output directory.

Try this:

- name: Invoke cookiecutter
  run: |
    cookiecutter https://github.com/${GITHUB_REPOSITORY} --output-dir="${GITHUB_WORKSPACE}" --overwrite-if-exists --no-input project_name=cookiecutter-pypackage-instance

Thanks very much for your input! I managed to find a workaround by simply moving the hidden files, as well as the normal files, outside the resulting subdir. Mistake on my part 😞 Feel free to close the issue.

peter-evans commented 3 years ago

No problem. Glad you've figured out a solution πŸ‘