bufbuild / buf

The best way of working with Protocol Buffers.
https://buf.build
Apache License 2.0
8.67k stars 257 forks source link

Git inputs cannot reference tags with the ref option #2932

Closed mloesch closed 1 day ago

mloesch commented 2 months ago

As far as I understand, git branches and tags are types of git refs (they are stored under .git/refs).

IMO it should therefore be possible to use the ref option as a generic way for referencing commits, branches, and tags.

This is actually stated in the documentation:

Any ref that is a valid input to git checkout is accepted.

https://buf.build/docs/reference/inputs#other-options

However, while git checkout remote-tag is working, buf generate "ssh://git@github.com/path-to-repo.git#ref=remote-tag" is not.

IMO this feature would make parameterizing CI pipelines easier, e.g.:

Note: this is also how kubectl kustomize is implementing the refoption:

ref - a git fetch-able ref, typically a branch, tag, or full commit hash (short hashes are not supported)

https://github.com/kubernetes-sigs/kustomize/blob/master/examples/remoteBuild.md#remote-directories

srikrsna-buf commented 2 months ago

I can reproduce this with:

buf build "https://github.com/bufbuild/buf.git#ref=v1.27.0,subdir=proto"

The same works when I use tag:

buf build "https://github.com/bufbuild/buf.git#tag=v1.27.0,subdir=proto"

Thank you for reporting, we'll look into this.

emcfarlane commented 1 day ago

Fix will go out in the next release.