Conversation
|
When running on MacOS |
🦙 MegaLinter status:
|
| Descriptor | Linter | Files | Fixed | Errors | Warnings | Elapsed time |
|---|---|---|---|---|---|---|
| ✅ ACTION | actionlint | 3 | 0 | 0 | 0.02s | |
| ✅ JSON | jsonlint | 3 | 0 | 0 | 0.13s | |
| ✅ JSON | prettier | 3 | 0 | 0 | 0 | 0.33s |
| markdownlint | 6 | 0 | 4 | 0 | 0.56s | |
| ✅ MARKDOWN | markdown-link-check | 6 | 0 | 0 | 3.33s | |
| ✅ MARKDOWN | markdown-table-formatter | 6 | 0 | 0 | 0 | 0.19s |
| ✅ RUST | clippy | yes | no | no | 49.32s | |
| ✅ YAML | prettier | 5 | 0 | 0 | 0 | 0.36s |
| ✅ YAML | yamllint | 5 | 0 | 0 | 0.4s |
See detailed report in MegaLinter reports
For the first line we'll need to sub in whatever the path to the git folder is based on the find_parent() function. As for the second, you'll need something like that, but it might need adjusting for Mac. The linker script is there to ensure that the section is always included in the binary, even if you don't reference it in your code (otherwise the linker throws it away) |
|
@doublebasil |
#[cfg(not(target_os = "macos"))] |
|
Need to investigate further into Mac Linkers and making sure we link correclty. There seems to be no command line option for declaring this... |
|
@petekubiak I believe this works but im unsure how I can get the git_path and put it into build.rs for example: within lib.rs fn find_valid_git_root(mut path: &str) -> Result<Repository, Error> {
let mut depth = 0;
loop {
depth += 1;
// Find last path separator position
let pos_slash = path.rfind('/');
let pos_backslash = path.rfind('\\');
let last = match (pos_slash, pos_backslash) {
(Some(s), Some(b)) => core::cmp::max(s, b),
(Some(s), None) => s,
(None, Some(b)) => b,
(None, None) => break, // Reached the top level
};
// Take the parent part
path = &path[..last];
// If this is a valid repository return it otherwise keep going
if let Ok(repo) = Repository::open(path) {
// Tell build.rs what the path is?
return Ok(repo);
}
}
Err(Error::new(
Span::call_site(),
format!("failed to find .git folder after {depth} parents"),
))
}Theres that function ^. However in build.rs I was going to an env variable to get the GIT_DIR But then I cant use env inside the crate because its |
|
I think I'd need to have a proper chat with you to understand the issue. Let's catch up on Monday :) |
Co-authored-by: petekubiak <37507920+petekubiak@users.noreply.github.com>
petekubiak
left a comment
There was a problem hiding this comment.
Couple minor tweaks - thanks for your work on this!
Co-authored-by: petekubiak <37507920+petekubiak@users.noreply.github.com>
Co-authored-by: petekubiak <37507920+petekubiak@users.noreply.github.com>
Co-authored-by: petekubiak <37507920+petekubiak@users.noreply.github.com>

Description
This PR Aims to add the ability for cargo metadata to handle git repos in which the cargo.toml file is in a subdirectory. It also aims to test out the cargo metadata functionality inside Docker, Balena and MacOS
Type of change
Please Tick the options that are relevant.
How Has This Been Tested?
Tested on MacOS
Your Specific Test Case
Checklist