Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Insufficient information in --version to distinguish between release and development instances #922

Closed
zancas opened this issue Oct 27, 2021 · 6 comments · Fixed by #957
Closed
Labels
A-packaging Area: Packaging and bundling C-bug Category: This is a bug

Comments

@zancas
Copy link
Contributor

zancas commented Oct 27, 2021

Reproduction steps

  1. Build helix from source.

  2. Invoke helix --version against the instance built from source, e.g.:

${GITREPO_ROOT}/target/debug/hx --version
helix 0.4.1
  1. Invoke helix --version against the instance installed from a release, e.g. (on Arch):
/usr/bin/helix --version
helix 0.4.1

Fix:
Make --version report more specific version information, perhaps:

$(RELEASETAG)-$(BUILD_CANDIDATE)_$(10CHARSBUILDHASH)

e.g.

0.4.1-rc1-8442e653f5

for a development build instance, and:

0.4.1 for a released instance.

@zancas zancas added the C-bug Category: This is a bug label Oct 27, 2021
@pickfire
Copy link
Contributor

I wanted to do that originally but then decided that it is easier to just ask the developer to report it himself using git describe.

@EpocSquadron
Copy link
Contributor

I don't think relying on git describe is enough. In my case for instance I build from the helix-git AUR package in a temporary directory (exists in memory, goes away after reboot if I don't rm -rf it manually). The version number encoded by the package is nonsense in order to make it always report out of date, since it is a vcs package. Thus I have no way of figuring out the exact commit from which I built helix. (I have a different machine where I build from source manually and run the editor with cargo run rather than a package, but that's just for working on the editor itself)

We could request the packager make the commit sha the package version instead, but that only fixes one case, and probably isn't totally clear to implement. I think as helix gets more popular more such edge cases will appear.

@archseer
Copy link
Member

@pickfire Looks like we could do this in build.rs without complicated proc macros, what was the problem with this again? I remember there was some issues:

// build.rs
use std::process::Command;
fn main() {
    // note: add error checking yourself.
    let output = Command::new("git").args(&["rev-parse", "--short", "HEAD"]).output().unwrap();
    let git_hash = String::from_utf8(output.stdout).unwrap();
    println!("cargo:rustc-env=GIT_HASH={}", git_hash);
}

// main.rs
fn main() {
    println!("{}", env!("GIT_HASH"));
    // output something like:
    // 7480b50f3c75eeed88323ec6a718d7baac76290d
}

@archseer
Copy link
Member

(needs some error checking so we fallback to "" if the code is not part of a git repository)

@archseer
Copy link
Member

The version number encoded by the package is nonsense in order to make it always report out of date, since it is a vcs package.

It's good practice to include the git sha in the pkgver: https://wiki.archlinux.org/title/VCS_package_guidelines#The_pkgver()_function

@pickfire
Copy link
Contributor

pickfire commented Oct 30, 2021

@pickfire Looks like we could do this in build.rs without complicated proc macros, what was the problem with this again? I remember there was some issues:

I did what you did there. Also, note that we may want git describe --dirty (the dirty part) since we don't know whether or not files are changed locally.

I find git describe --dirty useful because it can show us which commit is it and how far is it from the last tag. And with --dirty we know if they applied some patches.

@kirawi kirawi added the A-packaging Area: Packaging and bundling label Oct 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-packaging Area: Packaging and bundling C-bug Category: This is a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants