diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2023-07-28 18:27:14 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2023-07-30 18:35:24 +1000 |
commit | 4c5b1574f147fe2005bcd30bbb5dc106c4838b92 (patch) | |
tree | ce7fada27e54f793024e740add3e5779a2c63262 /pkg/commands/git_commands/submodule.go | |
parent | de57cfd6ff17751f7243476441beab6486fb4381 (diff) |
Centralise logic for obtaining repo paths
There are quite a few paths you might want to get e.g. the repo's path, the worktree's path,
the repo's git dir path, the worktree's git dir path. I want these all obtained once and
then used when needed rather than having to have IO whenever we need them. This is not so
much about reducing time spent on IO as it is about not having to care about errors every time
we want a path.
Diffstat (limited to 'pkg/commands/git_commands/submodule.go')
-rw-r--r-- | pkg/commands/git_commands/submodule.go | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/pkg/commands/git_commands/submodule.go b/pkg/commands/git_commands/submodule.go index 3d8602b9a..d9d1ccd20 100644 --- a/pkg/commands/git_commands/submodule.go +++ b/pkg/commands/git_commands/submodule.go @@ -139,7 +139,9 @@ func (self *SubmoduleCommands) Delete(submodule *models.SubmoduleConfig) error { self.Log.Error(err) } - return os.RemoveAll(filepath.Join(self.dotGitDir, "modules", submodule.Path)) + // We may in fact want to use the repo's git dir path but git docs say not to + // mix submodules and worktrees anyway. + return os.RemoveAll(filepath.Join(self.repoPaths.WorktreeGitDirPath(), "modules", submodule.Path)) } func (self *SubmoduleCommands) Add(name string, path string, url string) error { |