## Loading required package: devtools
## 
## Attaching package: 'devtools'
## The following object is masked from 'package:DiagrammeR':
## 
##     add_path
## Loading required package: curl
## 
## Attaching package: 'curl'
## The following object is masked from 'package:readr':
## 
##     parse_date
## Loading required package: random
## Loading required package: tfsR

TFS

In TFS2013 and Visual Studio Online, you can use git repositories inside TFS. This gives the ability to leverage all the advantages of a distributed source control system whilst still giving you all the functionality of TFS.

If you're using SourceSafe or earlier editions of TFS, UPGRADE for everyone's sakes.

If you're not using any source control, consider getting Visual Studio Online as it's free for 5 users (plus unlimited MSDN users), requires no hosting or maintenance on your part, and has fine grained permissions management.

Working with your TFS site in R with tfsR

Build StatusCoverage Status

If you have/want to work with R using git repositories in TFS (either on-premises or via Visual Studio Online), tfsR saves you having to have Visual Studio (installed on your machine or online), and allows you to directly create git repositories within TFS.

tfsR Information

Install

if (!require(devtools))
  install.packages("devtools")
devtools::install_github("stephlocke/tfsR",
                         build_vignettes = TRUE)

Setup

You must have a username (often an email address or AD account) and password for connecting. That's basically it!

NB - you can now use public acces tokens.

Intended use

Since you need to provide credentials to these functions, it is anticipated that you would use these on an ad-hoc basis in much the same way you would use devtools.

It's a great way to quickly setup a repository if you need to get your stuff into source control.

In terms of actually using your repositories once they're created, I recommend git2r.

Limitations

Using tfsR

Get info on existing repositories

A great place to start is a) verifying you can connect to your TFS and b) see what projects you could create repositories under

library(tfsR)


tfs<-"https://stephlocke.visualstudio.com"
authcreds<- TFSAuth(pwd="fz43enydh7vi2o6jqir2gmftohh7ooz2lizqvy6jxtw4ltrpwola")

repositories <-getTFSProjects(tfs,authcreds)

