Skip to content

Commit

Permalink
fix: use absolute paths when cloning remotes (#873)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrexox authored Nov 18, 2024
1 parent 9996e0d commit f4c24e4
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions internal/git/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ var (
cmdStagedFiles = []string{"git", "diff", "--name-only", "--cached", "--diff-filter=ACMR"}
cmdStatusShort = []string{"git", "status", "--short", "--porcelain"}
cmdListStash = []string{"git", "stash", "list"}
cmdRootPath = []string{"git", "rev-parse", "--show-toplevel"}
cmdHooksPath = []string{"git", "rev-parse", "--git-path", "hooks"}
cmdInfoPath = []string{"git", "rev-parse", "--git-path", "info"}
cmdGitPath = []string{"git", "rev-parse", "--git-dir"}
cmdRootPath = []string{"git", "rev-parse", "--path-format=absolute", "--show-toplevel"}
cmdHooksPath = []string{"git", "rev-parse", "--path-format=absolute", "--git-path", "hooks"}
cmdInfoPath = []string{"git", "rev-parse", "--path-format=absolute", "--git-path", "info"}
cmdGitPath = []string{"git", "rev-parse", "--path-format=absolute", "--git-dir"}
cmdAllFiles = []string{"git", "ls-files", "--cached"}
cmdCreateStash = []string{"git", "stash", "create"}
cmdStageFiles = []string{"git", "add"}
Expand Down Expand Up @@ -62,15 +62,13 @@ func NewRepository(fs afero.Fs, git *CommandExecutor) (*Repository, error) {
if err != nil {
return nil, err
}
if exists, _ := afero.DirExists(fs, filepath.Join(rootPath, hooksPath)); exists {
hooksPath = filepath.Join(rootPath, hooksPath)
}

infoPath, err := git.Cmd(cmdInfoPath)
if err != nil {
return nil, err
}
infoPath = filepath.Clean(infoPath)

if exists, _ := afero.DirExists(fs, infoPath); !exists {
err = fs.Mkdir(infoPath, infoDirMode)
if err != nil {
Expand All @@ -82,9 +80,6 @@ func NewRepository(fs afero.Fs, git *CommandExecutor) (*Repository, error) {
if err != nil {
return nil, err
}
if !filepath.IsAbs(gitPath) {
gitPath = filepath.Join(rootPath, gitPath)
}

emptyTreeSHA, err := git.Cmd(cmdEmptyTreeSHA)
if err != nil {
Expand Down

0 comments on commit f4c24e4

Please sign in to comment.