6
0
mirror of https://github.com/grdl/git-get.git synced 2026-02-04 16:49:43 +00:00

Add --skip-host flag to get command (#7)

When set, git-get won't create a directory for the repo host.
So instead of `<root>/<host>/<user>/<repo>`, a repo will be cloned into `<root>/<user>/<repo>`.
It's useful if all repos some from the same host and that additional folder feels redundant.
This commit is contained in:
Grzegorz Dlugoszewski
2020-07-07 18:35:30 +02:00
committed by GitHub
parent 0097681f89
commit 0064fc3b8e
6 changed files with 108 additions and 28 deletions

View File

@@ -9,11 +9,12 @@ import (
// GetCfg provides configuration for the Get command.
type GetCfg struct {
Branch string
DefHost string
Dump string
Root string
URL string
Branch string
DefHost string
Dump string
Root string
SkipHost bool
URL string
}
// Get executes the "git get" command.
@@ -40,7 +41,7 @@ func cloneSingleRepo(c *GetCfg) error {
opts := &git.CloneOpts{
URL: url,
Path: filepath.Join(c.Root, URLToPath(url)),
Path: filepath.Join(c.Root, URLToPath(*url, c.SkipHost)),
Branch: c.Branch,
}
@@ -63,7 +64,7 @@ func cloneDumpFile(c *GetCfg) error {
opts := &git.CloneOpts{
URL: url,
Path: filepath.Join(c.Root, URLToPath(url)),
Path: filepath.Join(c.Root, URLToPath(*url, c.SkipHost)),
Branch: line.branch,
}