add review type (perf, bug, security, ...) + fix tests
ci/woodpecker/push/tests Pipeline was successful

This commit is contained in:
qpismont committed 2026-09-20 14:42:14 +00:00
1 parent be7284c6d8
commit fa03fd8589
8 files changed
+630 -335

No files matched your search

+21 -16
View File
@@ -8,7 +8,7 @@ use tokio_util::io::StreamReader;
use tracing::{instrument, warn};
use crate::{
bot::{ReviewResult, ReviewSide},
bot::{ReviewResult, ReviewSeverity, ReviewSide},
consts::MAX_DIFF_SIZE,
errors::AppError,
};
@@ -49,15 +49,6 @@ impl GiteaAPI {
&self.token
}
/// HTTPS clone URL for a repository, suitable for `git clone`.
pub fn repo_clone_url(&self, full_name: &str) -> String {
format!(
"{}/{}.git",
self.base_url.trim_end_matches('/'),
full_name.trim_start_matches('/')
)
}
#[instrument(skip(self))]
pub async fn get_authorized_user(&self) -> anyhow::Result<User> {
let url = format!("{}/api/v1/user", self.base_url);
@@ -231,7 +222,11 @@ impl GiteaAPI {
.filter_map(|review| {
let line = review.line?;
let path = review.filename.clone();
let body = review.message.clone();
let severity = review
.severity
.unwrap_or(ReviewSeverity::Maintainability)
.label();
let body = format!("**[{severity}]** {}", review.message);
// A line removed by the pull request only exists in the old
// version of the file, so it is anchored with `old_position`.
@@ -333,6 +328,7 @@ pub struct User {
#[derive(Deserialize, Debug)]
pub struct Repository {
pub full_name: String,
pub clone_url: String,
}
/// A file changed by a pull request, as reported by the API.
@@ -390,7 +386,8 @@ mod tests {
"title": "My PR"
},
"repository": {
"full_name": "owner/repo"
"full_name": "owner/repo",
"clone_url": "https://github.com/owner/repo.git"
},
"comment": {
"id": 7,
@@ -453,7 +450,8 @@ mod tests {
"title": "My PR"
},
"repository": {
"full_name": "owner/repo"
"full_name": "owner/repo",
"clone_url": "https://github.com/owner/repo.git"
},
"comment": {
"id": 1,
@@ -485,7 +483,8 @@ mod tests {
"title": "My PR"
},
"repository": {
"full_name": "owner/repo"
"full_name": "owner/repo",
"clone_url": "https://github.com/owner/repo.git"
},
"comment": {
"id": 12,
@@ -501,6 +500,10 @@ mod tests {
assert_eq!(payload.action, "created");
assert_eq!(payload.comment.id, 12);
assert_eq!(payload.comment.body, "Needs work");
assert_eq!(
payload.repository.clone_url,
"https://github.com/owner/repo.git"
);
}
#[test]
@@ -521,7 +524,8 @@ mod tests {
"title": "My PR"
},
"repository": {
"full_name": "owner/repo"
"full_name": "owner/repo",
"clone_url": "https://github.com/owner/repo.git"
},
"comment": {
"id": 1,
@@ -548,7 +552,8 @@ mod tests {
"title": "My PR"
},
"repository": {
"full_name": "owner/repo"
"full_name": "owner/repo",
"clone_url": "https://github.com/owner/repo.git"
},
"comment": {
"id": 1,