Skip to content

Commit

Permalink
create new tasks with labels on push
Browse files Browse the repository at this point in the history
  • Loading branch information
jhspetersson committed Dec 23, 2024
1 parent a6acff1 commit e6e7713
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/connectors/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,10 @@ async fn create_issue(user: &String, repo: &String, task: &Task) -> Result<Strin
if let Some(description) = task.get_property("description") {
create_builder = create_builder.body(description);
}
if let Some(labels) = task.get_labels() {
let labels = labels.iter().map(|l| l.get_name()).collect::<Vec<_>>();
create_builder = create_builder.labels(labels);
}
match create_builder.send().await {
Ok(issue) => Ok(issue.number.to_string()),
Err(e) => Err(e.to_string())
Expand Down
4 changes: 4 additions & 0 deletions src/connectors/gitlab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ impl RemoteConnector for GitlabRemoteConnector {
let endpoint = endpoint.project(user.to_string() + "/" + repo);
endpoint.title(task.get_property("name").unwrap());
endpoint.description(task.get_property("description").unwrap());
if let Some(labels) = task.get_labels() {
let labels = labels.iter().map(|l| l.get_name()).collect::<Vec<_>>();
endpoint.labels(labels);
}
let endpoint = endpoint.build().unwrap();
let issue: Issue = endpoint.query(&client).unwrap();

Expand Down
9 changes: 9 additions & 0 deletions src/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,15 @@ pub(crate) fn task_push(ids: String, remote: &Option<String>, no_comments: bool,
} else {
eprintln!("Sync: REMOTE task ID {id} NOT found");

let local_task = match no_labels {
true => {
let mut local_task = local_task;
local_task.set_labels(vec![]);
local_task
},
false => local_task
};

match connector.create_remote_task(&user, &repo, &local_task) {
Ok(id) => {
println!("Sync: Created REMOTE task ID {id}");
Expand Down

0 comments on commit e6e7713

Please sign in to comment.