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] Files with names containing space might not be detected #92

Closed
3 tasks done
wkillerud opened this issue Oct 29, 2021 · 3 comments · Fixed by #93
Closed
3 tasks done

[BUG] Files with names containing space might not be detected #92

wkillerud opened this issue Oct 29, 2021 · 3 comments · Fixed by #93
Labels
bug Something isn't working

Comments

@wkillerud
Copy link

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?

My case is a visual diff tool that generates snapshot images in a workflow for new tests. It generates files with names like ComponentName test category test name #number.png.

I tried a regexp to match \.png, but the action didn't pick up the new image.

I've tracked it down to the interplay between git status --porcelain and awk.

To Reproduce

  1. Make a new Git repo
  2. Create a file containing spaces in its name (touch "foo bar.txt")
  3. Run parts of the command from entrypoint.sh (git status --porcelain | awk '{ print $2 }'
  4. Notice how the file name is missing its second part and file extension

What OS are you seeing the problem on?

ubuntu-latest or ubuntu-20.04, macos-latest or macos-10.15

Expected behavior?

The awk command should pass the whole file name including extension to grep.

I suggest this change (via Stack Overflow):

    # shellcheck disable=SC2207
-   CHANGED_FILES+=($(git status --porcelain | awk '{ print $2 }' | grep -E "(${path})" || true))
+   CHANGED_FILES+=($(git status --porcelain | awk '{$1=""; print $0 }' | grep -E "(${path})" || true))

If you follow the steps to reproduce, but replace step 3 with git status --porcelain | awk '{$1=""; print $0 }' you should see the whole file name.

Relevant log output

~/repro
> $ git init
Reinitialized existing Git repository in ~/repro/.git/

~/repro
> $ touch "foo bar.txt"

~/repro
> $ git status --porcelain
?? "foo bar.txt"

~/repro
> $ git status --porcelain | awk '{ print $2 }'
"foo

~/repro
> $ git status --porcelain | awk '{$1=""; print $0 }'
 "foo bar.txt"

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@wkillerud wkillerud added the bug Something isn't working label Oct 29, 2021
@github-actions
Copy link
Contributor

Thanks for reporting this issue.

jackton1 added a commit that referenced this issue Oct 29, 2021
jackton1 added a commit that referenced this issue Oct 29, 2021
@jackton1
Copy link
Member

@all-contributors please add @wkillerud for code

@allcontributors
Copy link
Contributor

@jackton1

I've put up a pull request to add @wkillerud! 🎉

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

Successfully merging a pull request may close this issue.

2 participants