Skip to content

Commit

Permalink
Tidy up path handling
Browse files Browse the repository at this point in the history
  • Loading branch information
twpayne committed Apr 21, 2021
1 parent bdab05d commit b9dcd48
Show file tree
Hide file tree
Showing 26 changed files with 297 additions and 179 deletions.
2 changes: 1 addition & 1 deletion cmd/applycmd.go
Expand Up @@ -34,7 +34,7 @@ func (c *Config) newApplyCmd() *cobra.Command {
}

func (c *Config) runApplyCmd(cmd *cobra.Command, args []string) error {
return c.applyArgs(c.destSystem, c.destDirAbsPath, args, applyArgsOptions{
return c.applyArgs(c.destSystem, c.DestDirAbsPath, args, applyArgsOptions{
include: c.apply.include.Sub(c.apply.exclude),
recursive: c.apply.recursive,
umask: c.Umask,
Expand Down
2 changes: 1 addition & 1 deletion cmd/catcmd.go
Expand Up @@ -32,7 +32,7 @@ func (c *Config) runCatCmd(cmd *cobra.Command, args []string, sourceState *chezm

sb := strings.Builder{}
for _, targetRelPath := range targetRelPaths {
targetStateEntry, err := sourceState.MustEntry(targetRelPath).TargetStateEntry(c.destSystem, c.destDirAbsPath.Join(targetRelPath))
targetStateEntry, err := sourceState.MustEntry(targetRelPath).TargetStateEntry(c.destSystem, c.DestDirAbsPath.Join(targetRelPath))
if err != nil {
return fmt.Errorf("%s: %w", targetRelPath, err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/cdcmd.go
Expand Up @@ -33,5 +33,5 @@ func (c *Config) runCDCmd(cmd *cobra.Command, args []string) error {
if shellCommand == "" {
shellCommand, _ = shell.CurrentUserShell()
}
return c.run(c.sourceDirAbsPath, shellCommand, c.CD.Args)
return c.run(c.SourceDirAbsPath, shellCommand, c.CD.Args)
}
8 changes: 4 additions & 4 deletions cmd/chattrcmd.go
Expand Up @@ -101,8 +101,8 @@ func (c *Config) runChattrCmd(cmd *cobra.Command, args []string, sourceState *ch
switch sourceStateEntry := sourceStateEntry.(type) {
case *chezmoi.SourceStateDir:
if newBaseNameRelPath := chezmoi.RelPath(am.modifyDirAttr(sourceStateEntry.Attr).SourceName()); newBaseNameRelPath != fileRelPath {
oldSourceAbsPath := c.sourceDirAbsPath.Join(parentRelPath, fileRelPath)
newSourceAbsPath := c.sourceDirAbsPath.Join(parentRelPath, newBaseNameRelPath)
oldSourceAbsPath := c.SourceDirAbsPath.Join(parentRelPath, fileRelPath)
newSourceAbsPath := c.SourceDirAbsPath.Join(parentRelPath, newBaseNameRelPath)
if err := c.sourceSystem.Rename(oldSourceAbsPath, newSourceAbsPath); err != nil {
return err
}
Expand All @@ -111,8 +111,8 @@ func (c *Config) runChattrCmd(cmd *cobra.Command, args []string, sourceState *ch
// FIXME encrypted attribute changes
// FIXME when changing encrypted attribute add new file before removing old one
if newBaseNameRelPath := chezmoi.RelPath(am.modifyFileAttr(sourceStateEntry.Attr).SourceName(encryptedSuffix)); newBaseNameRelPath != fileRelPath {
oldSourceAbsPath := c.sourceDirAbsPath.Join(parentRelPath, fileRelPath)
newSourceAbsPath := c.sourceDirAbsPath.Join(parentRelPath, newBaseNameRelPath)
oldSourceAbsPath := c.SourceDirAbsPath.Join(parentRelPath, fileRelPath)
newSourceAbsPath := c.SourceDirAbsPath.Join(parentRelPath, newBaseNameRelPath)
if err := c.sourceSystem.Rename(oldSourceAbsPath, newSourceAbsPath); err != nil {
return err
}
Expand Down

0 comments on commit b9dcd48

Please sign in to comment.