mirror of
https://github.com/grdl/git-get.git
synced 2026-02-15 14:00:07 +00:00
Replace path.Join with filepath.Join
Path is for URLs, filepath is for os paths. This solves the problem with wrong repo root on windows.
This commit is contained in:
@@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
"git-get/pkg/git"
|
||||
"git-get/pkg/io"
|
||||
"path"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
// GetCfg provides configuration for the Get command.
|
||||
@@ -40,7 +40,7 @@ func cloneSingleRepo(c *GetCfg) error {
|
||||
|
||||
opts := &git.CloneOpts{
|
||||
URL: url,
|
||||
Path: path.Join(c.Root, URLToPath(url)),
|
||||
Path: filepath.Join(c.Root, URLToPath(url)),
|
||||
Branch: c.Branch,
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ func cloneDumpFile(c *GetCfg) error {
|
||||
|
||||
opts := &git.CloneOpts{
|
||||
URL: url,
|
||||
Path: path.Join(c.Root, URLToPath(url)),
|
||||
Path: filepath.Join(c.Root, URLToPath(url)),
|
||||
Branch: line.branch,
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"git-get/pkg/io"
|
||||
"git-get/pkg/run"
|
||||
"git-get/pkg/test"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -75,7 +75,7 @@ func TestGitConfig(t *testing.T) {
|
||||
|
||||
func makeConfigEmpty(t *testing.T) *cfgStub {
|
||||
c := newCfgStub(t)
|
||||
io.Write(path.Join(c.repo.Path(), dotgit, "config"), "")
|
||||
io.Write(filepath.Join(c.repo.Path(), dotgit, "config"), "")
|
||||
|
||||
return c
|
||||
}
|
||||
@@ -89,7 +89,7 @@ func makeConfigValid(t *testing.T) *cfgStub {
|
||||
[gitget]
|
||||
host = github.com
|
||||
`
|
||||
io.Write(path.Join(c.repo.Path(), dotgit, "config"), gitconfig)
|
||||
io.Write(filepath.Join(c.repo.Path(), dotgit, "config"), gitconfig)
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
@@ -4,12 +4,12 @@ import (
|
||||
"fmt"
|
||||
"git-get/pkg/io"
|
||||
"git-get/pkg/run"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func (r *Repo) writeFile(filename string, content string) {
|
||||
path := path.Join(r.path, filename)
|
||||
path := filepath.Join(r.path, filename)
|
||||
err := io.Write(path, content)
|
||||
checkFatal(r.t, err)
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package pkg
|
||||
|
||||
import (
|
||||
urlpkg "net/url"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
@@ -67,7 +67,7 @@ func URLToPath(url *urlpkg.URL) (repoPath string) {
|
||||
repoHost := strings.Split(url.Host, ":")[0]
|
||||
|
||||
// Remove trailing ".git" from repo name
|
||||
repoPath = path.Join(repoHost, url.Path)
|
||||
repoPath = filepath.Join(repoHost, url.Path)
|
||||
repoPath = strings.TrimSuffix(repoPath, ".git")
|
||||
|
||||
// Remove tilde (~) char from username
|
||||
|
||||
Reference in New Issue
Block a user