build: use gix to populate build envs#30
Conversation
Signed-off-by: tison <wander4096@gmail.com>
Signed-off-by: tison <wander4096@gmail.com>
| fn is_dirty(repo: &gix::Repository) -> Result<bool, gix::Error> { | ||
| let status_platform = repo | ||
| .status(gix::progress::Discard) | ||
| .map_err(gix::Error::from_error)?; | ||
| let status_iter = status_platform | ||
| .untracked_files(gix::status::UntrackedFiles::Collapsed) | ||
| .into_iter(None) | ||
| .map_err(gix::Error::from_error)?; | ||
| for item in status_iter { | ||
| let item = item.map_err(gix::Error::from_error)?; | ||
| let dirty = match item { | ||
| gix::status::Item::IndexWorktree(item) => match item { | ||
| gix::status::index_worktree::Item::Modification { .. } => true, | ||
| gix::status::index_worktree::Item::DirectoryContents { entry, .. } => { | ||
| matches!(entry.status, gix::dir::entry::Status::Untracked) | ||
| } | ||
| gix::status::index_worktree::Item::Rewrite { .. } => true, | ||
| }, | ||
| gix::status::Item::TreeIndex { .. } => true, | ||
| }; | ||
| if dirty { | ||
| return Ok(true); | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| Ok(false) |
There was a problem hiding this comment.
@Byron FYI this is where I come to GitoxideLabs/gitoxide#2583.
I wrote my own is_dirty to ensure that an untracked file can properly report dirty=true.
Not sure if there are any caveats (on iterating the status platform) I miss. And I'd like to know if it's desired to report as a downstream use case on the GitoxideLabs/gitoxide forum or anywhere else.
There was a problem hiding this comment.
Thanks for reeling me in.
I wonder why you had to implement your own instead of using gix::Repository::is_dirty().
Maybe there is a genuine bug to be fixed here?
There was a problem hiding this comment.
Yes I tried it. Let's move the discussion to a dedicated gix issue - GitoxideLabs/gitoxide#2587
There was a problem hiding this comment.
Not sure if there are any caveats (on iterating the status platform) I miss. And I'd like to know if it's desired to report as a downstream use case on the GitoxideLabs/gitoxide forum or anywhere else.
BTW is there a gallery I can submit this use case? Just want to show and tell with other gix users ><
There was a problem hiding this comment.
Code Review
This pull request replaces the shadow-rs crate with a custom build script implementation using gix to capture build-time metadata, such as Git branch, commit hash, and build timestamps. This change improves build reproducibility and reduces dependencies. The review identified a potential panic in scopeql/src/version.rs when splitting the commit hash, which has been addressed with a suggested fix.
| shadow-rs = { version = "2.0.0", default-features = false, features = [ | ||
| "build", | ||
| ] } | ||
| gix = { version = "0.83.0", default-features = false, features = ["sha1", "status"] } |
There was a problem hiding this comment.
@Byron BTW I'd like to know if I can eliminate more dependencies that are not in use.
Generally, they are build-time only deps, so it should be fine to add some. But given that gix provides small crates, I'd like to know whether I should use gix or combine the sub-crates myself. And if I use gix, how can I (or should I) opt out of code I don't need?
There was a problem hiding this comment.
gix is already built so that without features you get basic support for objects and refs, and nothing else. The idea is that with plumbing crates you won't save anything, unless you only use individual ones for specific use-cases.
You could take a look at the crates it pulls in and if these seem to be related to features you don't expect for status, then it could be considered a bug. However, I also recommend not to fixate on one or two crates that you think may not be needed because it's likely that they are and that not including them would also not save time meaningfully.
Overall, I think you can save the time, but looking into it might reveal genuine things to improve, which is always appreciated.
There was a problem hiding this comment.
Thanks for your advice! I'm fine with the current status then.
Signed-off-by: tison <wander4096@gmail.com>
No description provided.