Skip to content

Setting file content may produce incorrect record in file history log #495

Open
@van-de-bugger

Description

@van-de-bugger

Plugins which add files to distribution are expected to consume FileInjector role, which defines add_file method. This method adds a file to distribution and adds a record to file history log (added_by attribute of file object). History record has correct plugun name, package and line number, because add_file method has both references to plugin and to file.

Plugins which modify files in distribution call content method on file object. content method updates file content and adds a records to file history log. However, plugin is not known at this moment, and content method calls _caller_plugin_name which tries to guess plugin name by unwinding call stack and looking for a package starting from Dist::Zilla::Plugin:: and returns the rest of the package name. It works only in trivial cases.

Plugins which modify files in distribution are expected to consume FileMunger role. I think it would be better to add a method set_file or change_file (like add_file in FileInjector). Such a method will have both references (to plugin and to file) and will be able just record correct information without need for guessing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions