usethis icon indicating copy to clipboard operation
usethis copied to clipboard

`git_vaccinate()` drops blank lines and repeated comments

Open jimhester opened this issue 8 years ago • 2 comments

git_vaccinate() calls write_union() to update the global gitignore file and write_union() keeps only unique lines.

https://github.com/r-lib/usethis/blob/e9a3c8299c132f9fc8a630886e26c36668f427c7/R/write.R#L61

Unfortunately this deletes all empty lines (but the first) and repeated comments, such as those often used around section headings, e.g.

value = 123

########################
# A new section        #
########################

value2 = 456

Becomes

value = 123

########################
# A new section        #
value2 = 456

Since you are already doing a set diff of the new lines and the existing lines, couldn't you just prepend the new lines rather than taking the union to avoid this? e.g. change that line to

all <- c(new, existing_lines)

jimhester avatar Dec 03 '18 20:12 jimhester

Yeah, good call.

hadley avatar Dec 04 '18 00:12 hadley

I'll do this one.

khailper avatar Jan 19 '19 17:01 khailper