haskell / cabal

Official upstream development repository for Cabal and cabal-install
https://haskell.org/cabal
Other
1.62k stars 697 forks source link

RFC: Include Git SHA in `cabal --version` for debug builds #8984

Open ulysses4ever opened 1 year ago

ulysses4ever commented 1 year ago

Do you think it'd be desirable to include SHA-hash into the --version info? With the rolling prerelease it may be hard to figure what exactly is included in your binary. But even with released artifacts it may be reassuring to know the exact revision. EDIT. I guess releases are always tagged in the repo, so this makes less sense there. Also, it’d probably work nicely for nightly releases if we ever get there (#8932).

There are various ways to do that. One, Haskell-based way goes via template-haskell (see packages like gitrev or githash). cabal-install does not depend on TH currently. Would it be an issue to add such a dependency?

ffaf1 commented 1 year ago

Very useful for prereleases! I am not sure about released artifacts: they are signed already and moreover tagged in the source repository.

jneira commented 1 year ago

maybe not fancy but what about naming the cabal binary produced by the new workflow cabal-<commit> instead cabal-head? it seems it would not be too difficult

I usually do that renaming by hand.

ulysses4ever commented 1 year ago

@ffaf1

I am not sure about released artifacts: they are signed already and moreover tagged in the source repository.

Signatures are meant for security purposes. The --version is for a lay person inquiring which exactly binary they're using. I have no idea how to use signatures (and I certainly didn't download my cabal from the Downloads page where the signatures are hosted: it comes either from ghcup or nixpkgs).

The fact that the repo has tags is in theory sufficient but not very handy.

ulysses4ever commented 1 year ago

@jneira

maybe not fancy but what about naming the cabal binary produced by the new workflow cabal- instead cabal-head? it seems it would not be too difficult

It'd not be difficult, indeed, but then the info is very easy to loose.

Also, note that currently the binary you download from that workflow is called cabal and the archive it's wrapped in is called cabal-head. There's a certain aesthetic pleasing in having it simply named cabal. E.g., the user can move it to ~/.local/bin and use it as a replacement of any other cabal they have. Of course, if we implement your idea and have it named cabal-sha..., they can rename it to cabal, but then, again, the information is lost forever...

ulysses4ever commented 1 year ago

I'm thinking that if we want the SHA only in debug builds, we could probably have a flag for the template-haskell dependency and set it only in debug builds.

jneira commented 1 year ago

yeah, i suggested it as a quick way to encode the info in the name itself, but no as alternative to set it in cabal version i prefer to test ephemeral versions with the full name of the executable and keep "cabal" for the default stable cabal installed with ghcup for regular use so add the commit fits my workflow, maybe it does not fit other ones of course

fgaz commented 1 year ago

Would this make sdists unbuildable?

ulysses4ever commented 1 year ago

@fgaz do you mean that there may be no git info around? It certainly can be handled in a gracious way. See e.g. tGitInfoCwdTry in githash.

ulysses4ever commented 1 year ago

I’m scaling down the scope of the RFC to debug / non-release builds only.

Kleidukos commented 1 year ago

I approve