inbo / n2khab

R package with preprocessing functions and standard reference data for Flemish Natura 2000 (N2K) habitat (HAB) analyses
https://inbo.github.io/n2khab
GNU General Public License v3.0
2 stars 1 forks source link

fileman_folders() should update (or create) .gitignore if root = "git" #75

Open hansvancalster opened 4 years ago

hansvancalster commented 4 years ago

Would be useful for this function to write a .gitignore file when root = "git". to the n2khab_data folder.

The contents of the .gitignore should be

*
!.gitignore
florisvdh commented 4 years ago

Fine idea @hansvancalster , you're welcome to add something like that! Don't know whether it's even necessary to add the exception for .gitignore itself (to be tested, maybe you did).

Personally I find it most convenient when all ignored stuff is in one .gitignore file at the git repo root and not scattered around, in order to easily manage git. This would mean:

  1. check if .gitignore is present and n2khab_data is still missing in it.
  2. If so, add a new line n2khab_data.
  3. If .gitignore is missing, make it and do the same.
  4. If n2khab_data is already in .gitignore, nothing is to be done.

If you like to do deeper checks for existing ignored files, have a look here. Maybe git2r could help in it. But I wouldn't make it too complicated.

florisvdh commented 4 years ago

@hansvancalster: the implementation of @ThierryO to use **/n2khab_data seems better than what I first proposed.

falkmielke commented 2 months ago

I would like to mention that fileman_folders() fails if there is no *.Rproj file in the cwd. However, no Rproj is delivered with the package.

> Error: No root directory found in <path> or its parent directories. Root criterion: contains a file matching "[.]Rproj$" with contents matching "^Version: " in the first line

I would expect the function to have a fallback (instead of adding an rproj, which seems debatable).

This is a bonus. I can just make an Rproj file. But I thought it "low hanging fruit" if we implement checking for a git repo anyways.

Cheers,

Falk

> sessionInfo()
R version 4.4.1 (2024-06-14)
Platform: x86_64-pc-linux-gnu
Running under: Manjaro Linux

Matrix products: default
BLAS:   /usr/lib/libblas.so.3.12.0 
LAPACK: /usr/lib/liblapack.so.3.12.0

other attached packages:
 [1] units_0.8-5     mapview_2.11.2  sf_1.0-16       lubridate_1.9.3
 [5] forcats_1.0.0   stringr_1.5.1   dplyr_1.1.4     purrr_1.0.2    
 [9] readr_2.1.5     tidyr_1.3.1     tibble_3.2.1    ggplot2_3.5.1  
[13] tidyverse_2.0.0 knitr_1.48      n2khab_0.10.1  
florisvdh commented 2 months ago

I would like to mention that fileman_folders() fails if there is no *.Rproj file in the cwd.

That's definitely not OK, thanks for reporting. The functions should not be bound by IDE specifics.

Can you make this into a separate issue @falkmielke? I've narrowed the subject of current issue to better reflect the initial idea.