pub async fn can_merge(&self, pr: &PullRequest) -> Result<()> {
        let endpoint = format!(
            "/rest/api/1.0/projects/{project_key}/repos/{repo_slug}/pull-requests/{id}/merge",
            project_key = pr.to_ref["repository"]["project"]["key"].as_str().unwrap(),
            repo_slug = pr.to_ref["repository"]["slug"].as_str().unwrap(),
            id = pr.id,
        );
        let response_text = self.get(&endpoint, None).await?.text().await?;
        let response_json: serde_json::Value = serde_json::from_str(&response_text)?;
        response_json
            .as_object()
            .and_then(|response| {
                if let Some(serde_json::Value::Bool(true)) = response.get("canMerge") {
                    Some(())
                } else {
                    None
                }
            })
            .ok_or(anyhow!(response_text))
    }
/// Check if a pull request is able to be merged without actually merging it
Check if a pull request is able to be merged without actually merging it
Check if a pull request is able to be merged without actually merging it
pub async fn can_merge(&self, pr: &PullRequest) -> Result<()> {
        let endpoint = format!(
            "/rest/api/1.0/projects/{project_key}/repos/{repo_slug}/pull-requests/{id}/merge",
            project_key = pr.to_ref["repository"]["project"]["key"].as_str().unwrap(),
            repo_slug = pr.to_ref["repository"]["slug"].as_str().unwrap(),
            id = pr.id,
        );
        let response_text = self.get(&endpoint, None).await?.text().await?;
        let response_json: serde_json::Value = serde_json::from_str(&response_text)?;
        response_json
            .as_object()
            .and_then(|response| {
                if let Some(serde_json::Value::Bool(true)) = response.get("canMerge") {
                    Some(())
                } else {
                    None
                }
            })
            .ok_or(anyhow!(response_text))
    }
pub async fn can_merge ( & self , pr : & PullRequest ) -> Result < ( ) > { let endpoint = format ! ( " " project_key pr to_ref [ " " ] [ " " ] [ " " ] as_str ( ) unwrap ( ) repo_slug pr to_ref [ " " ] [ " " ] as_str ( ) unwrap ( ) id pr id ) ; let response_text = self . get ( & endpoint , None ) . await ? . text ( ) . await ? ; let response_json : serde_json :: Value = serde_json :: from_str ( & response_text ) ? ; response_json . as_object ( ) . and_then ( | response | { if let Some ( serde_json :: Value :: Bool ( true ) ) = response . get ( " " ) { Some ( ( ) ) } else { None } } ) . ok_or ( anyhow ! ( response_text ) ) }
Check if a pull request is able to be merged without actually merging it
Check if a pull request is able to be merged without actually merging it
&self
pr
&PullRequest
&self
pr
&PullRequest