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

Conditional messages for before/after copy/update #1757

Open
farhaan-shamsee opened this issue Aug 30, 2024 · 5 comments
Open

Conditional messages for before/after copy/update #1757

farhaan-shamsee opened this issue Aug 30, 2024 · 5 comments

Comments

@farhaan-shamsee
Copy link

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.

@farhaan-shamsee farhaan-shamsee changed the title Conditional Messages for before/after copy/update Conditional messages for before/after copy/update Aug 30, 2024
@pawamoy
Copy link
Contributor

pawamoy commented Aug 30, 2024

Sounds like migrations. You'd have a migration between v1 and v2 that does the file backup for you and prints a message.

@yajo
Copy link
Member

yajo commented Sep 2, 2024

It could be done with migrations, but in reality those run at the end of the update. However the feature request is to have messages at the beginning AFAICS.

@yajo yajo added this to the Community contribution milestone Sep 2, 2024
@farhaan-shamsee
Copy link
Author

Sounds like migrations. You'd have a migration between v1 and v2 that does the file backup for you and prints a message.

Yes, this can resolve/help in my use case but partially. As mentioned by @yajo , there can be some use cases where we want the messages to be printed before also.

@yajo
Copy link
Member

yajo commented Sep 21, 2024

Can't you just add a message like: "If you are doing a major version update, make sure to check the template change log."?

@farhaan-shamsee
Copy link
Author

Yes, in fact this is what we are doing currently, redirecting them to our release notes. And also looking at the migrations as mentioned above.
I believe this fulfils our requirement.

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

No branches or pull requests

3 participants