baoyachi / shadow-rs

A build-time information stored in your rust project.(binary,lib,cdylib,dylib)
https://docs.rs/shadow-rs
MIT License
444 stars 40 forks source link

Try use gix to replace git2 #162

Closed tisonkun closed 1 month ago

tisonkun commented 1 month ago

gix has less dependencies and may have better performance.

I use this crate and notice the dependency of git2 naughty ..

Perhaps I can find some time to give it a try.

cc @Byron

tisonkun commented 1 month ago

Major Git infos:

    println!("{}", build::BRANCH); //master
    println!("{}", build::SHORT_COMMIT);//8405e28e
    println!("{}", build::COMMIT_HASH);//8405e28e64080a09525a6cf1b07c22fcaf71a5c5
    println!("{}", build::COMMIT_DATE);//2021-08-04 12:34:03 +00:00
    println!("{}", build::COMMIT_AUTHOR);//baoyachi
    println!("{}", build::COMMIT_EMAIL);//xxx@gmail.com
    println!("{}", build::GIT_CLEAN);//false
    println!("{}", build::GIT_STATUS_FILE);//* src/lib.rs (dirty)
Byron commented 1 month ago

Please note that there is a tracking issue and once the last feature (diffing HEAD with the index) is available, I have already planned to add gix as option next to using the git CLI and git2.

Personally I found using git (CLI) nice in build scripts as it can save a lot of build-time on CI if the project isn't also using gix.

tisonkun commented 1 month ago

Personally I found using git (CLI) nice in build scripts as it can save a lot of build-time on CI if the project isn't also using gix.

Yes. Maybe calling a command is an option, as long as they are not as time-consuming as we were facing in hawkeye to check all the ignored file ..

baoyachi commented 1 month ago

The reason why shadow-rs uses git is because it has fewer dependencies and is built faster.

tisonkun commented 1 month ago

Git CLI is still different from git2. git2 doesn't reduce dependencies too much and you should still compile the -sys crate.

baoyachi commented 1 month ago

I am very willing to accept PR if it can achieve the same effect while reducing dependence. @tisonkun

Byron commented 1 month ago

@tisonkun I think the reason to support gitoxide here is to provide another option for projects that…

(the points above aren't necessarily mutually exclusive)

This doesn't mean gitoxide is better or worse, it's pros and cons depending on the usecase. Thus it's not here to replace any of the other options or be a 'successor'.

baoyachi commented 1 month ago

@tisonkun By the way,git2 crate dependence are not necessary . shadow-rs can achieve the same effect using the git command. E.g:

[dependencies]
shadow-rs = { version="0.29.0", default-features = false, features = ["tzdb"] }

See detail:https://github.com/baoyachi/shadow-rs/blob/4eabcda5debb838fe8d0ac1150c51c11fe7b82fb/example_wasm/Cargo.toml#L12-L13



baoyachi commented 1 month ago

It looks like it can be closed now.