Documentation
¶
Overview ¶
Package cloner はリポジトリのクローン先パス決定と `git clone` の実行を担当します。
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrAlreadyExists = errors.New("クローン先のディレクトリは既に存在します")
ErrAlreadyExists はクローン先ディレクトリが既に存在する場合に返されます。
View Source
var ErrGitNotInstalled = errors.New("git コマンドが見つかりません")
ErrGitNotInstalled は git コマンドが見つからない場合に返されます。
Functions ¶
func Clone ¶
func Clone(dest Destination, opts Options) error
Clone は git clone を実行します。
- 既にクローン先ディレクトリが存在する場合は ErrAlreadyExists を返します (Options.AllowExisting が true の場合のみ呼び出し側に判断を委ねます)。
- git コマンドが存在しない場合は ErrGitNotInstalled を返します。
func CloneURL ¶
func CloneURL(dest Destination, useSSH bool) string
CloneURL は与えられた Destination からクローン URL を組み立てます。 useSSH が true の場合 git@github.com:Owner/Repo.git 形式、false の場合 https://github.com/Owner/Repo.git 形式を返します。
Types ¶
type Destination ¶
type Destination struct {
BaseDir string // 例: /Users/foo/src
Host string // 例: github.com
Owner string
Repo string
}
Destination はクローン先のパス情報を表します。
func ResolveDestination ¶
func ResolveDestination(baseDir, owner, repo string) Destination
ResolveDestination は ghq 準拠のクローン先パスを構築します。
func (Destination) FullPath ¶
func (d Destination) FullPath() string
FullPath はクローン先の絶対パスを返します ($base/github.com/Owner/Repo)。
type Options ¶
type Options struct {
// AllowExisting が true の場合、既存ディレクトリでもエラーにせずスキップします。
AllowExisting bool
// UseSSH が true の場合、 git@github.com:Owner/Repo.git をクローン URL として利用します。
UseSSH bool
// Stdout / Stderr が指定されていれば git clone の出力先として利用します (テスト用)。
Stdout io.Writer
Stderr io.Writer
}
Options は Clone の追加オプションです。
Click to show internal directories.
Click to hide internal directories.