Changeset d237199 in gignore
- Timestamp:
- 19 Apr 2026, 12:17:08 (10 days ago)
- Branches:
- multi_arg, trunk
- Children:
- 3cf1172
- Parents:
- 9efe32f
- File:
-
- 1 edited
-
src/main.rs (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/main.rs
r9efe32f rd237199 121 121 122 122 match &args.operation { 123 <<<<<<< Updated upstream124 OperCommand::Add { path } => {125 let Some(path) = path else {126 if !fs::exists(".gitignore").context("cannot search for `.gitignore`")? {127 File::create(".gitignore").context("cannot create file `.gitignore`")?;128 exit(0);129 } else {130 bail!("The file `.gitignore` already exists");131 }132 };133 if fs::read_to_string(".gitignore")134 .context("cannot read .gitignore")?135 .lines()136 .collect::<Vec<&str>>()137 .contains(&&**path)138 {139 return Err(Error::msg(format!(140 "The path `{path} already exists in `.gitignore`!"141 )))142 .context("cannot add path to `.gitignore`");143 }144 145 let mut append_handle = open_append(".gitignore".as_ref())146 .context("cannot open `.gitignore` in append mode")?;147 148 append_handle149 .write_all(format!("{}\n", path.trim()).as_bytes())150 .context("cannot write to `gitignore`")?;151 152 Ok(())153 }154 =======155 >>>>>>> Stashed changes156 123 OperCommand::Remove { path } => { 157 124 let Some(path) = path else {
Note:
See TracChangeset
for help on using the changeset viewer.
