Package 'ghdump'

Title: Clone Or Download All Repos For A GitHub User
Description: Clone all of a GitHub user's repositories, or download them as zip files to a specified location and optionally unzip them. Intended for archiving or setting up a new computer.
Authors: Matt Dray [aut, cre]
Maintainer: Matt Dray <[email protected]>
License: MIT + file LICENSE
Version: 0.1.0
Built: 2024-11-12 02:39:17 UTC
Source: https://github.com/matt-dray/ghdump

Help Index


Clone Multiple Repos From A GitHub User

Description

Iterate over multiple repos for a given GitHub user, cloning them to a specified local repository.

Usage

ghd_clone_multi(gh_user, names_vec, protocol, dest_dir)

Arguments

gh_user

Character string. A GitHub user name.

names_vec

Character vector. Repo names for the given gh_user.

protocol

Character string. Either "https" or "ssh".

dest_dir

Character string. A local file path where the zipped repositories will be downloaded to. Must be a full path.

Details

If you're using protocol = "ssh", you need to make sure you've set up your SSH keys.

Value

The named user's named repos cloned to the specified location.


Clone One Repo From A GitHub User

Description

Clone a repo for a specified user to a specified local repository.

Usage

ghd_clone_one(gh_user, repo, protocol, dest_dir)

Arguments

gh_user

Character string. A GitHub user name.

repo

Character string. A GitHub repo name for the named gh_user.

protocol

Character string. Either "https" or "ssh".

dest_dir

Character string. A local file path where the zipped repositories will be downloaded to. Must be a full path.

Details

If you're using protocol = "ssh", you need to make sure you have set up your SSH keys.

If you're using protocol = "ssh", you need to make sure you've set up your SSH keys.

Value

The named user's named repo cloned to the specified location.


Clone Or Download All GitHub Repositories For A User

Description

Clone all of a GitHub user's repositories to your computer, or download them all as zip files and then optionally unzip them.

Usage

ghd_copy(gh_user, dest_dir, copy_type, protocol = NULL)

Arguments

gh_user

Character string. A GitHub user name.

dest_dir

Character string. A local file path where the clones or zipped repositories will be downloaded to. Must be a full path.

copy_type

Character string. Specify whether to "download" or "clone" the repos to your local machine.

protocol

Character string. Either "https" or "ssh". Only required if copy_type = "clone".

Details

Make sure you've got a GitHub account and have generated a GitHub PAT and stored it your .Renviron. If you're using protocol = "ssh", you need to make sure you have set up your SSH keys.

Value

GitHub repositories either (a) cloned or (b) downloaded in the specified local directory.

Examples

## Not run: 
ghd_copy(
  gh_user = "matt-dray",
  dest_dir = "~/Documents/repos-cloned",
  copy_type = "clone",
  protocol = "https"
)

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

## End(Not run)

Download Zipped Repos To Your Machine

Description

Download to a specified location the zip files from provided URL. The directory is created if it doesn't already exist.

Usage

ghd_download_zips(repo_urls, dest_dir)

Arguments

repo_urls

A data.frame as returned by ghd_enframe_urls, with one row per GitHub repo with character-class columns for the repo_names and zip_url.

dest_dir

A character string. The local directory you want to download the zipped files to. Must be a full path.

Value

Zipped GitHub repositories downloaded to a (possibly new) directory.


Create A Data Frame Of Repo Names And Zip File URLS For Each

Description

Prepare a data frame containing each repo name and its corresponding zip file URL in the form https://github.com/username/reponame/archive/master.zip

Usage

ghd_enframe_urls(repo_names, gh_user)

Arguments

repo_names

A character vector of GitHub repository names, as returned by ghd_extract_names.

gh_user

The name of a GitHub user.

Value

A data.frame object. One row per GitHub repo with character vector columns for the repo_names and zip_url.


Extract Names of GitHub Repos

Description

Extract all the 'name' elements from a gh_response object. These are the names of all the GitHub repos.

Usage

ghd_extract_names(repo_object)

Arguments

repo_object

A gh_response object, as returned by ghd_get_repos.

Value

A character vector of GitHub repo names.


Get GitHub Repo Information for a Named User

Description

Uses gh to access the GitHub API and get the details for all of a named user's repos. To use this function you need to have created a GitHub account and to have put a GitHub Personal Access Token (PAT) in your .Renviron. See Happy Git and GitHub for the UseR for more information.

Usage

ghd_get_repos(gh_user)

Arguments

gh_user

Character string. A GitHub username.

Value

A gh_response (list) object.


Unzip GitHub Repositories In A Named Directory

Description

Unzips the GitHub repositories that have been downloaded to a specified local directory and optionally deletes the zipped versions. Optionally rename all the unzipped folders to remove the "-master" suffix (e.g. "demo-repo-master" becomes "demo-repo").

Usage

ghd_unzip(dir)

Arguments

dir

A string. Path to a local directory containing zipped GitHub directories. These may have been downloaded using ghd_download_zips. Must be a full path.

Value

Unzipped GitHub repositories in a named directory.