Skip to content

Hooks don't have access to the original template directory #706

@rivol

Description

@rivol

I'm trying to include a configuration summary with the generated projects. The summary would be a JSON file, dumped by post_gen_project hook, which would include the cookiecutter context that was used to create the project (same as the files used by --replay functionality).

But I'd also like the config summary to include the revision (commit hash) of the used cookiecutter template. This is useful for enabling easy upgrading of the used template, i.e. incorporating the template changes into a project that had been generated from an older version of the template.

Problem is that ATM hooks don't seem to have any way of accessing the template source dir (correct me if I'm wrong). I'd propose to modify generate_files() to add some special keys to the context, including (but perhaps not limited to) the original template directory. The new values could either go into a new toplevel dict in the context (next to the cookiecutter dict), or maybe into the existing cookiecutter object, prefixed with underscores.

Let me know if this is something that would fit into cookiecutter. If yes and we agree on the implementation, I should be able to create a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions