use filepth.Join, drop dep on path
This commit is contained in:
parent
366e08ff40
commit
07b1ab7572
|
|
@ -30,7 +30,6 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"path"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
@ -447,7 +446,7 @@ func addUser() error {
|
||||||
// worktree, this returns the path to it.
|
// worktree, this returns the path to it.
|
||||||
func updateSymlink(ctx context.Context, gitRoot, link, newDir string) (string, error) {
|
func updateSymlink(ctx context.Context, gitRoot, link, newDir string) (string, error) {
|
||||||
// Get currently-linked repo directory (to be removed), unless it doesn't exist
|
// Get currently-linked repo directory (to be removed), unless it doesn't exist
|
||||||
linkPath := path.Join(gitRoot, link)
|
linkPath := filepath.Join(gitRoot, link)
|
||||||
oldWorktreePath, err := filepath.EvalSymlinks(linkPath)
|
oldWorktreePath, err := filepath.EvalSymlinks(linkPath)
|
||||||
if err != nil && !os.IsNotExist(err) {
|
if err != nil && !os.IsNotExist(err) {
|
||||||
return "", fmt.Errorf("error accessing current worktree: %v", err)
|
return "", fmt.Errorf("error accessing current worktree: %v", err)
|
||||||
|
|
@ -511,7 +510,7 @@ func addWorktreeAndSwap(ctx context.Context, gitRoot, dest, branch, rev string,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make a worktree for this exact git hash.
|
// Make a worktree for this exact git hash.
|
||||||
worktreePath := path.Join(gitRoot, "rev-"+hash)
|
worktreePath := filepath.Join(gitRoot, "rev-"+hash)
|
||||||
_, err := runCommand(ctx, gitRoot, *flGitCmd, "worktree", "add", worktreePath, "origin/"+branch)
|
_, err := runCommand(ctx, gitRoot, *flGitCmd, "worktree", "add", worktreePath, "origin/"+branch)
|
||||||
log.V(0).Info("adding worktree", "path", worktreePath, "branch", fmt.Sprintf("origin/%s", branch))
|
log.V(0).Info("adding worktree", "path", worktreePath, "branch", fmt.Sprintf("origin/%s", branch))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -526,8 +525,8 @@ func addWorktreeAndSwap(ctx context.Context, gitRoot, dest, branch, rev string,
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
gitDirRef := []byte(path.Join("gitdir: ../.git/worktrees", worktreePathRelative) + "\n")
|
gitDirRef := []byte(filepath.Join("gitdir: ../.git/worktrees", worktreePathRelative) + "\n")
|
||||||
if err = ioutil.WriteFile(path.Join(worktreePath, ".git"), gitDirRef, 0644); err != nil {
|
if err = ioutil.WriteFile(filepath.Join(worktreePath, ".git"), gitDirRef, 0644); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -666,8 +665,8 @@ func syncRepo(ctx context.Context, repo, branch, rev string, depth int, gitRoot,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
target := path.Join(gitRoot, dest)
|
target := filepath.Join(gitRoot, dest)
|
||||||
gitRepoPath := path.Join(target, ".git")
|
gitRepoPath := filepath.Join(target, ".git")
|
||||||
var hash string
|
var hash string
|
||||||
_, err := os.Stat(gitRepoPath)
|
_, err := os.Stat(gitRepoPath)
|
||||||
switch {
|
switch {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue