Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] - whole path name is included when specifying a file with a target #158

Open
ekarious opened this issue Jun 16, 2024 · 5 comments
Open
Labels
bug Something isn't working

Comments

@ekarious
Copy link

Describe the bug
Bug to the path of uploaded files

To Reproduce
When You have a structure like this:

dotfiles
   windows
      alacritty.toml
profiles
   windows.yaml

and windows.yaml file like this:

target: "C:\\Users\\Yann\\Desktop\\test_dotfiles"

dotfiles:
  - path: windows/alacritty.toml
    target:
      path: "C:\\Users\\Yann\\Desktop\\test_dotfiles\\alacritty.toml"
    template: false

The problem is the file is sent to this path:

C:\Users\Yann\Desktop\test_dotfiles\windows\alacritty.toml

The windows in the path should not be included.

Expected behavior
This should be the correct path:

C:\Users\Yann\Desktop\test_dotfiles\alacritty.toml

Desktop (please complete the following information):

  • OS: Windows 10
  • Version 22H2

Additional Infos
I have set the Env Variable:
PUNKTF_SOURCE = C:\Users\Yann\.dotfiles

@ekarious ekarious added the bug Something isn't working label Jun 16, 2024
@ekarious
Copy link
Author

ekarious commented Jun 16, 2024

If I add a rename to the dotfiles element, I can remove the windows from the path.
But it should not be necessary when the target path is specified.

@ekarious ekarious changed the title [BUG] - Parent folder path is included when specifying a file [BUG] - whole path name is included when specifying a file with a target Jun 16, 2024
@Shemnei
Copy link
Owner

Shemnei commented Jul 16, 2024

Hey @ekarious thanks for reporting this and sorry for the very late response.
What you describe, is indeed a bug and the rename workaround should not be necessary.
I will take a look if i can reproduce this and then fix it.

@Shemnei
Copy link
Owner

Shemnei commented Jul 16, 2024

Had a quick look and found a few issues:

Unused field

In your example you have the field target.path set for a dotfile. This field does not exist on a dotfile, the field meant to be used for this is overwrite_target.

Currently punktf will only return an error about unused/unknown variables if they are on the profile level, all "sublevel" (e.g. dotfiles) are not checked.

This is a bug and i will fix it.

Rename

I don't if your example is representative of your actual profile, but if it is, i would suggest to actually use rename:

target: "C:\\Users\\Yann\\Desktop\\test_dotfiles"

dotfiles:
  - path: windows/alacritty.toml
    rename: "alacritty.toml"
    template: false

This should deploy the file to the default profile.target with the name/relative path alacritty.toml.

Overwrite Target

While looking through the code for the path resolution, i also noticed that even if you would have used overwrite_target, it would not have worked.
I think you are correct with our assumption of how this value should work and will adjust it in this way, also i no longer like the original name of overwrite_target and will rename it to target instead (will probably keep the old name around for backwards compatibility).

After i implement all these changes your given example should almost work in the way you described/expected it to work.

target: "C:\\Users\\Yann\\Desktop\\test_dotfiles"

dotfiles:
  - path: windows/alacritty.toml
    target: "C:\\Users\\Yann\\Desktop\\test_dotfiles\\alacritty.toml"
    template: false

Thank you very much for the feedback/report 😄

@Shemnei
Copy link
Owner

Shemnei commented Jul 16, 2024

I will keep you updated but it might take a few days for me to implement all of that

@ekarious
Copy link
Author

Thank you very much for the response.
Glad I could help you enhanced it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants