diff --git a/docs/reference.md b/docs/reference.md index bfcc6a1..04f8883 100644 --- a/docs/reference.md +++ b/docs/reference.md @@ -375,10 +375,12 @@ relative to the base of the repo; other paths are relative to that root arbitrary labels to you projects, which is useful when using the `info` command. - `hooks`: (optional) A set of hooks that run at certain points of the - release process. Currently, only the `post_write` hook is supported: - this hook runs after local file changes are made, but before any VCS + release process. Currently, there are only two hooks: + - `post_write` this hook runs after local file changes are made, but before any VCS commits/push/tagging is performed; it's useful to make additional file changes that need to be committed with the release. + - `on_finish` this hooks runs after everything has been pushed to remote repo and right before + the program exits. This could be used to trigger pipelines for specific project. - `commit` diff --git a/src/commands.rs b/src/commands.rs index 498a582..99fd1c9 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -378,6 +378,14 @@ pub async fn release( } output.commit(); + + for (project_id, (size, _)) in plan.incrs() { + if size != &Size::Fail && size > &Size::None { + let proj = mono.get_project(project_id)?; + let hook = proj.hooks(); + hook.execute_on_finish(&proj.root())?; + } + } Ok(()) } diff --git a/src/config.rs b/src/config.rs index df73bc8..3294a18 100644 --- a/src/config.rs +++ b/src/config.rs @@ -717,6 +717,8 @@ impl HookSet { } pub fn execute_post_write(&self, root: &Option<&String>) -> Result<()> { self.execute("post_write", root) } + + pub fn execute_on_finish(&self, root: &Option<&String>) -> Result<()> { self.execute("on_finish", root) } } impl<'de> Deserialize<'de> for HookSet { @@ -1218,7 +1220,9 @@ impl Ord for Size { } fn default_includes() -> Vec { vec!["**/*".into()] } + fn default_prev_tag() -> String { "versio-prev".into() } + fn default_branch() -> Option { None } fn deser_labels<'de, D: Deserializer<'de>>(desr: D) -> std::result::Result, D::Error> { @@ -1314,9 +1318,10 @@ fn match_opts() -> MatchOptions { MatchOptions { require_literal_separator: true #[cfg(test)] mod test { - use super::{ConfigFile, FileLocation, HashMap, Location, Picker, Project, ProjectId, ScanningPicker, Size}; use crate::scan::parts::Part; + use super::{ConfigFile, FileLocation, HashMap, Location, Picker, Project, ProjectId, ScanningPicker, Size}; + #[test] fn test_both_file_and_tags() { let data = r#"