ghca

package
v2.4.0+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 12, 2018 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package ghca provides functionalities of github-clone-all command. Because of restriction of GitHub search API, max number of results is 1000 repositories. And you may need to gain GitHub API token in advance to avoid reaching API rate limit.

Please see the repository page to know more detail.

https://github.com/rhysd/github-clone-all

Index

Constants

View Source
const PageUnlimited uint = 0

PageUnlimited means to fetch and clone repositories as much as possible.

Variables

This section is empty.

Functions

This section is empty.

Types

type CLI

type CLI struct {
	// contains filtered or unexported fields
}

CLI represents a command line interface of github-clone-all.

func NewCLI

func NewCLI(token, query, dest, extract string, count int, dry bool, deep bool) (*CLI, error)

NewCLI creates a new command line interface to run github-clone-all. Query ('q' parameter) must not be empty.

func (*CLI) Run

func (c *CLI) Run() (err error)

Run processes github-clone-all with given options.

type Cloner

type Cloner struct {

	// Err is a receiver of errors which occurs while cloning repositories
	Err chan error

	// SSH is a flag to use SSH for git-clone. By default, it's false and HTTPS is used.
	SSH bool
	// contains filtered or unexported fields
}

Cloner is a git-clone worker to clone given repositories with workers in parallel.

func NewCloner

func NewCloner(dest string, extract *regexp.Regexp, deep bool) *Cloner

NewCloner creates a new cloner instance. 'extract' parameter can be nil.

func (*Cloner) Clone

func (cl *Cloner) Clone(slug string)

Clone clones the repository. Format of 'slug' parameter is 'owner/name'.

func (*Cloner) Shutdown

func (cl *Cloner) Shutdown()

Shutdown stops all workers and waits until all of current tasks are completed.

func (*Cloner) Start

func (cl *Cloner) Start(para int)

Start starts underlying workers and makes ready for running. Parameter 'para' indicates how many workers should be used.a Max number is '# of CPU - 1' and 0 indicates using the default value.

type Collector

type Collector struct {

	// Query is a query to search repositories on GitHub.
	// Please refer following links to know about query:
	// https://help.github.com/articles/understanding-the-search-syntax/
	// https://help.github.com/articles/searching-repositories/
	Query string
	// Dest is a directory to clone repository into.
	Dest string
	// Extract is a regular expression to extract files with. It can be nil.
	Extract *regexp.Regexp
	// Count represents max number of repositories to clone
	Count int
	// Dry indicates doing dry-run instead of cloning repositories
	Dry bool
	// Deep indicates shallow clone is not used
	Deep bool
	// contains filtered or unexported fields
}

Collector is a worker to fetch repositories via GitHub Search API and clone them all. You should NOT reuse Collector instance for multiple queries.

func NewCollector

func NewCollector(query, token, dest string, extract *regexp.Regexp, count int, dry bool, deep bool, page *PageConfig) *Collector

NewCollector creates Collector instance.

func (*Collector) Collect

func (col *Collector) Collect() (int, int, error)

Collect collects all repositories based on results of GitHub Search API. It returns total number of atucally cloned repositories and total number of repositories on GitHub.

type PageConfig

type PageConfig struct {
	// Per represents how many repositories per sending request.
	Per uint
	// Max represents a max page.
	Max uint
	// Start represents which page should be started.
	Start uint
}

PageConfig represents configurations for pagination of the Search API.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL