Skip to content

feat: try to infer sub-package tag#161

Merged
caarlos0 merged 1 commit intocaarlos0:mainfrom
aymanbagabas:sub-pkg
Jul 10, 2024
Merged

feat: try to infer sub-package tag#161
caarlos0 merged 1 commit intocaarlos0:mainfrom
aymanbagabas:sub-pkg

Conversation

@aymanbagabas
Copy link
Copy Markdown
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 <ayman.bagabas@gmail.com>
@caarlos0
Copy link
Copy Markdown
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