(
owner: &str,
repo: &str,
pr_number: u64,
token: Option<&str>,
)
| 4876 | } |
| 4877 | |
| 4878 | fn github_fetch_pr_runtime_info( |
| 4879 | owner: &str, |
| 4880 | repo: &str, |
| 4881 | pr_number: u64, |
| 4882 | token: Option<&str>, |
| 4883 | ) -> anyhow::Result<GithubPrRuntimeInfo> { |
| 4884 | let endpoint = format!("repos/{owner}/{repo}/pulls/{pr_number}"); |
| 4885 | let value = gh_api_json("GET", &endpoint, None, token)?; |
| 4886 | |
| 4887 | let head_ref = value |
| 4888 | .get("head") |
| 4889 | .and_then(|v| v.get("ref")) |
| 4890 | .and_then(|v| v.as_str()) |
| 4891 | .ok_or_else(|| anyhow::anyhow!("PR {} is missing head.ref", pr_number))? |
| 4892 | .to_string(); |
| 4893 | let head_repo_full_name = value |
| 4894 | .get("head") |
| 4895 | .and_then(|v| v.get("repo")) |
| 4896 | .and_then(|v| v.get("full_name")) |
| 4897 | .and_then(|v| v.as_str()) |
| 4898 | .unwrap_or(&format!("{owner}/{repo}")) |
| 4899 | .to_string(); |
| 4900 | let base_repo_full_name = value |
| 4901 | .get("base") |
| 4902 | .and_then(|v| v.get("repo")) |
| 4903 | .and_then(|v| v.get("full_name")) |
| 4904 | .and_then(|v| v.as_str()) |
| 4905 | .unwrap_or(&format!("{owner}/{repo}")) |
| 4906 | .to_string(); |
| 4907 | |
| 4908 | Ok(GithubPrRuntimeInfo { |
| 4909 | head_ref, |
| 4910 | head_repo_full_name, |
| 4911 | base_repo_full_name, |
| 4912 | }) |
| 4913 | } |
| 4914 | |
| 4915 | fn github_generate_branch_name(prefix: &str, issue_number: Option<u64>) -> String { |
| 4916 | let stamp = chrono::Utc::now().format("%Y%m%d%H%M%S").to_string(); |
no test coverage detected