Merge pull request #276 from thockin/8-use-filepath

use filepath.Join, drop dep on path
This commit is contained in:
Kubernetes Prow Robot 2020-09-05 10:25:41 -07:00 committed by GitHub
commit 9c56b25591
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 7 deletions

View File

@ -30,7 +30,6 @@ import (
"os"
"os/exec"
"os/signal"
"path"
"path/filepath"
"strconv"
"strings"
@ -446,7 +445,7 @@ func addUser() error {
// worktree, this returns the path to it.
func updateSymlink(ctx context.Context, gitRoot, link, newDir string) (string, error) {
// 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)
if err != nil && !os.IsNotExist(err) {
return "", fmt.Errorf("error accessing current worktree: %v", err)
@ -510,7 +509,7 @@ func addWorktreeAndSwap(ctx context.Context, gitRoot, dest, branch, rev string,
}
// 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)
log.V(0).Info("adding worktree", "path", worktreePath, "branch", fmt.Sprintf("origin/%s", branch))
if err != nil {
@ -525,8 +524,8 @@ func addWorktreeAndSwap(ctx context.Context, gitRoot, dest, branch, rev string,
if err != nil {
return err
}
gitDirRef := []byte(path.Join("gitdir: ../.git/worktrees", worktreePathRelative) + "\n")
if err = ioutil.WriteFile(path.Join(worktreePath, ".git"), gitDirRef, 0644); err != nil {
gitDirRef := []byte(filepath.Join("gitdir: ../.git/worktrees", worktreePathRelative) + "\n")
if err = ioutil.WriteFile(filepath.Join(worktreePath, ".git"), gitDirRef, 0644); err != nil {
return err
}
@ -665,8 +664,8 @@ func syncRepo(ctx context.Context, repo, branch, rev string, depth int, gitRoot,
}
}
target := path.Join(gitRoot, dest)
gitRepoPath := path.Join(target, ".git")
target := filepath.Join(gitRoot, dest)
gitRepoPath := filepath.Join(target, ".git")
var hash string
_, err := os.Stat(gitRepoPath)
switch {