Skip to main content

gitignore_with_log_rule

Function gitignore_with_log_rule 

Source
pub fn gitignore_with_log_rule(existing: Option<&str>) -> Option<String>
Expand description

Given a .ct/.gitignore’s current contents (or None when it is absent), return the contents to write so it carries LOG_IGNORE_RULE, or None when the rule is already present (no write needed). Existing lines are preserved; the rule is appended.

§Examples

use coding_tools::steer::gitignore_with_log_rule;
assert_eq!(gitignore_with_log_rule(None).as_deref(), Some("*log\n"));
assert_eq!(gitignore_with_log_rule(Some("*log\n")), None); // already there
assert_eq!(gitignore_with_log_rule(Some("target\n")).as_deref(), Some("target\n*log\n"));