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

Incorrect paths when using nested Danger #1429

Open
Skoti opened this issue Feb 24, 2023 · 7 comments
Open

Incorrect paths when using nested Danger #1429

Skoti opened this issue Feb 24, 2023 · 7 comments

Comments

@Skoti
Copy link

Skoti commented Feb 24, 2023

Report

I'm converting my comment from here: #1177
into an issue, as 1177 was closed and no one seem to care.

Assume

.
├── .git
├── nested
│     ├── nested-again
│       ├── Dangerfile

When executing danger from nested-again directory the paths returned by git.renamed_files, git.modified_files and git.added_files are incorrect. They will all start with /nested/nested-again/someFilename instead of just ./someFilename as this is the current working directory.

This leads to issues in all plugins as most of them is doing File.expand_path on the returned paths and the final path is:
/Users/<username>/<path_to_repo>/nested/nestedAgain/nested/nestedAgain/someFilename leading to:
(No such file or directory) errors.

I don't know where is the root cause but it seems like the change to make danger run in a subdirectory is not completed.
Would you please take a look at this?

Example of an issue in swiftlint plugin:
ashfurrow/danger-ruby-swiftlint#175

I've checked this on Danger 9.2.0.

@orta
Copy link
Member

orta commented Feb 24, 2023

Would you please take a look at this?

Danger Ruby is a very mature, done OSS project, I'm afraid folks aren't going to be fixing bugs or adding features for other people, you're welcome to look at this if it is important to you though

@Cordelro

This comment was marked as spam.

@Cordelro

This comment was marked as spam.

@Cordelro

This comment was marked as spam.

@Cordelro

This comment was marked as spam.

@manicmaniac
Copy link
Member

Honestly I don't think this is a bug.

git.renamed_files, git.modified_files and git.added_files are internally calls git diff.
I think it is natural that they return files related to top-level of the Git work tree instead of the current directory.

@Skoti
Copy link
Author

Skoti commented Apr 26, 2023

That's the point.
The #1177 PR was supposed to make it possible to run Danger from a subdirectory.
As I explained in my first post, it seems like it missed the fact that git diff always returns paths relative to the git directory instead of the current directory, hence the common part of the path is added twice.
Seems like the paths should be relativized before expansion.

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

No branches or pull requests

4 participants