-
Notifications
You must be signed in to change notification settings - Fork 316
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
Propagate install and uninstall hook exit codes #7782
Conversation
@@ -61,7 +61,7 @@ impl Default for ExitCode { | |||
pub trait Hook: fmt::Debug + Sized + Send { | |||
type ExitValue: fmt::Debug + Send; | |||
|
|||
fn file_name() -> &'static str; | |||
const FILE_NAME: &'static str; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 👍
@@ -315,6 +320,61 @@ pub trait Hook: fmt::Debug + Sized + Send { | |||
fn stderr_log_path(&self) -> &Path; | |||
} | |||
|
|||
#[async_trait::async_trait] | |||
pub trait HookExt: Hook<ExitValue = ExitStatus> + Sync { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The naming and typing of this trait doesn't clearly capture that it's for install and uninstall hooks only. It'd be nice to make that more obvious (though I admittedly am not sure what a better name for the trait and function would be).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. I struggled around the naming of this. There is no reason this has to apply only to the install
and uninstall
hooks so I left the naming very general.
The method and frequency of when the install
and uninstall
hooks are run may provide an axis of differentiation. What if I called the trait one of the following: OneOffHookExt
, AuxiliaryHookExt
, PackageMaintenceHookExt
...?
Ultimately, I think the Hook
trait could use some cleanup. There is a lot of duplicated functionality when calling the hooks that should be moved into the trait itself and the handle_exit
functionality seems unnecessarily general. There is really only a few different kinds of exit types and this would probably be better handled with different run functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that the Hook
trait needs a lot of love
The idea of using method/frequency of hook execution as an axis of differentiation is a great one. Of the suggestions given, I lean toward PackageMaintenanceHookExt
as it's more descriptive and seems to capture something core to the whole idea of having install
and uninstall
hooks. Making that name change, along with a nice documentation comment, would be a nice addition 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Addressed in c02aca
c02acae
to
62adbd3
Compare
Signed-off-by: David McNeil <mcneil.david2@gmail.com>
Signed-off-by: David McNeil <mcneil.david2@gmail.com>
Signed-off-by: David McNeil <mcneil.david2@gmail.com>
Signed-off-by: David McNeil <mcneil.david2@gmail.com>
Signed-off-by: David McNeil <mcneil.david2@gmail.com>
Signed-off-by: David McNeil <mcneil.david2@gmail.com>
Signed-off-by: David McNeil <mcneil.david2@gmail.com>
Signed-off-by: David McNeil <mcneil.david2@gmail.com>
62adbd3
to
d661b9a
Compare
Resolves #6964
This PR adds the logic to propagate the exit code of the
install
anduninstall
hook to thehab
command.