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

Renamed files do not show as modified, added or removed, but do appear in files #108

Open
justyn opened this issue Aug 21, 2020 · 6 comments · May be fixed by #136
Open

Renamed files do not show as modified, added or removed, but do appear in files #108

justyn opened this issue Aug 21, 2020 · 6 comments · May be fixed by #136

Comments

@justyn
Copy link

justyn commented Aug 21, 2020

Describe the bug
files_added and files_removed are not showing in my test setup, only files_modified is working correctly.
And files which should show all, just shows modified and new.

Workflow
Here are the relevant parts of my workflow (other actions not shown include checkout):

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:

    - uses: trilom/[email protected]
      id: file_changes
      with:
        output: ' '
        pushBefore: ${{ github.base_ref }}
        pushAfter: ${{ github.ref }}

    - name: Run a multi-line script
      run: |
        echo modified: ${{ steps.file_changes.outputs.files_modified }}
        echo added: ${{ steps.file_changes.outputs.files_added }}
        echo removed: ${{ steps.file_changes.outputs.files_removed }}
        echo all: ${{ steps.file_changes.outputs.files }}

Expected behavior

I'm removing three files (four, five and six), adding three files (one, two and three), modifying one file (run_checks.sh), each in their own commit, then pushing these commits to a branch with a Pull Request.

I would expect this:

modified: run_checks.sh
added: one two three
removed: four five six
all: run_checks.sh one three two four five six

Actual output:

modified: run_checks.sh
added:
removed:
all: run_checks.sh one three two

Not quite sure what is going on here!

Particularly strange that the added files are not showing in files_added but they are in files.

@justyn justyn changed the title Added and removed files not showing, all files is incomplete Renamed files do not show as modified, added or removed, but do appear in files Aug 22, 2020
@justyn
Copy link
Author

justyn commented Aug 22, 2020

Ah, I see what happened - these blank test files show as being renamed, that is why they don't show up as files_added or files_removed, and only the new "names" show up in files.

This does show a bit of an inconsistency though, because it means:

files = files_added + files_removed + files_modified + files_renamed

but there is no individual option to test for files_renamed.

@Jolg42
Copy link

Jolg42 commented Mar 18, 2021

I'm also interested to track renamed/moved files, reading this issue it seems that feature is not yet covered?

@Issafalcon
Copy link

We've also run into an issue with not picking up renamed files. GitHub doesn't include the "old" file (one that was renamed) in the list of modified files. The old name is only included as an additional field on the renamed files entry, which the action code doesn't do anything with. Seeing that this issue has been around for a while, we are fixing it ourselves. Ticket is on our backlog at the moment, but I will be issuing a PR once we've established it works.

@marc-hb
Copy link

marc-hb commented Jan 3, 2022

We've also run into an issue with not picking up renamed files. [...] Ticket is on our backlog at the moment

Who is "we" and what backlog is this? Is this involving this action or something else?

GitHub doesn't include the "old" file (one that was renamed) in the list of modified files

If it were just that then it wouldn't be too bad. I mean if at least the new name was listed in added files then it would be OK-ish for most users.

BTW: git diff --no-renames

@Issafalcon
Copy link

Apologies, I realise my comment was a bit cryptic. I meant 'we' as in the company I'm working for at the moment, and the backlog being the one we have internally (which is pretty long!)

You're right that the issue isn't something that causes problems for the most part. It is only affecting my current team as we are using terraform in quite a specific way that depends on the file-changes-action to determine which .tf files have changed to then decide which files to run terraform apply on.

Thanks for the tip about --no-renames. It could help our situation.

@808sAndBR
Copy link

I dug into the code a bit and while it is not documented like the rest of them, there is a files_renamed object that has the info I needed in it:

${{ steps.get_file_changes.outputs.files_renamed }}

I dont actually know js or typescript (im a python/R dev) but I think it is getting added here:

files.forEach(f => {
changedFiles[f.status].push(
f.filename || f.added || f.removed || f.renamed || f.modified
)
changedFiles.files.push(
f.filename || f.added || f.removed || f.modified || f.renamed
)

Annnnnyways if you are having issues with this try accessing the renames directly with that path.

@808sAndBR 808sAndBR linked a pull request Jul 2, 2022 that will close this issue
1 task
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.

5 participants