odeke-em/drive

`drive version` should report git's short commit hash

l3iggs opened this issue · 10 comments

`drive version` should report git's short commit hash

I don't know what to think about this, this will be coupling too much of git with drive of which I might be bound to forget during dev. Might be helpful for debugging otherwise.

One example of another project that does this is docker:

$ docker version
Client version: 1.5.0
Client API version: 1.17
Go version (client): go1.4.1
Git commit (client): a8a31ef
OS/Arch (client): linux/amd64
Server version: 1.5.0
Server API version: 1.17
Go version (server): go1.4.1
Git commit (server): a8a31ef

For sure. I'll have to hard code it, which is what I am worried about forgetting.

Never mind my last comment, I think I've conjured a way to solve this without any hard coding . I'll do this when I get back home.

Please checkout PR #144

kcwu commented

The git hash reported by 'drive about' is dynamically detected.
I mean, the hash is not related to the running binary.

For example,

  1. run 'drive about'
  2. git pull # get new code, but don't build
  3. run 'drive about' again

The result git hash of step 1 and 3 are different. But the 'drive' binary actually doesn't change. This may give misleading information for advanced users.

docker solves this problem using additional build script.
https://github.com/docker/docker/blob/master/hack/make/.go-autogen

For pure go solution, https://blog.golang.org/generate may be useful. However, it requires go 1.4

That is true, it just selects the most recent hash. For starters, the average user (at least from the interactions I've had) will not be building drive frequently. Thank you, I'll take a look at Docker's solution

Just saw Docker's solution: ahaha I had an initial solution exactly like theirs before but figured it would not work for our build currently.

See none of those solutions will work directly. Another solution that I had was a packager for drive, that would build the binary and get the hash right then.

Please help me take a look at #151, if you can.
Thank you.

You can now do

$ go get github.com/odeke-em/drive/drive-gen && drive-gen