Skip to content

Commit 0be12a5

Browse files
committed
fix: skip assignee/label API resolution during dry-run
1 parent 2b110f6 commit 0be12a5

1 file changed

Lines changed: 50 additions & 25 deletions

File tree

‎src/commands/issues.rs‎

Lines changed: 50 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -737,25 +737,42 @@ async fn create_issue(
737737
input["stateId"] = json!(s);
738738
}
739739
if let Some(ref a) = assignee {
740-
// Resolve user name/email to UUID
741-
let assignee_id = resolve_user_id(&client, a, &output.cache).await?;
742-
input["assigneeId"] = json!(assignee_id);
740+
// Resolve user name/email to UUID (skip during dry-run to avoid API calls)
741+
if dry_run {
742+
input["assigneeId"] = json!(a);
743+
} else {
744+
let assignee_id = resolve_user_id(&client, a, &output.cache).await?;
745+
input["assigneeId"] = json!(assignee_id);
746+
}
743747
}
744748
if !labels.is_empty() {
745-
// Resolve label names to UUIDs
746-
let mut label_ids: Vec<String> = input["labelIds"]
747-
.as_array()
748-
.map(|arr| {
749-
arr.iter()
750-
.filter_map(|v| v.as_str().map(|s| s.to_string()))
751-
.collect()
752-
})
753-
.unwrap_or_default();
754-
for label in &labels {
755-
let label_id = resolve_label_id(&client, label, &output.cache).await?;
756-
label_ids.push(label_id);
749+
// Resolve label names to UUIDs (skip during dry-run to avoid API calls)
750+
if dry_run {
751+
let mut label_ids: Vec<String> = input["labelIds"]
752+
.as_array()
753+
.map(|arr| {
754+
arr.iter()
755+
.filter_map(|v| v.as_str().map(|s| s.to_string()))
756+
.collect()
757+
})
758+
.unwrap_or_default();
759+
label_ids.extend(labels.clone());
760+
input["labelIds"] = json!(label_ids);
761+
} else {
762+
let mut label_ids: Vec<String> = input["labelIds"]
763+
.as_array()
764+
.map(|arr| {
765+
arr.iter()
766+
.filter_map(|v| v.as_str().map(|s| s.to_string()))
767+
.collect()
768+
})
769+
.unwrap_or_default();
770+
for label in &labels {
771+
let label_id = resolve_label_id(&client, label, &output.cache).await?;
772+
label_ids.push(label_id);
773+
}
774+
input["labelIds"] = json!(label_ids);
757775
}
758-
input["labelIds"] = json!(label_ids);
759776
}
760777
if let Some(ref d) = due {
761778
// Parse due date shorthand
@@ -918,18 +935,26 @@ async fn update_issue(
918935
input["stateId"] = json!(s);
919936
}
920937
if let Some(a) = assignee {
921-
// Resolve user name/email to UUID
922-
let assignee_id = resolve_user_id(&client, &a, &output.cache).await?;
923-
input["assigneeId"] = json!(assignee_id);
938+
// Resolve user name/email to UUID (skip during dry-run to avoid API calls)
939+
if dry_run {
940+
input["assigneeId"] = json!(a);
941+
} else {
942+
let assignee_id = resolve_user_id(&client, &a, &output.cache).await?;
943+
input["assigneeId"] = json!(assignee_id);
944+
}
924945
}
925946
if !labels.is_empty() {
926-
// Resolve label names to UUIDs
927-
let mut label_ids = Vec::new();
928-
for label in &labels {
929-
let label_id = resolve_label_id(&client, label, &output.cache).await?;
930-
label_ids.push(label_id);
947+
// Resolve label names to UUIDs (skip during dry-run to avoid API calls)
948+
if dry_run {
949+
input["labelIds"] = json!(labels);
950+
} else {
951+
let mut label_ids = Vec::new();
952+
for label in &labels {
953+
let label_id = resolve_label_id(&client, label, &output.cache).await?;
954+
label_ids.push(label_id);
955+
}
956+
input["labelIds"] = json!(label_ids);
931957
}
932-
input["labelIds"] = json!(label_ids);
933958
}
934959
if let Some(ref d) = due {
935960
// Support clearing due date with "none"

0 commit comments

Comments
 (0)