()
| 4653 | } |
| 4654 | |
| 4655 | fn 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 | |
| 4676 | fn github_u64(payload: &serde_json::Value, path: &[&str]) -> Option<u64> { |
| 4677 | let mut cursor = payload; |
no test coverage detected