#![forbid(unsafe_code)]
#![allow(
clippy::doc_markdown,
reason = "GitCode is a platform brand name, not a Rust code item"
)]
#![cfg_attr(
test,
allow(
clippy::expect_used,
clippy::unwrap_used,
clippy::indexing_slicing,
clippy::useless_format,
clippy::clone_on_copy,
reason = "Tests legitimately need to unwrap fixture data and index into known-shape \
collections"
)
)]
pub mod auth;
pub mod commit;
pub mod error;
pub mod issue;
pub mod label;
pub mod pipeline;
pub mod pr;
pub mod release;
pub mod review;
pub mod runner;
pub use auth::GitCodeAuthProvider;
pub use commit::GitCodeCommitProvider;
pub use error::parse_gitcode_error;
pub use issue::GitCodeIssueProvider;
pub use label::{GitCodeLabelProvider, GitCodeMilestoneProvider};
pub use pipeline::GitCodePipelineProvider;
pub use pr::GitCodePrProvider;
pub use release::GitCodeReleaseProvider;
pub use review::GitCodeReviewProvider;
#[allow(
clippy::disallowed_methods,
reason = "binary discovery runs at startup before async runtime is ready"
)]
pub(crate) fn gitcode_binary() -> String {
const CANDIDATES: &[&str] = &["gc", "gitcode"];
for &candidate in CANDIDATES {
if let Ok(p) = which::which(candidate) {
return p.to_string_lossy().into_owned();
}
}
if let Ok(home) = std::env::var("HOME") {
for &candidate in CANDIDATES {
let lib = std::path::PathBuf::from(&home).join("Library/Python");
if let Ok(entries) = std::fs::read_dir(&lib) {
for entry in entries.flatten() {
let p = entry.path().join("bin").join(candidate);
if p.exists() {
return p.to_string_lossy().into_owned();
}
}
}
let p = std::path::PathBuf::from(&home)
.join(".local/bin")
.join(candidate);
if p.exists() {
return p.to_string_lossy().into_owned();
}
}
}
"gc".into()
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_should_return_non_empty_binary_name() {
let binary = gitcode_binary();
assert!(!binary.is_empty());
}
}