knitr::kable(repositories)
id name url remoteUrl defaultBranch project.id project.name project.url project.state type
db3754aa-754e-4729-82d8-15f1008fa6b2 UL2IIm https://stephlocke.visualstudio.com/DefaultCollection/_apis/git/repositories/db3754aa-754e-4729-82d8-15f1008fa6b2 https://stephlocke.visualstudio.com/DefaultCollection/tfsr3/_git/UL2IIm NA 934590ee-933c-4067-a87b-62fa1c6ad989 tfsr3 https://stephlocke.visualstudio.com/DefaultCollection/_apis/projects/934590ee-933c-4067-a87b-62fa1c6ad989 wellFormed Sub-Project
74b3180e-fa0b-4edb-80b6-2e9c5ce56a04 Z3c14j https://stephlocke.visualstudio.com/DefaultCollection/_apis/git/repositories/74b3180e-fa0b-4edb-80b6-2e9c5ce56a04 https://stephlocke.visualstudio.com/DefaultCollection/tfsr3/_git/Z3c14j NA 934590ee-933c-4067-a87b-62fa1c6ad989 tfsr3 https://stephlocke.visualstudio.com/DefaultCollection/_apis/projects/934590ee-933c-4067-a87b-62fa1c6ad989 wellFormed Sub-Project
945892a7-b38c-411d-a6fd-66efce0107d9 UserGroups https://stephlocke.visualstudio.com/DefaultCollection/_apis/git/repositories/945892a7-b38c-411d-a6fd-66efce0107d9 https://stephlocke.visualstudio.com/DefaultCollection/_git/UserGroups refs/heads/master cb870c1d-933c-40e9-b7b2-c4a5eb06d210 UserGroups https://stephlocke.visualstudio.com/DefaultCollection/_apis/projects/cb870c1d-933c-40e9-b7b2-c4a5eb06d210 wellFormed Project
075b69a8-0e45-4805-8e7b-71790ee2f6dd hriiB9 https://stephlocke.visualstudio.com/DefaultCollection/_apis/git/repositories/075b69a8-0e45-4805-8e7b-71790ee2f6dd https://stephlocke.visualstudio.com/DefaultCollection/tfsr3/_git/hriiB9 NA 934590ee-933c-4067-a87b-62fa1c6ad989 tfsr3 https://stephlocke.visualstudio.com/DefaultCollection/_apis/projects/934590ee-933c-4067-a87b-62fa1c6ad989 wellFormed Sub-Project
16f3a6b2-83ec-413e-9be3-8fafa36e5502 BL4xA1 https://stephlocke.visualstudio.com/DefaultCollection/_apis/git/repositories/16f3a6b2-83ec-413e-9be3-8fafa36e5502 https://stephlocke.visualstudio.com/DefaultCollection/tfsr3/_git/BL4xA1 NA 934590ee-933c-4067-a87b-62fa1c6ad989 tfsr3 https://stephlocke.visualstudio.com/DefaultCollection/_apis/projects/934590ee-933c-4067-a87b-62fa1c6ad989 wellFormed Sub-Project
b89aeb65-9993-4b2f-a466-917f5ebccc56 47xR9q https://stephlocke.visualstudio.com/DefaultCollection/_apis/git/repositories/b89aeb65-9993-4b2f-a466-917f5ebccc56 https://stephlocke.visualstudio.com/DefaultCollection/tfsr3/_git/47xR9q NA 934590ee-933c-4067-a87b-62fa1c6ad989 tfsr3 https://stephlocke.visualstudio.com/DefaultCollection/_apis/projects/934590ee-933c-4067-a87b-62fa1c6ad989 wellFormed Sub-Project
1238a6cb-3500-4d58-8f71-9a3adf3bba23 9Vwm3n https://stephlocke.visualstudio.com/DefaultCollection/_apis/git/repositories/1238a6cb-3500-4d58-8f71-9a3adf3bba23 https://stephlocke.visualstudio.com/DefaultCollection/tfsr3/_git/9Vwm3n NA 934590ee-933c-4067-a87b-62fa1c6ad989 tfsr3 https://stephlocke.visualstudio.com/DefaultCollection/_apis/projects/934590ee-933c-4067-a87b-62fa1c6ad989 wellFormed Sub-Project
8b4d7951-f93a-4563-9428-ac71ca214c6e 0j9JmO https://stephlocke.visualstudio.com/DefaultCollection/_apis/git/repositories/8b4d7951-f93a-4563-9428-ac71ca214c6e https://stephlocke.visualstudio.com/DefaultCollection/tfsr3/_git/0j9JmO NA 934590ee-933c-4067-a87b-62fa1c6ad989 tfsr3 https://stephlocke.visualstudio.com/DefaultCollection/_apis/projects/934590ee-933c-4067-a87b-62fa1c6ad989 wellFormed Sub-Project
ba8ad5a5-16e8-42fb-b02f-afb04149e6c7 IqchPU https://stephlocke.visualstudio.com/DefaultCollection/_apis/git/repositories/ba8ad5a5-16e8-42fb-b02f-afb04149e6c7 https://stephlocke.visualstudio.com/DefaultCollection/tfsr3/_git/IqchPU NA 934590ee-933c-4067-a87b-62fa1c6ad989 tfsr3 https://stephlocke.visualstudio.com/DefaultCollection/_apis/projects/934590ee-933c-4067-a87b-62fa1c6ad989 wellFormed Sub-Project
4c5e9db5-5a16-4ab3-bb39-bbc76f010dd6 tfsr3 https://stephlocke.visualstudio.com/DefaultCollection/_apis/git/repositories/4c5e9db5-5a16-4ab3-bb39-bbc76f010dd6 https://stephlocke.visualstudio.com/DefaultCollection/_git/tfsr3 NA 934590ee-933c-4067-a87b-62fa1c6ad989 tfsr3 https://stephlocke.visualstudio.com/DefaultCollection/_apis/projects/934590ee-933c-4067-a87b-62fa1c6ad989 wellFormed Project
a4eba57b-aeb5-430c-83f4-c1e55197510a dc9YnG https://stephlocke.visualstudio.com/DefaultCollection/_apis/git/repositories/a4eba57b-aeb5-430c-83f4-c1e55197510a https://stephlocke.visualstudio.com/DefaultCollection/tfsr3/_git/dc9YnG NA 934590ee-933c-4067-a87b-62fa1c6ad989 tfsr3 https://stephlocke.visualstudio.com/DefaultCollection/_apis/projects/934590ee-933c-4067-a87b-62fa1c6ad989 wellFormed Sub-Project
dba7ced2-3a8e-4841-9228-d94c51f54ae6 pFoMRk https://stephlocke.visualstudio.com/DefaultCollection/_apis/git/repositories/dba7ced2-3a8e-4841-9228-d94c51f54ae6 https://stephlocke.visualstudio.com/DefaultCollection/tfsr3/_git/pFoMRk NA 934590ee-933c-4067-a87b-62fa1c6ad989 tfsr3 https://stephlocke.visualstudio.com/DefaultCollection/_apis/projects/934590ee-933c-4067-a87b-62fa1c6ad989 wellFormed Sub-Project
0edd7ad6-d410-4dfa-acfd-e2616357a86b Vfcpk4 https://stephlocke.visualstudio.com/DefaultCollection/_apis/git/repositories/0edd7ad6-d410-4dfa-acfd-e2616357a86b https://stephlocke.visualstudio.com/DefaultCollection/tfsr3/_git/Vfcpk4 NA 934590ee-933c-4067-a87b-62fa1c6ad989 tfsr3 https://stephlocke.visualstudio.com/DefaultCollection/_apis/projects/934590ee-933c-4067-a87b-62fa1c6ad989 wellFormed Sub-Project
3d1b50af-e517-45d2-9def-f3f94206ced5 n4lnyT https://stephlocke.visualstudio.com/DefaultCollection/_apis/git/repositories/3d1b50af-e517-45d2-9def-f3f94206ced5 https://stephlocke.visualstudio.com/DefaultCollection/tfsr3/_git/n4lnyT NA 934590ee-933c-4067-a87b-62fa1c6ad989 tfsr3 https://stephlocke.visualstudio.com/DefaultCollection/_apis/projects/934590ee-933c-4067-a87b-62fa1c6ad989 wellFormed Sub-Project

