Learn R Programming

archivist.github (version 0.2.6)

createGitHubRepo: Create an Empty Repository on GitHub

Description

createGitHubRepo is a GitHub version of createLocalRepo and creates a new GitHub repository with an empty archivist-like Repository. It also creates a Local Repository which is git-synchronized with new GitHub repository.

This function is well explained on this http://r-bloggers.com/r-hero-saves-backup-city-with-archivist-and-github blog post.

Usage

createGitHubRepo(repo, github_token = aoptions("github_token"),
  user = aoptions("user"), repoDir = NULL,
  password = aoptions("password"),
  repoDescription = aoptions("repoDescription"),
  readmeDescription = aoptions("readmeDescription"),
  response = aoptions("response"), default = FALSE, verbose = FALSE, ...)

Arguments

repo

While working with a Github repository. A character denoting new GitHub repository name. White spaces will be substitued with a dash.

github_token

While working with a Github repository. An OAuth GitHub Token created with the oauth2.0_token function. See archivist-github-integration. Can be set globally with aoptions("github_token", github_token).

user

While working with a Github repository. A character denoting GitHub user name. Can be set globally with aoptions("user", user). See archivist-github-integration.

repoDir

A character that specifies the directory for the Repository which is to be made. While working with GitHub Repository, this will be the directory of the synchronized Local Repository, in which the new Local Repository will be created (is NULL then is the same as repo).

password

While working with a Github repository. A character denoting GitHub user password. Can be set globally with aoptions("password", password). See archivist-github-integration.

repoDescription

While working with a Github repository. A character specifing the new GitHub repository description.

readmeDescription

While working with a Github repository. A character of the content of README.md file. By default a description of Repository. Can be set globally with aoptions("readmeDescription", readmeDescription). In order to omit README.md file set aoptions("readmeDescription", NULL).

response

A logical value. Should the GitHub API response be returned.

default

If default = TRUE then repoDir (repo) is set as default local repository. Also the user is set as default GitHub user.

verbose

A logical value. If TRUE then additional messages will be printed out.

...

further arguments passed to createLocalRepo such as force.

Details

To learn more about Archivist Integration With GitHub visit agithub.

At least one Repository must be initialized before using other functions from the archivist.github package. While working in groups, it is highly recommended to create a Repository on a shared Dropbox/GitHub folder.

All artifacts which are desired to be archived are going to be saved in the local Repository, which is an SQLite database stored in a file named backpack. After calling saveToLocalRepo function, each artifact will be archived in a md5hash.rda file. This file will be saved in a folder (under repoDir directory) named gallery. For every artifact, md5hash is a unique string of length 32 that is produced by digest function, which uses a cryptographical MD5 hash algorithm.

To learn more about artifacts visit archivist-package.

Created backpack database is a useful and fundamental tool for remembering artifact's name, class, archiving date etc. (the so called Tags) or for keeping artifact's md5hash.

Besides the backpack database, gallery folder is created in which all artifacts will be archived.

After every saveToLocalRepo call the database is refreshed. As a result, the artifact is available immediately in backpack.db database for other collaborators.

References

More about archivist.github can be found on marcinkosinski.github.io/archivist.github/ and about archivist in posts' history on https://pbiecek.github.io/archivist/articles/posts.html

See Also

Other archivist.github: archive, archivist.github-package, authoriseGitHub, cloneGitHubRepo, deleteGitHubRepo, pushGitHubRepo

Examples

Run this code
# NOT RUN {
# empty GitHub Repository creation
authoriseGitHub(ClientID, ClientSecret) -> github_token
# authoriseGitHub also does: aoptions("github_token", github_token)
aoptions("user", user.name)
aoptions("password", user.password)

createGitHubRepo("Museum")
createGitHubRepo("Museum-Extras", response = TRUE)
createGitHubRepo("Gallery", readmeDescription = NULL)
createGitHubRepo("Landfill", 
repoDescription = "My models and stuff") 
createGitHubRepo("MuseumYYYY", repoDir = "Museum_YY")
createGitHubRepo("archive-test4", default = TRUE)

## artifact's archiving
przyklad <- 1:100

# archiving
archive(przyklad) -> md5hash_path

## proof that artifact is really archived
showRemoteRepo() # uses options from setGithubRepo
# let's remove przyklad
rm(przyklad)
# and load it back from md5hash_path
aread(md5hash_path)


# clone example
unlink("archive-test", recursive = TRUE)
cloneGithubRepo('https://github.com/MarcinKosinski/archive-test')
setRemoteRepo(aoptions("user"), "archive-test")
data(iris)
archive(iris)
showRemoteRepo()

# }

Run the code above in your browser using DataLab