Skip to content

Commit

Permalink
improved Gitlab support
Browse files Browse the repository at this point in the history
  • Loading branch information
jhspetersson committed Oct 4, 2024
1 parent 58b3366 commit 856c567
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions src/connectors/gitlab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::collections::HashMap;

use gitlab::api::issues::{IssueScope, IssueState};
use gitlab::api::projects::issues::IssueStateEvent;
use gitlab::api::Query;
use gitlab::api::{Pagination, Query};
use gitlab::Gitlab;
use regex::Regex;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -62,7 +62,11 @@ impl RemoteConnector for GitlabRemoteConnector {
None => endpoint
};
let endpoint = endpoint.build().unwrap();
let issues: Vec<Issue> = gitlab::api::paged(endpoint, gitlab::api::Pagination::Limit(limit.unwrap_or_else(|| 100))).query(&client).unwrap();
let pagination = match limit {
Some(limit) => Pagination::Limit(limit),
None => Pagination::All
};
let issues: Vec<Issue> = gitlab::api::paged(endpoint, pagination).query(&client).unwrap();
let mut result = vec![];
for issue in issues {
let mut props = HashMap::new();
Expand All @@ -82,10 +86,6 @@ impl RemoteConnector for GitlabRemoteConnector {
result.push(task);
}

if result.len() == 100 {
eprintln!("Only last 100 issues are supported for Gitlab");
}

result
}

Expand Down Expand Up @@ -129,12 +129,6 @@ impl RemoteConnector for GitlabRemoteConnector {
let endpoint = endpoint.build().unwrap();
let issue: Issue = endpoint.query(&client).unwrap();

if let Some(comments) = task.get_comments() {
if !comments.is_empty() {
eprintln!("Comments are not supported for Gitlab");
}
}

Ok(issue.iid.to_string())
}

Expand Down Expand Up @@ -195,7 +189,7 @@ fn list_issue_comments(client: &Gitlab, user: &String, repo: &String, task_id: &
let mut endpoint = gitlab::api::projects::issues::notes::IssueNotes::builder();
let endpoint = endpoint.project(user.to_string() + "/" + repo).issue(task_id.parse().unwrap());
let endpoint = endpoint.build().unwrap();
match gitlab::api::paged(endpoint, gitlab::api::Pagination::Limit(100)).query(client) {
match gitlab::api::paged(endpoint, Pagination::All).query(client) {
Ok(comments) => {
let comments: Vec<GitlabComment> = comments;
let mut result: Vec<Comment> = vec![];
Expand Down

0 comments on commit 856c567

Please sign in to comment.