Introducing gitignore

In this post I will introduce the gitignore R package (https://github.com/PMassicotte/gitignore).

Basic idea

gitignore is a simple R package that provide an interface to query gitignore.io to fetch gitignore templates that can be included in the .gitignore file. More than 450 templates are currently available. There are actually two functions in the package:

  • gi_fetch_available_templates(): to get a list of all templates available on gitignore.io.
  • gi_fetch_ignore_templates(): to get one or more template(s). This function can copy the returned template(s) in the clipboard as well as happening the the .gitignore file in your project directory.

Examples

library(gitignore)

Get the list of all available templates from gitignore.io:

head(gi_fetch_available_templates(), 50)
##  [1] "1c"                   "1c-bitrix"            "a-frame"             
##  [4] "actionscript"         "ada"                  "adobe"               
##  [7] "advancedinstaller"    "agda"                 "al"                  
## [10] "alteraquartusii"      "altium"               "android"             
## [13] "androidstudio"        "angular"              "anjuta"              
## [16] "ansible"              "apachecordova"        "apachehadoop"        
## [19] "appbuilder"           "appceleratortitanium" "appcode"             
## [22] "appcode+all"          "appcode+iml"          "appengine"           
## [25] "aptanastudio"         "arcanist"             "archive"             
## [28] "archives"             "archlinuxpackages"    "aspnetcore"          
## [31] "assembler"            "ate"                  "atmelstudio"         
## [34] "ats"                  "audio"                "automationstudio"    
## [37] "autotools"            "autotools+strict"     "backup"              
## [40] "ballerina"            "basercms"             "basic"               
## [43] "batch"                "bazaar"               "bazel"               
## [46] "bitrise"              "bitrix"               "bittorrent"          
## [49] "blackbox"             "bloop"

The function gi_fetch_ignore_templates() can be used to fetch particular template(s). For example, one could want to get the java and c++ templates as follow:

gi_fetch_ignore_templates(c("java", "c++"))

By default, the template(s) are copied into the clipboard, this can be changed by setting copy_to_clipboard = FALSE:

gi_fetch_ignore_templates(c("java", "c++"), copy_to_clipboard = FALSE)

Additionally, you can tell gi_fetch_ignore_templates() to append automatically the .gitignore file in your project by setting append_gitignore = TRUE:

gi_fetch_ignore_templates(c("java", "c++"), append_gitignore = TRUE)

Demo

R