Skip to content
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

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

Open
hansvancalster opened this issue Apr 30, 2020 · 4 comments
Labels
enhancement New feature or request

Comments

@hansvancalster
Copy link
Contributor

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
Copy link
Member

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
Copy link
Member

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

@florisvdh florisvdh added the enhancement New feature or request label Sep 25, 2020
@falkmielke
Copy link
Collaborator

falkmielke commented Aug 21, 2024

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 florisvdh changed the title fileman_folders fileman_folders() should update (or create) .gitignore if root = "git" Aug 21, 2024
@florisvdh
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants