Skip to content

Commit 902aa4d

Browse files
committed
fix(ci): apply cargo fmt and remove auto crates publish
1 parent 372fd0b commit 902aa4d

19 files changed

Lines changed: 608 additions & 372 deletions

‎.github/workflows/release.yml‎

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,3 @@ jobs:
7676
files: |
7777
linear-cli-*/linear-cli-*
7878
generate_release_notes: true
79-
80-
publish-crates:
81-
name: Publish to crates.io
82-
needs: release
83-
runs-on: ubuntu-latest
84-
85-
steps:
86-
- uses: actions/checkout@v4
87-
88-
- name: Install Rust
89-
uses: dtolnay/rust-toolchain@stable
90-
91-
- name: Publish to crates.io
92-
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}

‎src/api.rs‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,29 @@ pub async fn resolve_team_id(client: &LinearClient, team: &str) -> Result<String
3434
.unwrap_or(&empty);
3535

3636
// First try exact key match (case-insensitive)
37-
if let Some(team_data) = teams.iter().find(|t| {
38-
t["key"].as_str().map(|k| k.eq_ignore_ascii_case(team)) == Some(true)
39-
}) {
37+
if let Some(team_data) = teams
38+
.iter()
39+
.find(|t| t["key"].as_str().map(|k| k.eq_ignore_ascii_case(team)) == Some(true))
40+
{
4041
if let Some(id) = team_data["id"].as_str() {
4142
return Ok(id.to_string());
4243
}
4344
}
4445

4546
// Then try exact name match (case-insensitive)
46-
if let Some(team_data) = teams.iter().find(|t| {
47-
t["name"].as_str().map(|n| n.eq_ignore_ascii_case(team)) == Some(true)
48-
}) {
47+
if let Some(team_data) = teams
48+
.iter()
49+
.find(|t| t["name"].as_str().map(|n| n.eq_ignore_ascii_case(team)) == Some(true))
50+
{
4951
if let Some(id) = team_data["id"].as_str() {
5052
return Ok(id.to_string());
5153
}
5254
}
5355

54-
anyhow::bail!("Team not found: '{}'. Use 'linear-cli t list' to see available teams.", team)
56+
anyhow::bail!(
57+
"Team not found: '{}'. Use 'linear-cli t list' to see available teams.",
58+
team
59+
)
5560
}
5661

5762
pub struct LinearClient {
@@ -96,4 +101,3 @@ impl LinearClient {
96101
self.query(mutation, variables).await
97102
}
98103
}
99-

‎src/commands/bulk.rs‎

Lines changed: 51 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ async fn resolve_user_id(client: &LinearClient, user: &str) -> Result<String> {
102102
for u in users {
103103
let name = u["name"].as_str().unwrap_or("");
104104
let email = u["email"].as_str().unwrap_or("");
105-
105+
106106
if name.eq_ignore_ascii_case(user) || email.eq_ignore_ascii_case(user) {
107107
if let Some(id) = u["id"].as_str() {
108108
return Ok(id.to_string());
@@ -134,7 +134,9 @@ async fn resolve_state_id(client: &LinearClient, team_id: &str, state: &str) ->
134134
}
135135
"#;
136136

137-
let result = client.query(query, Some(json!({ "teamId": team_id }))).await?;
137+
let result = client
138+
.query(query, Some(json!({ "teamId": team_id })))
139+
.await?;
138140
let empty = vec![];
139141
let states = result["data"]["team"]["states"]["nodes"]
140142
.as_array()
@@ -192,7 +194,10 @@ async fn resolve_label_id(client: &LinearClient, label: &str) -> Result<String>
192194
}
193195

194196
/// Get issue details including UUID and team ID from identifier (e.g., "LIN-123")
195-
async fn get_issue_info(client: &LinearClient, issue_id: &str) -> Result<(String, String, Option<String>)> {
197+
async fn get_issue_info(
198+
client: &LinearClient,
199+
issue_id: &str,
200+
) -> Result<(String, String, Option<String>)> {
196201
let query = r#"
197202
query($id: String!) {
198203
issue(id: $id) {
@@ -222,27 +227,17 @@ async fn get_issue_info(client: &LinearClient, issue_id: &str) -> Result<(String
222227
.ok_or_else(|| anyhow::anyhow!("Failed to get team ID"))?
223228
.to_string();
224229

225-
let identifier = issue["identifier"]
226-
.as_str()
227-
.map(|s| s.to_string());
230+
let identifier = issue["identifier"].as_str().map(|s| s.to_string());
228231

229232
Ok((uuid, team_id, identifier))
230233
}
231234

232235
pub async fn handle(cmd: BulkCommands) -> Result<()> {
233236
match cmd {
234-
BulkCommands::UpdateState { state, issues } => {
235-
bulk_update_state(&state, issues).await
236-
}
237-
BulkCommands::Assign { user, issues } => {
238-
bulk_assign(&user, issues).await
239-
}
240-
BulkCommands::Label { label, issues } => {
241-
bulk_label(&label, issues).await
242-
}
243-
BulkCommands::Unassign { issues } => {
244-
bulk_unassign(issues).await
245-
}
237+
BulkCommands::UpdateState { state, issues } => bulk_update_state(&state, issues).await,
238+
BulkCommands::Assign { user, issues } => bulk_assign(&user, issues).await,
239+
BulkCommands::Label { label, issues } => bulk_label(&label, issues).await,
240+
BulkCommands::Unassign { issues } => bulk_unassign(issues).await,
246241
}
247242
}
248243

@@ -268,9 +263,7 @@ async fn bulk_update_state(state: &str, issues: Vec<String>) -> Result<()> {
268263
let client = &client;
269264
let state = &state_owned;
270265
let id = issue_id.clone();
271-
async move {
272-
update_issue_state(client, &id, state).await
273-
}
266+
async move { update_issue_state(client, &id, state).await }
274267
})
275268
.collect();
276269

@@ -310,9 +303,7 @@ async fn bulk_assign(user: &str, issues: Vec<String>) -> Result<()> {
310303
let client = &client;
311304
let user_id = &user_id;
312305
let id = issue_id.clone();
313-
async move {
314-
update_issue_assignee(client, &id, Some(user_id)).await
315-
}
306+
async move { update_issue_assignee(client, &id, Some(user_id)).await }
316307
})
317308
.collect();
318309

@@ -352,9 +343,7 @@ async fn bulk_label(label: &str, issues: Vec<String>) -> Result<()> {
352343
let client = &client;
353344
let label_id = &label_id;
354345
let id = issue_id.clone();
355-
async move {
356-
add_label_to_issue(client, &id, label_id).await
357-
}
346+
async move { add_label_to_issue(client, &id, label_id).await }
358347
})
359348
.collect();
360349

@@ -370,11 +359,7 @@ async fn bulk_unassign(issues: Vec<String>) -> Result<()> {
370359
return Ok(());
371360
}
372361

373-
println!(
374-
"{} Unassigning {} issues...",
375-
">>".cyan(),
376-
issues.len()
377-
);
362+
println!("{} Unassigning {} issues...", ">>".cyan(), issues.len());
378363

379364
let client = LinearClient::new()?;
380365

@@ -383,9 +368,7 @@ async fn bulk_unassign(issues: Vec<String>) -> Result<()> {
383368
.map(|issue_id| {
384369
let client = &client;
385370
let id = issue_id.clone();
386-
async move {
387-
update_issue_assignee(client, &id, None).await
388-
}
371+
async move { update_issue_assignee(client, &id, None).await }
389372
})
390373
.collect();
391374

@@ -554,44 +537,45 @@ async fn add_label_to_issue(client: &LinearClient, issue_id: &str, label_id: &st
554537
}
555538
"#;
556539

557-
let (uuid, identifier, existing_label_ids) = match client.query(query, Some(json!({ "id": issue_id }))).await {
558-
Ok(result) => {
559-
if result["data"]["issue"].is_null() {
540+
let (uuid, identifier, existing_label_ids) =
541+
match client.query(query, Some(json!({ "id": issue_id }))).await {
542+
Ok(result) => {
543+
if result["data"]["issue"].is_null() {
544+
return BulkResult {
545+
issue_id: issue_id.to_string(),
546+
success: false,
547+
identifier: None,
548+
error: Some("Issue not found".to_string()),
549+
};
550+
}
551+
552+
let uuid = result["data"]["issue"]["id"]
553+
.as_str()
554+
.unwrap_or(issue_id)
555+
.to_string();
556+
557+
let identifier = result["data"]["issue"]["identifier"]
558+
.as_str()
559+
.map(|s| s.to_string());
560+
561+
let labels: Vec<String> = result["data"]["issue"]["labels"]["nodes"]
562+
.as_array()
563+
.unwrap_or(&vec![])
564+
.iter()
565+
.filter_map(|l| l["id"].as_str().map(|s| s.to_string()))
566+
.collect();
567+
568+
(uuid, identifier, labels)
569+
}
570+
Err(e) => {
560571
return BulkResult {
561572
issue_id: issue_id.to_string(),
562573
success: false,
563574
identifier: None,
564-
error: Some("Issue not found".to_string()),
575+
error: Some(e.to_string()),
565576
};
566577
}
567-
568-
let uuid = result["data"]["issue"]["id"]
569-
.as_str()
570-
.unwrap_or(issue_id)
571-
.to_string();
572-
573-
let identifier = result["data"]["issue"]["identifier"]
574-
.as_str()
575-
.map(|s| s.to_string());
576-
577-
let labels: Vec<String> = result["data"]["issue"]["labels"]["nodes"]
578-
.as_array()
579-
.unwrap_or(&vec![])
580-
.iter()
581-
.filter_map(|l| l["id"].as_str().map(|s| s.to_string()))
582-
.collect();
583-
584-
(uuid, identifier, labels)
585-
}
586-
Err(e) => {
587-
return BulkResult {
588-
issue_id: issue_id.to_string(),
589-
success: false,
590-
identifier: None,
591-
error: Some(e.to_string()),
592-
};
593-
}
594-
};
578+
};
595579

596580
let mut label_ids = existing_label_ids;
597581

‎src/commands/comments.rs‎

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,11 @@ struct CommentRow {
4242
pub async fn handle(cmd: CommentCommands) -> Result<()> {
4343
match cmd {
4444
CommentCommands::List { issue_id } => list_comments(&issue_id).await,
45-
CommentCommands::Create { issue_id, body, parent_id } => {
46-
create_comment(&issue_id, &body, parent_id).await
47-
}
45+
CommentCommands::Create {
46+
issue_id,
47+
body,
48+
parent_id,
49+
} => create_comment(&issue_id, &body, parent_id).await,
4850
}
4951
}
5052

@@ -70,7 +72,9 @@ async fn list_comments(issue_id: &str) -> Result<()> {
7072
}
7173
"#;
7274

73-
let result = client.query(query, Some(json!({ "issueId": issue_id }))).await?;
75+
let result = client
76+
.query(query, Some(json!({ "issueId": issue_id })))
77+
.await?;
7478
let issue = &result["data"]["issue"];
7579

7680
if issue.is_null() {
@@ -84,9 +88,7 @@ async fn list_comments(issue_id: &str) -> Result<()> {
8488
println!("{}", "─".repeat(50));
8589

8690
let empty = vec![];
87-
let comments = issue["comments"]["nodes"]
88-
.as_array()
89-
.unwrap_or(&empty);
91+
let comments = issue["comments"]["nodes"].as_array().unwrap_or(&empty);
9092

9193
if comments.is_empty() {
9294
println!("No comments found for this issue.");
@@ -154,16 +156,26 @@ async fn create_comment(issue_id: &str, body: &str, parent_id: Option<String>) -
154156
}
155157
"#;
156158

157-
let result = client.mutate(mutation, Some(json!({ "input": input }))).await?;
159+
let result = client
160+
.mutate(mutation, Some(json!({ "input": input })))
161+
.await?;
158162

159163
if result["data"]["commentCreate"]["success"].as_bool() == Some(true) {
160164
let comment = &result["data"]["commentCreate"]["comment"];
161165
let issue_identifier = comment["issue"]["identifier"].as_str().unwrap_or("");
162166
let issue_title = comment["issue"]["title"].as_str().unwrap_or("");
163167

164-
println!("{} Comment added to {} {}", "✓".green(), issue_identifier, issue_title);
168+
println!(
169+
"{} Comment added to {} {}",
170+
"✓".green(),
171+
issue_identifier,
172+
issue_title
173+
);
165174
println!(" ID: {}", comment["id"].as_str().unwrap_or(""));
166-
println!(" Author: {}", comment["user"]["name"].as_str().unwrap_or(""));
175+
println!(
176+
" Author: {}",
177+
comment["user"]["name"].as_str().unwrap_or("")
178+
);
167179

168180
let body_preview = comment["body"]
169181
.as_str()

0 commit comments

Comments
 (0)