merging a pr does not return a body
This commit is contained in:
		
							parent
							
								
									bc9dbc6348
								
							
						
					
					
						commit
						e732034aea
					
				
					 2 changed files with 24 additions and 1 deletions
				
			
		
							
								
								
									
										23
									
								
								src/lib.rs
									
										
									
									
									
								
							
							
						
						
									
										23
									
								
								src/lib.rs
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -118,6 +118,16 @@ impl Forgejo {
 | 
			
		|||
        self.execute_str(request).await
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    async fn post_unit<T: Serialize>(
 | 
			
		||||
        &self,
 | 
			
		||||
        path: &str,
 | 
			
		||||
        body: &T,
 | 
			
		||||
    ) -> Result<(), ForgejoError> {
 | 
			
		||||
        let url = self.url.join("api/v1/").unwrap().join(path).unwrap();
 | 
			
		||||
        let request = self.client.post(url).json(body).build()?;
 | 
			
		||||
        self.execute_unit(request).await
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    async fn post_raw(
 | 
			
		||||
        &self,
 | 
			
		||||
        path: &str,
 | 
			
		||||
| 
						 | 
				
			
			@ -179,6 +189,19 @@ impl Forgejo {
 | 
			
		|||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// Like `execute`, but returns unit.
 | 
			
		||||
    async fn execute_unit(&self, request: Request) -> Result<(), ForgejoError> {
 | 
			
		||||
        let response = self.client.execute(request).await?;
 | 
			
		||||
        match response.status() {
 | 
			
		||||
            status if status.is_success() => Ok(()),
 | 
			
		||||
            status if status.is_client_error() => Err(ForgejoError::ApiError(
 | 
			
		||||
                status,
 | 
			
		||||
                response.json::<ErrorMessage>().await?.message.unwrap_or_else(|| String::from("[no message]")),
 | 
			
		||||
            )),
 | 
			
		||||
            status => Err(ForgejoError::UnexpectedStatusCode(status)),
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// Like `execute`, but returns `Ok(None)` on 404.
 | 
			
		||||
    async fn execute_opt<T: DeserializeOwned>(
 | 
			
		||||
        &self,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -44,7 +44,7 @@ impl Forgejo {
 | 
			
		|||
        pr: u64,
 | 
			
		||||
        opts: MergePullRequestOption,
 | 
			
		||||
    ) -> Result<(), ForgejoError> {
 | 
			
		||||
        self.post(&format!("repos/{owner}/{repo}/pulls/{pr}/merge"), &opts)
 | 
			
		||||
        self.post_unit(&format!("repos/{owner}/{repo}/pulls/{pr}/merge"), &opts)
 | 
			
		||||
            .await
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue