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

formatters:fix - invalid work dir path on Windows #859

Merged
merged 1 commit into from
Dec 14, 2021

Conversation

matheusalcantarazup
Copy link
Contributor

@matheusalcantarazup matheusalcantarazup commented Dec 8, 2021

Previously when we were running on Windows we was setting a Windows path
as a work dir inside a Docker container. For example, we start the
analysis, and we try to find a path that contains go.mod files, we found
the path C:\user\some\path and we was using this path (with Windows
slashes) as a work dir on Docker, so when the command try to access this
path (cd some\path) we was getting errors.

This commit fix this issue converting any path to Unix path before
replacing the {{WORK_DIR}} of command.

Some tests of formatter was changed to expected that any path used on
{{WORK_DIR}} should be a Unix like path.

This commit also make some improvements on utils/file private
functions, resolving a TODO by refactoring the function to use a better
approach to get the relative directory of a file path. Some functions
was renamed to make more clear what they are doing and new debug logging
was added to inform the path that the searched files was founded.

Signed-off-by: Matheus Alcantara matheus.alcantara@zup.com.br

- What I did

- How to verify it

- Description for the changelog

@matheusalcantarazup matheusalcantarazup force-pushed the fix-get-files-subpath branch 12 times, most recently from eeb64ef to 548659d Compare December 13, 2021 19:45
@matheusalcantarazup matheusalcantarazup changed the title formatters:fix - invalid path to cd into on containers formatters:fix - invalid work dir path on Windows Dec 14, 2021
@matheusalcantarazup matheusalcantarazup force-pushed the fix-get-files-subpath branch 2 times, most recently from b83c336 to 60bd7d4 Compare December 14, 2021 12:04
Previously when we were running on Windows we was setting a Windows path
as a work dir inside a Docker container. For example, we start the
analysis, and we try to find a path that contains go.mod files, we found
the path C:\user\some\path and we was using this path (with Windows
slashes) as a work dir on Docker, so when the command try to access this
path (cd some\path) we was getting errors.

This commit fix this issue converting any path to Unix path before
replacing the {{WORK_DIR}} of command.

Some tests of formatter was changed to expected that any path used on
{{WORK_DIR}} should be a Unix like path.

This commit also make some improvements on `utils/file` private
functions, resolving a TODO by refactoring the function to use a better
approach to get the relative directory of a file path. Some functions
was renamed to make more clear what they are doing and new debug logging
was added to inform the path that the searched files was founded.

Signed-off-by: Matheus Alcantara <matheus.alcantara@zup.com.br>
@matheusalcantarazup matheusalcantarazup merged commit 3c0ae7f into main Dec 14, 2021
@matheusalcantarazup matheusalcantarazup deleted the fix-get-files-subpath branch December 14, 2021 14:06
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 this pull request may close these issues.

3 participants