Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
R
 
 
man
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

ghdump

Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public. rostrum.blog post

Purpose

Clone all of a GitHub user's repositories, or download them as zip files to a specified location and unzip them. Intended for archiving purposes or setting up on a new computer.

Using {ghdump}

Learn more about this package from an associated blog post.

Note that the package is under development, may not work in all environments and is not fully tested. Use at own risk.

Install

You can install the developer version of {ghdump} from GitHub with:

remotes::install_github("matt-dray/ghdump")

GitHub PAT

You'll need a GitHub Personal Access Token to use {ghdump}.

Assuming you have a GitHub account, generate a token for accessing the GitHub API and store this in your .Renviron file. The {usethis} package helps make this a breeze. Read more in the Happy Git and GitHub for the useR book by Jenny Bryan, the STAT 545 TAs and Jim Hester.

usethis::browse_github_pat()  # opens browser to generate token
usethis::edit_r_environ()     # add your token to the .Renviron

Make sure to restart R after these steps.

Use ghd_copy()

{ghdump} has one exported function: ghd_copy(). Pass to the function a GitHub user name, a local directory to download into and whether you want to download or clone the repos. If you want to clone, you must specify the protocol (make sure your keys are set up if specifying SSH).

To clone:

ghdump::ghd_copy(
  gh_user = "matt-dray",  # user whose repos to download
  dest_dir = "~/Documents/repos",  # where to copy to
  copy_type = "clone",  # 'clone' or 'download' the repos
  protocol = "https"  # 'https' or 'ssh'
)

To download:

ghdump::ghd_copy(
  gh_user = "matt-dray",
  dest_dir = "~/Documents/repos",
  copy_type = "download"
)

The function is designed to be used interactively and infrequently. To this end, the user is prompted throughout as to whether to:

  • create a new local directory with the provided 'dest_dir' argument
  • commit to cloning all the repos (if copy_type = "clone")
  • commit to downloading all zip files (if copy_type = "download") and then whether to:
    • unzip all the files
    • retain the zip files
    • rename the unzipped directories to remove the default '-master' suffix

Credits

The function interacts with the GitHub API thanks to the {gh} package by Gábor Csárdi, Jenny Bryan and Hadley Wickham. Iteration is thanks to the {purrr} package by Lionel Henry and Hadley Wickham.

The {ghdump} package sticker was made thanks to Dmytro Perepolkin's {bunny} package and the {magick} package from Jeroen Ooms.

Code of Conduct

Please note that the {ghdump} project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

About

:octocat:⬇️ R package: download all of a user's GitHub repositories

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Languages