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

Source files that have been moved throw "error opening input file '/path/to/file' (No such file or directory)" #168

Closed
rogerluan opened this issue Aug 25, 2021 · 0 comments · Fixed by #169

Comments

@rogerluan
Copy link
Collaborator

Hey 👋

I've noticed that files that have been moved throw "No such file or directory" because this plugin attempts to read the file in its old location.

The errors thrown look like this:

error opening input file '/Users/rogerluan/Documents/Projects/redacted/redacted/SampleFile1.swift' (No such file or directory)
SourceKittenFramework/File.swift:28: Fatal error: 'try!' expression unexpectedly raised an error: Error Domain=NSCocoaErrorDomain Code=260 "The file “SampleFile1.swift” couldn’t be opened because there is no such file." UserInfo={NSFilePath=/Users/rogerluan/Documents/Projects/redacted/redacted/SampleFile1.swift, NSUnderlyingError=0x7f858bc8d420 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}

Not sure if this should be reported in Danger itself, or in this plugin, because I know for a fact that Danger itself report the moved files in a misleading way (IMO). We had to implement this workaround for other Dangerfiles in our project:

files_of_interest = git.added_files + git.modified_files
renamed_files = git.renamed_files
added_or_modified_files = files_of_interest.map do |file|
    renamed_dict = renamed_files.find { |dict| dict[:before] == file }
    if renamed_dict
        renamed_dict[:after]
    else
        file
    end
end

And whenever we want "added or modified files", we need to use added_or_modified_files instead of files_of_interest (in the example above).

How can we improve this behavior? Right now this plugin simply crashes when facing those errors 😬

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant