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_available_templates(): to get a list of all templates available on gitignore.io.
  • gi_fetch_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_available_templates(), 50)
##  [1] "1c"                   "1c-bitrix"            "actionscript"        
##  [4] "ada"                  "adobe"                "advancedinstaller"   
##  [7] "adventuregamestudio"  "a-frame"              "agda"                
## [10] "al"                   "alteraquartusii"      "altium"              
## [13] "android"              "androidstudio"        "angular"             
## [16] "anjuta"               "ansible"              "apachecordova"       
## [19] "apachehadoop"         "appbuilder"           "appceleratortitanium"
## [22] "appcode"              "appcode+all"          "appcode+iml"         
## [25] "appengine"            "aptanastudio"         "arcanist"            
## [28] "archive"              "archives"             "archlinuxpackages"   
## [31] "aspnetcore"           "assembler"            "ate"                 
## [34] "atmelstudio"          "ats"                  "audio"               
## [37] "automationstudio"     "autotools"            "autotools+strict"    
## [40] "awr"                  "backup"               "ballerina"           
## [43] "basercms"             "basic"                "batch"               
## [46] "bazaar"               "bazel"                "bitrise"             
## [49] "bitrix"               "bittorrent"

The function gi_fetch_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_templates(c("java", "c++"))
## 
## # Created by https://www.gitignore.io/api/java,c++
## # Edit at https://www.gitignore.io/?templates=java,c++
## 
## ### C++ ###
## # Prerequisites
## *.d
## 
## # Compiled Object files
## *.slo
## *.lo
## *.o
## *.obj
## 
## # Precompiled Headers
## *.gch
## *.pch
## 
## # Compiled Dynamic libraries
## *.so
## *.dylib
## *.dll
## 
## # Fortran module files
## *.mod
## *.smod
## 
## # Compiled Static libraries
## *.lai
## *.la
## *.a
## *.lib
## 
## # Executables
## *.exe
## *.out
## *.app
## 
## ### Java ###
## # Compiled class file
## *.class
## 
## # Log file
## *.log
## 
## # BlueJ files
## *.ctxt
## 
## # Mobile Tools for Java (J2ME)
## .mtj.tmp/
## 
## # Package Files #
## *.jar
## *.war
## *.nar
## *.ear
## *.zip
## *.tar.gz
## *.rar
## 
## # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
## hs_err_pid*
## 
## # End of https://www.gitignore.io/api/java,c++

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

gi_fetch_templates(c("java", "c++"), copy_to_clipboard = FALSE)
## 
## # Created by https://www.gitignore.io/api/java,c++
## # Edit at https://www.gitignore.io/?templates=java,c++
## 
## ### C++ ###
## # Prerequisites
## *.d
## 
## # Compiled Object files
## *.slo
## *.lo
## *.o
## *.obj
## 
## # Precompiled Headers
## *.gch
## *.pch
## 
## # Compiled Dynamic libraries
## *.so
## *.dylib
## *.dll
## 
## # Fortran module files
## *.mod
## *.smod
## 
## # Compiled Static libraries
## *.lai
## *.la
## *.a
## *.lib
## 
## # Executables
## *.exe
## *.out
## *.app
## 
## ### Java ###
## # Compiled class file
## *.class
## 
## # Log file
## *.log
## 
## # BlueJ files
## *.ctxt
## 
## # Mobile Tools for Java (J2ME)
## .mtj.tmp/
## 
## # Package Files #
## *.jar
## *.war
## *.nar
## *.ear
## *.zip
## *.tar.gz
## *.rar
## 
## # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
## hs_err_pid*
## 
## # End of https://www.gitignore.io/api/java,c++

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

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

Demo

R 

See also

comments powered by Disqus