mirror of
https://github.com/grdl/git-get.git
synced 2026-02-09 09:44:18 +00:00
Add quiet flag to Clone method
This commit is contained in:
10
new/repo.go
10
new/repo.go
@@ -1,6 +1,7 @@
|
|||||||
package new
|
package new
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/go-git/go-git/v5/plumbing/cache"
|
"github.com/go-git/go-git/v5/plumbing/cache"
|
||||||
@@ -17,7 +18,12 @@ type Repo struct {
|
|||||||
Status *RepoStatus
|
Status *RepoStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
func CloneRepo(url string, path billy.Filesystem) (r *Repo, err error) {
|
func CloneRepo(url string, path billy.Filesystem, quiet bool) (r *Repo, err error) {
|
||||||
|
var output io.Writer
|
||||||
|
if !quiet {
|
||||||
|
output = os.Stdout
|
||||||
|
}
|
||||||
|
|
||||||
opts := &git.CloneOptions{
|
opts := &git.CloneOptions{
|
||||||
URL: url,
|
URL: url,
|
||||||
Auth: nil,
|
Auth: nil,
|
||||||
@@ -27,7 +33,7 @@ func CloneRepo(url string, path billy.Filesystem) (r *Repo, err error) {
|
|||||||
NoCheckout: false,
|
NoCheckout: false,
|
||||||
Depth: 0,
|
Depth: 0,
|
||||||
RecurseSubmodules: git.NoRecurseSubmodules,
|
RecurseSubmodules: git.NoRecurseSubmodules,
|
||||||
Progress: os.Stdout,
|
Progress: output,
|
||||||
Tags: git.AllTags,
|
Tags: git.AllTags,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
|
|
||||||
func TestRepoCloneInMemory(t *testing.T) {
|
func TestRepoCloneInMemory(t *testing.T) {
|
||||||
path := memfs.New()
|
path := memfs.New()
|
||||||
repo, err := CloneRepo("https://github.com/grdl/dotfiles", path)
|
repo, err := CloneRepo("https://github.com/grdl/dotfiles", path, true)
|
||||||
checkFatal(t, err)
|
checkFatal(t, err)
|
||||||
|
|
||||||
wt, err := repo.repo.Worktree()
|
wt, err := repo.repo.Worktree()
|
||||||
@@ -26,7 +26,7 @@ func TestRepoCloneInMemory(t *testing.T) {
|
|||||||
|
|
||||||
func TestRepoCloneOnDisk(t *testing.T) {
|
func TestRepoCloneOnDisk(t *testing.T) {
|
||||||
path := osfs.New(newTempDir(t))
|
path := osfs.New(newTempDir(t))
|
||||||
repo, err := CloneRepo("https://github.com/grdl/dotfiles", path)
|
repo, err := CloneRepo("https://github.com/grdl/dotfiles", path, true)
|
||||||
checkFatal(t, err)
|
checkFatal(t, err)
|
||||||
|
|
||||||
wt, err := repo.repo.Worktree()
|
wt, err := repo.repo.Worktree()
|
||||||
|
|||||||
Reference in New Issue
Block a user