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

feat: try to infer sub-package tag #161

Merged
merged 1 commit into from
Jul 10, 2024
Merged

Conversation

aymanbagabas
Copy link
Contributor

This adds support for inferring a sub-package version by trying to predict the sub-package tag using the current directory and Git root path.

For example, running svu in a Go mono-repository with multiple packages won't return the correct tag since it won't be able to parse the latest tag ansi/v0.1.2.

This PR initializes the --prefix and --pattern when the current directory doesn't match the Git root making svu work without the need to specify svu --prefix="ansi/v" --pattern="ansi/*" ....

P.S. maybe there's a cleaner way of doing so 🤔

Previously I had this little shell func

function get-next-version() {
  root=$(git rev-parse --show-toplevel)
  if [ "$PWD" != "$root" ]; then
    local prefix=$(echo -n "$PWD" | sed "s|$root/||g")
    svu --prefix="$prefix/v" --pattern="$prefix/*" "$@"
  else
    svu "$@"
  fi
}

This adds support for inferring a sub-package version by trying to
predict the sub-package tag using the current directory and Git root
path.

For example, running `svu` in a Go mono-repository with multiple
packages won't return the correct tag since it won't be able to parse
the latest tag `ansi/v0.1.2`.

This PR initializes the `--prefix` and `--pattern` when the current
directory doesn't match the Git root making `svu` work without the need
to specify `svu --prefix="ansi/v" --pattern="ansi/*" ...`.

P.S. maybe there's a cleaner way of doing so 🤔

Previously I had this little shell func
```sh
function get-next-version() {
  root=$(git rev-parse --show-toplevel)
  if [ "$PWD" != "$root" ]; then
    local prefix=$(echo -n "$PWD" | sed "s|$root/||g")
    svu --prefix="$prefix/v" --pattern="$prefix/*" "$@"
  else
    svu "$@"
  fi
}
```

Signed-off-by: Ayman Bagabas <[email protected]>
@caarlos0 caarlos0 merged commit 680777b into caarlos0:main Jul 10, 2024
1 check passed
This was referenced Aug 8, 2024
caarlos0 added a commit that referenced this pull request Aug 24, 2024
@caarlos0
Copy link
Owner

reverted this for now

aymanbagabas added a commit to aymanbagabas/dotfiles that referenced this pull request Sep 10, 2024
aymanbagabas added a commit to aymanbagabas/dotfiles that referenced this pull request Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants