open-telemetry / opentelemetry-go-build-tools

Build tools for use by the Go API/SDK, the collector, and their associated contrib repositories
https://opentelemetry.io
Apache License 2.0
32 stars 35 forks source link

semconvgen: panic: unable to exe when specification version is set #41

Open MrAlias opened 2 years ago

MrAlias commented 2 years ago
$ .tools/semconvgen -i ~/code/opentelemetry-specification/semantic_conventions/resource -s "v1.7.0" -t semconv/template.j2
panic: unable to exec /usr/bin/git worktree add /tmp/otel_semconvgen1125124/input v1.7.0: exit status 128

goroutine 1 [running]:
main.main()
    /home/tyler/go/pkg/mod/go.opentelemetry.io/build-tools/semconvgen@v0.0.0-20210920164323-2ceabab23375/generator.go:59 +0x42e

Version: go.opentelemetry.io/build-tools/semconvgen v0.0.0-20210920164323-2ceabab23375

MrAlias commented 2 years ago

Seems to have been caused because the v1.7.0 tag was checked out to a v1.7.0 branch in the specification repository (git checkout tags/v1.7.0 -b v1.7.0).

Ideally this wouldn't be panic.

pellared commented 1 year ago

I think the proper fix is to improve the error handling and tell that git worktree add failed. Maybe the command is emitting something to stdout/stderr that is worth printing? I would not like to run worktree add with -f flag, because it can be dangerous as it will create a "linked worktree" that will modify the existing one.