-
Notifications
You must be signed in to change notification settings - Fork 1
feat(hooks,session): PostReview hook, NEXT_STEP directive, diff fingerprint #529
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| //! CSA directive parsing from hook/step output. | ||
| //! | ||
| //! Directives are HTML-comment-style markers embedded in stdout: | ||
| //! `<!-- CSA:NEXT_STEP step_id=<id> -->` — instruct weave to jump to a step. | ||
|
|
||
| /// A parsed CSA directive from hook or step output. | ||
| #[derive(Debug, Clone, PartialEq, Eq)] | ||
| pub enum CsaDirective { | ||
| /// Jump to the named weave step. | ||
| NextStep { step_id: String }, | ||
| } | ||
|
Comment on lines
+8
to
+11
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| /// Parse all `CSA:NEXT_STEP` directives from text output. | ||
| /// | ||
| /// Returns the **last** `NEXT_STEP` directive found (later directives | ||
| /// override earlier ones, matching the "last writer wins" convention). | ||
| pub fn parse_next_step(output: &str) -> Option<String> { | ||
| let mut last_step_id = None; | ||
|
|
||
| for line in output.lines() { | ||
| let trimmed = line.trim(); | ||
| // Match: <!-- CSA:NEXT_STEP step_id=<value> --> | ||
| if let Some(rest) = trimmed.strip_prefix("<!-- CSA:NEXT_STEP") | ||
| && let Some(rest) = rest.strip_suffix("-->") | ||
| { | ||
| let rest = rest.trim(); | ||
| if let Some(value) = rest.strip_prefix("step_id=") { | ||
| let id = value.trim().trim_matches('"').trim(); | ||
| if !id.is_empty() { | ||
| last_step_id = Some(id.to_string()); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| last_step_id | ||
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod tests { | ||
| use super::*; | ||
|
|
||
| #[test] | ||
| fn parse_next_step_basic() { | ||
| let output = "some output\n<!-- CSA:NEXT_STEP step_id=merge -->\nmore output"; | ||
| assert_eq!(parse_next_step(output), Some("merge".to_string())); | ||
| } | ||
|
|
||
| #[test] | ||
| fn parse_next_step_quoted() { | ||
| let output = "<!-- CSA:NEXT_STEP step_id=\"push_and_review\" -->"; | ||
| assert_eq!(parse_next_step(output), Some("push_and_review".to_string())); | ||
| } | ||
|
|
||
| #[test] | ||
| fn parse_next_step_last_wins() { | ||
| let output = "<!-- CSA:NEXT_STEP step_id=first -->\n<!-- CSA:NEXT_STEP step_id=second -->"; | ||
| assert_eq!(parse_next_step(output), Some("second".to_string())); | ||
| } | ||
|
|
||
| #[test] | ||
| fn parse_next_step_none() { | ||
| assert_eq!(parse_next_step("no directives here"), None); | ||
| } | ||
|
|
||
| #[test] | ||
| fn parse_next_step_empty_id() { | ||
| assert_eq!(parse_next_step("<!-- CSA:NEXT_STEP step_id= -->"), None); | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 construction of
diff_argscan be simplified to avoid repetition and improve conciseness.