/
README.Rmd
97 lines (66 loc) · 4.19 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# gitignore
<!-- badges: start -->
[![CRAN status](https://www.r-pkg.org/badges/version/gitignore)](https://cran.r-project.org/package=gitignore)
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
[![Codecov test coverage](https://codecov.io/gh/ropensci/gitignore/branch/main/graph/badge.svg)](https://app.codecov.io/gh/ropensci/gitignore?branch=main)
[![DOI](https://zenodo.org/badge/184759416.svg)](https://zenodo.org/badge/latestdoi/184759416)
[![rOpenSci peer-review](https://badges.ropensci.org/303_status.svg)](https://github.com/ropensci/software-review/issues/303)
[![R-CMD-check](https://github.com/PMassicotte/gitignore/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/ropensci/gitignore/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->
Based on the definition proposed by [freecodecamp](https://www.freecodecamp.org/news/gitignore-what-is-it-and-how-to-add-to-repo/):
> The .gitignore file is a text file that tells Git which files or folders to ignore in a project. A local .gitignore file is usually placed in the root directory of a project. You can also create a global .gitignore file and any entries in that file will be ignored in all of your Git repositories.
For any project, it is therefore important to have a `.gitignore` file that is complete and accurate. The package `gitignore` provides a simple R interface to the [gitignore.io](https://www.toptal.com/developers/gitignore) API. It can be used to fetch gitignore templates that can be included into the `.gitignore` file of you git repository. The `gitignore` R package can be used with R package, R Studio project or with any `.gitignore` file. Note that by default, the `usethis` package populates the `.gitignore` for the R language when you create a R project. However, it is common to use many different programming languages in a project such as `LaTeX`, `python`, `matlab`, `julia` and so one. This is where the `gitignore` package shines as it can be used to programmatically modify the `.gitignore` file of your project.
## Installation
The CRAN version of `gitignore` can be installed using:
```{r, eval=FALSE}
install.packages("gitignore")
```
The dev version of `gitignore` can be installed from GitHub:
```{r, eval=FALSE}
install.packages("devtools")
devtools::install_github("ropensci/gitignore")
```
## Examples
There are currently two useful functions in the package:
- `gi_available_templates()` to fetch all supported gitignore templates.
- `gi_fetch_templates()` to fetch one or many gitignore templates.
Show the first 25 templates returned by `gi_available_templates()`.
```{r}
library(gitignore)
head(gi_available_templates(), 25)
```
Templates can be fetched using the `gi_fetch_templates()` function.
```{r, results='markup', comment=""}
gi_fetch_templates("R")
```
Multiple templates can be fetched by specifying multiple values:
```{r, results='markup', comment=""}
gi_fetch_templates(c("java", "c++"))
```
By default, templates are copied into the clipboard. It is also possible to modify a `.gitignore` file using the `gi_write_gitignore()` function.
```{r, eval=FALSE}
f <- file.path(tempdir(), ".gitignore")
new_lines <- gi_fetch_templates("r")
gi_write_gitignore(fetched_template = new_lines, gitignore_file = f)
```
If `gitignore_file` is not specified, `gitignore` will try to find the `.gitignore` file of your current project or package.
More examples are provided in the vignette.
```{r, eval=FALSE}
browseVignettes("gitignore")
```
You can also visit the [gitignore website](https://docs.ropensci.org/gitignore/).
## Code of conduct
Please note that the 'gitignore' project is released with a [Contributor Code of Conduct](https://docs.ropensci.org/gitignore/CODE_OF_CONDUCT.html). By [contributing to this project](https://docs.ropensci.org/gitignore/CONTRIBUTING.html), you agree to abide by its terms.
[![ropensci_footer](https://ropensci.org/public_images/ropensci_footer.png)](https://ropensci.org)