Create a new repository

TFS doesn't allow you to create new projects so if you want to create a new repository, you have to do it in an existing project or go to the GUI and manually create one (there is no API call for this).

You don't want to start nesting repositories so you need to make the repository under a top-level project. As such, in this bit of functionality, you provide the name of the top-level project which you want to put your repository, and it goes away and gets a GUID if the project exists and is a top-level project, then tells the API to create a repository in it.

tfs<-"https://stephlocke.visualstudio.com"
authcreds<- TFSAuth(pwd="fz43enydh7vi2o6jqir2gmftohh7ooz2lizqvy6jxtw4ltrpwola")

parentproj   <-"tfsr3"
newrepo      <- as.character(random::randomStrings(n=1, len=6))
createdrepo  <- createTFSRepository(tfs,authcreds,parentproj,newrepo)
createdrepo
## [1] "https://stephlocke.visualstudio.com/DefaultCollection/tfsr3/_git/VwlZxU"

This will provide you with the URL you need to be able to push and pull commits to. In this case it has created a repository called “VwlZxU” which can be interacted with at the URL https://stephlocke.visualstudio.com/DefaultCollection/tfsr3/_git/VwlZxU

Delete a repository

USE WITH CAUTION!

You can delete a repository programmatically if you so choose. Primarily, I wrote the method to keep these vignettes clean!

Let's clean up the repo we just made.

deleteTFSRepository(tfs,authcreds,newrepo)
## [1] "Success!"