cloner

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: MIT Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 の追加オプションです。

Jump to

Keyboard shortcuts

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