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

Hooks #1449

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open

Hooks #1449

wants to merge 17 commits into from

Conversation

aljazerzen
Copy link
Contributor

@aljazerzen aljazerzen commented Jan 22, 2025

  • make hooks a single string, instead of an array,
  • invoke /bin/sh instead of the process directly,
  • set cwd,
  • WSL
  • tests

  • project.init.after
  • branch.switch.after
  • branch.wipe.after
  • migration.apply.after

Do we want before hooks too? I've implemented some because they were easy.

  • project.init.before
  • branch.switch.before
  • branch.wipe.before
  • migration.apply.before

@aljazerzen aljazerzen changed the title hooks Hooks Jan 22, 2025
@aljazerzen aljazerzen marked this pull request as draft January 22, 2025 18:09
@aljazerzen aljazerzen changed the base branch from master to project-manifest January 22, 2025 18:09
@aljazerzen aljazerzen force-pushed the hooks branch 2 times, most recently from d3deae9 to bea254b Compare January 23, 2025 17:15
Base automatically changed from project-manifest to master January 27, 2025 11:47
@aljazerzen aljazerzen marked this pull request as ready for review January 28, 2025 11:12
@aljazerzen
Copy link
Contributor Author

I need an install of windows to implement hooks in WSL.

Copy link
Member

@msullivan msullivan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

Comment on lines +63 to +65
if let Some(project) = &context.get_project().await? {
hooks::on_action("branch.switch.before", project).await?;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be cleaner to have hooks::on_action (or something similar) take a context and then call it unconditionally in each call site, and have the logic there?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a few different contextes: branching, migration, project. Some are subsets of other and contain different amounts of information.

hooks::on_action takes project::Context

pro.arg(pair);
}
// TODO: set current dir
pro.arg("/bin/sh");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure not to lose track of this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this will be implemented when I do WSL for real.

Comment on lines +1 to +15
[instance]
server-version = "nightly"

[project]
schema-dir = "./database_schema"

[hooks]
project.init.before = "true"
project.init.after = "true"
branch.switch.before = "true"
branch.switch.after = "true"
branch.wipe.before = "true"
branch.wipe.after = "true"
migration.apply.before = "true"
migration.apply.after = "true"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably we want some tests where we can test they ran in the right context?

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

Successfully merging this pull request may close these issues.

2 participants