Skip to content
This repository has been archived by the owner on Jan 14, 2023. It is now read-only.

add git commit hash to version #116

Merged
merged 1 commit into from
Nov 1, 2020
Merged

add git commit hash to version #116

merged 1 commit into from
Nov 1, 2020

Conversation

benmkw
Copy link
Contributor

@benmkw benmkw commented Oct 31, 2020

as discussed on matrix this may be helpful for user bug reports

I could not find a way to format the string at compile time in which
case I could have used something like:
#[structopt(version = git_version::git_version!() + .... )]

output:

$ cargo run - --version
cargo-embed 0.9.1
git commit: baca8ba

If you want to do the cargo update stuff separately I can also adjust after thats done.

Tested on macos only.

as discussed on matrix this may be helpful for user bug reports

I could not find a way to format the string at compile time in which
case I could have used something like:
`#[structopt(version = git_version::git_version!() + ... )]`

output:
$ cargo run - --version
cargo-embed 0.9.1
git commit: baca8ba
@@ -28,8 +28,14 @@ use probe_rs::{
use probe_rs_cli_util::build_artifact;
use probe_rs_rtt::{Rtt, ScanRegion};

const CARGO_NAME: &'static str = env!("CARGO_PKG_NAME");
Copy link
Member

Choose a reason for hiding this comment

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

Why not add those constants to the cli-util lib? :) I think that should work and then we can also add this to cargo-flash? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

does not seem to work for git_version

$ git status 
On branch version
nothing to commit, working tree clean

$ git rev-parse --short HEAD
e0104b6

$ cargo run - --version  
probe-rs-cli-util 0.9.0
git commit: v0.5.1-467-g7b33b4b-modified

I don't even see where 0.5.1 comes from :/ but both cargo env variable and git_version do the wrong thing or maybe phrased more accurately are used in a way they were not meant to be ;)

We can still add it to cargo flash as well though, just copy pasting :D

Copy link
Member

Choose a reason for hiding this comment

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

Yeah sounds good to me :) Do this now, possibly improve later :)

Copy link
Member

@Yatekii Yatekii left a comment

Choose a reason for hiding this comment

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

bors r+

@bors
Copy link
Contributor

bors bot commented Nov 1, 2020

@bors bors bot merged commit 325f888 into probe-rs:master Nov 1, 2020
benmkw added a commit to benmkw/cargo-flash that referenced this pull request Jan 10, 2021
same as probe-rs/cargo-embed#116

output:
cargo-flash 0.10.2
git commit: db4e2c3
bors bot added a commit to probe-rs/cargo-flash that referenced this pull request Jan 10, 2021
155: add git commit hash to version r=Yatekii a=benmkw

same as probe-rs/cargo-embed#116

output:
```
cargo-flash 0.10.2
git commit: db4e2c3
```

I scrolled though matrix and saw this was still needed :) 

(this was not put into probe-rs-cli-util because it would then use the wrong commit hash iirc)

Co-authored-by: Benedikt Mandelkow <[email protected]>
Yatekii pushed a commit to probe-rs/probe-rs that referenced this pull request Jan 13, 2023
same as probe-rs/cargo-embed#116

output:
cargo-flash 0.10.2
git commit: db4e2c3
Yatekii pushed a commit to probe-rs/probe-rs that referenced this pull request Jan 13, 2023
155: add git commit hash to version r=Yatekii a=benmkw

same as probe-rs/cargo-embed#116

output:
```
cargo-flash 0.10.2
git commit: db4e2c3
```

I scrolled though matrix and saw this was still needed :) 

(this was not put into probe-rs-cli-util because it would then use the wrong commit hash iirc)

Co-authored-by: Benedikt Mandelkow <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants