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

[BUG] Get all modified/deleted/added files from a Pull Request #410

Closed
3 tasks done
Xat59 opened this issue Mar 1, 2022 · 4 comments
Closed
3 tasks done

[BUG] Get all modified/deleted/added files from a Pull Request #410

Xat59 opened this issue Mar 1, 2022 · 4 comments
Labels
bug Something isn't working

Comments

@Xat59
Copy link

Xat59 commented Mar 1, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Does this issue exist in the latest version?

  • I'm using the latest release

Describe the bug?

Hello team,

I am trying to list all files that have been modified / removed / added from the current pull request comparing to the target branch of the PR.

Here is what I tried :

---
name: Get all changed files from this PR

on:
  push:
    branches: 'bau/*'
  pull_request:
    branches: 'bau/*'

jobs:
  changed-files:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: changed-files
        id: changed-files
        uses: tj-actions/changed-files@v17.2
        with:
          since_last_remote_commit: 'true'

Instead of returning the full list of files that have been changed in the full PR, it returns only files changed (edited/removed/added) from the second to last commit.
I can also see that the INPUT_BASE_SHA used is the second to last SHA from the PR. That's probably the reason.

To Reproduce

  1. Have an existing repo with main default branch
  2. Create the provided workflow
  3. Create a new branch bau/test from main
  4. Edit several files, commit them, and push to bau/test branch
  5. From the same bau/test branch, edit a new file , commit it and push it in bau/test
  6. The GH workflow runs, and tj-actions/changed-files only returns the latest changed file at step 5, but not files from step 4.

What OS are you seeing the problem on?

ubuntu-latest or ubuntu-20.04

Expected behavior?

Regarding my workflow it should return all files removed/added/edited from the target branch, not only comparing the new commit with the second to last

Relevant log output

No response

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@Xat59 Xat59 added the bug Something isn't working label Mar 1, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Mar 1, 2022

Thanks for reporting this issue, don't forget to star this project to help us reach a wider audience.

@jackton1
Copy link
Member

jackton1 commented Mar 2, 2022

@Xat59 Seems the confusion is how "since_last_remote_commit" works.

main <-  PR (hash1: pushed to remote (github)) 

Compares the HEAD or last commit with main.

main <- PR (hash1: pushed to remote (github)) -> (hash4: local commit before pushing changes: hash2 -> hash3 -> hash4)  

since_last_remote_commit would mean use hash1 which is the last remote commit to perform the diff i.e diff hash1 hash4

To get all changes in the PR you'll need to remove since_last_remote_commit

@jackton1 jackton1 closed this as completed Mar 2, 2022
@Xat59
Copy link
Author

Xat59 commented Mar 2, 2022

Thanks for your feedback but since_last_remote_commit is not clear at all.

Plus, I have exactly the same result when removing since_last_remote_commit from the workflow :

---
name: Get all changed files from this PR

on:
  push:
    branches: 'bau/*'
  pull_request:
    branches: 'bau/*'

jobs:
  changed-files:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: changed-files
        id: changed-files
        uses: tj-actions/changed-files@v17.2

This returns only 1 file while I have 3 modified files in my PR... :

  Resolving repository path...
  Retrieving changes between 95635589e714fa8c58d7e0206a966ff8fd311216 (bau/chg0001) → 2c0046c6f49aceda59bc9cff304140445da4bb72 (bau/chg0001)
  Getting diff...
  Added files: 
  Copied files: 
  Deleted files: 
  Modified files: .github/workflows/terragrunt.yml
  Renamed files: 
  Type Changed files: 
  Unmerged files: 
  Unknown files: 
  All changed and modified files: .github/workflows/terragrunt.yml
  All changed files: .github/workflows/terragrunt.yml
  All modified files: .github/workflows/terragrunt.yml

Note 95635589e714fa8c58d7e0206a966ff8fd311216 is the second to last SHA in the PR, and 2c0046c6f49aceda59bc9cff304140445da4bb72 is the last SHA in the PR.

So yeah of course between these 2 commits there are only 1 file, but that is not at all what I need.

I need to retrieve all files from the PR.

@breno-bicycle
Copy link

So @jackton1 , is it not possible to get all files changed in the PR? (or, diff from last commit and the target branch)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants