Skip to content

Conditional messages for before/after copy/update #1757

@farhaan-shamsee

Description

@farhaan-shamsee

Actual Situation

Currently the message_before_update and similar messages gets printed on every copy or update.

There can be the case where I want some specific message to be printed when a condition is met. I think this is not possible currently.

Desired Situation

In my case, I have different versions of template. So when a user is updating from 1.0.0 to 2.0.0, I want a message to be printed, for example to take backup of a file, as it will be a breaking change.

But if the user is already on 2.0.0, and runs update to change some answers, then I do not want the same message to be displayed.

Or in short the update message should be displayed on the first update only of a particular template version.

Proposed solution

As a workaround for my use-case, I was trying to get the _copier_answers._commit value from the answers file and then apply some logic to check if the version of template was changing (as it will only change if I am updating to new template version). But it seems that the _commit value changes even before the update command gets executed. So I do not have any way of getting the previous value of _commit.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions