-
Notifications
You must be signed in to change notification settings - Fork 67
Remove Change: footer on split push #1586
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| use crate::JoshResult; | ||
| use regex::Regex; | ||
| use std::cell::RefCell; | ||
| use std::collections::HashMap; | ||
|
|
||
| pub fn transform_with_template( | ||
| re: &Regex, | ||
| template: &str, | ||
| input: &str, | ||
| globals: &HashMap<String, String>, | ||
| ) -> JoshResult<String> { | ||
| let first_error: RefCell<Option<crate::JoshError>> = RefCell::new(None); | ||
|
|
||
| let result = re | ||
| .replace_all(input, |caps: ®ex::Captures| { | ||
| // Build a HashMap with all named captures and globals | ||
| // We need to store the string values to keep them alive for the HashMap references | ||
| let mut string_storage: HashMap<String, String> = HashMap::new(); | ||
|
|
||
| // Collect all named capture values | ||
| for name in re.capture_names().flatten() { | ||
| if let Some(m) = caps.name(name) { | ||
| string_storage.insert(name.to_string(), m.as_str().to_string()); | ||
| } | ||
| } | ||
|
|
||
| // Build the HashMap for strfmt with references to the stored strings | ||
| let mut vars: HashMap<String, &dyn strfmt::DisplayStr> = HashMap::new(); | ||
|
|
||
| // Add all globals first (lower priority) | ||
| for (key, value) in globals { | ||
| vars.insert(key.clone(), value as &dyn strfmt::DisplayStr); | ||
| } | ||
|
|
||
| // Add all named captures (higher priority - will overwrite globals if there's a conflict) | ||
| for (key, value) in &string_storage { | ||
| vars.insert(key.clone(), value as &dyn strfmt::DisplayStr); | ||
| } | ||
|
|
||
| // Format the template, propagating errors | ||
| match strfmt::strfmt(template, &vars) { | ||
| Ok(s) => s, | ||
| Err(e) => { | ||
| let mut error = first_error.borrow_mut(); | ||
| if error.is_none() { | ||
| *error = Some(e.into()); | ||
| } | ||
| caps[0].to_string() | ||
| } | ||
| } | ||
| }) | ||
| .into_owned(); | ||
|
|
||
| match first_error.into_inner() { | ||
| Some(e) => Err(e), | ||
| None => Ok(result), | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -577,11 +577,23 @@ pub fn unapply_filter( | |
| } | ||
| }; | ||
|
|
||
| let mut apply = filter::Apply::from_tree(new_tree.clone()); | ||
|
|
||
| if change_ids.is_some() { | ||
| let new_message = filter::text::transform_with_template( | ||
| ®ex::Regex::new(&"(?m)^Change: [^ ]+")?, | ||
| &"", | ||
| module_commit.message_raw().unwrap(), | ||
| &std::collections::HashMap::new(), | ||
| )?; | ||
|
Comment on lines
+583
to
+588
|
||
| apply = apply.with_message(new_message); | ||
| } | ||
|
|
||
| ret = rewrite_commit( | ||
| transaction.repo(), | ||
| &module_commit, | ||
| &original_parents, | ||
| filter::Apply::from_tree(new_tree.clone()), | ||
| apply, | ||
| false, | ||
| )?; | ||
|
|
||
|
|
||
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 function contains complex template formatting logic (lines 18-50) that is not used in the current implementation. The only caller passes an empty string as the template, making the strfmt logic, string_storage, vars HashMap, and error handling for template formatting dead code. Consider simplifying to a basic regex replace function or documenting the intended future use of template parameters.