MCPcopy Create free account
hub / github.com/ChrisFeldmeier/OpenCodeRust / github_repo_from_env_or_git

Function github_repo_from_env_or_git

crates/opencode-cli/src/main.rs:4655–4674  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4653}
4654
4655fn github_repo_from_env_or_git() -> anyhow::Result<(String, String)> {
4656 if let Ok(repo) = std::env::var("GITHUB_REPOSITORY") {
4657 if let Some((owner, name)) = repo.split_once('/') {
4658 if !owner.is_empty() && !name.is_empty() {
4659 return Ok((owner.to_string(), name.to_string()));
4660 }
4661 }
4662 }
4663
4664 let remote = ProcessCommand::new("git")
4665 .args(["remote", "get-url", "origin"])
4666 .output()
4667 .map_err(|e| anyhow::anyhow!("Failed to read git origin remote: {}", e))?;
4668 if !remote.status.success() {
4669 anyhow::bail!("Could not resolve GitHub repository from env or git remote.");
4670 }
4671 let remote_url = String::from_utf8_lossy(&remote.stdout).trim().to_string();
4672 parse_github_remote(&remote_url)
4673 .ok_or_else(|| anyhow::anyhow!("Unsupported GitHub remote URL format: {}", remote_url))
4674}
4675
4676fn github_u64(payload: &serde_json::Value, path: &[&str]) -> Option<u64> {
4677 let mut cursor = payload;

Callers 1

handle_github_commandFunction · 0.85

Calls 5

newFunction · 0.85
parse_github_remoteFunction · 0.85
is_emptyMethod · 0.80
outputMethod · 0.80
successMethod · 0.45

Tested by

no test coverage detected