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

Sub-package tag parsing breaks Windows path parsing in v2.1.0 #164

Closed
doug-fitzmaurice-rowden opened this issue Jul 31, 2024 · 1 comment · Fixed by #165
Closed

Sub-package tag parsing breaks Windows path parsing in v2.1.0 #164

doug-fitzmaurice-rowden opened this issue Jul 31, 2024 · 1 comment · Fixed by #165

Comments

@doug-fitzmaurice-rowden
Copy link
Contributor

doug-fitzmaurice-rowden commented Jul 31, 2024

The feature to infer sub-package tags introduced in #161 and released in 2.1.0 breaks the default behaviour of the tool on Windows systems.

The features compares the root of the git repo to the current directory, and if they are not the same sets --pattern and --prefix defaults automatically to compensate.
However it appears that the git cli and the go os library return representations of the same path using different path separators, so the comparison always returns false, and the absolute path of the repo is set as the pattern.

The issue occurs both in the root of a git repo and in a subdirectory, and causes all tag parsing to fail. Normal behaviour can be restored by adding the old defaults back in on the CLI:

svu --pattern="" --prefix="v"

I think that using filepath.Clean() on both paths before using them should normalise the slashes and resolve this issue, though I can't test as I don't have a working golang setup on my Windows machine, and testing on Linux is inconclusive as filepath.Clean behaviour is platform-dependent.

Example:

> git rev-parse --show-toplevel
C:/Users/Doug/Code/myrepo
os.getWd()
C:\\Users\\Doug\\Code\\myrepo

This results in the following help text showing the defaults when running svu:

> svu -h
usage: svu [<flags>] <command> [<args> ...]

...snip....

      --pattern="C:\\Users\\Doug\\Code\\myrepo/*"
                                 limits calculations to be based on tags
                                 matching the given pattern
      --prefix="C:\\Users\\Doug\\Code\\myrepo/v"
                                 set a custom prefix
@caarlos0
Copy link
Owner

caarlos0 commented Aug 7, 2024

i don't use windows, happy to review a pr fixing this though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants