Skip to content

Adding --verbose flag to check commit hash #4568

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

DanKhaitov
Copy link

This PR adds a --verbose flag to the gleam --version command. When used, it will include the current git commit hash in the output.

Usage

$ gleam --version
1.0.0

$ gleam --version --verbose
1.0.0 (commit abc1234)

Closes #4544

Copy link
Member

@lpil lpil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I've left a couple comments on the code here, but I don't think we have agreed on a design yet so let's go back to the issue and discuss it prior to implementing anything further.

.filter(|s| !s.is_empty())
.unwrap_or_else(|| "unknown".to_string());

println!("cargo:rustc-env=GIT_COMMIT_HASH={}", commit_hash);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a huge fan of shelling out to run a program each time. We could do something like this perhaps

const GIT_SHA: &str = if include_str!("../../.git/HEAD") == "ref: refs/heads/main" {
  include_str!("../../.git/refs/heads/main")
} else {
  include_str!("../../.git/HEAD")
}

styles = Styles::styled()
.header(styling::AnsiColor::Yellow.on_default())
.usage(styling::AnsiColor::Yellow.on_default())
.literal(styling::AnsiColor::Green.on_default())
)]
struct Cli {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No abbreviations please

}
},
None => {
println!("Use `gleam --help` to see available commands.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking change! No other functionality must change

@lpil lpil marked this pull request as draft May 7, 2025 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Gleam version with git hash
2 participants