Skip to content

feat: issues find-branch command to find issue by Git branch name#106

Merged
flipbit03 merged 4 commits intoflipbit03:mainfrom
lightstrikelabs:feat/issues-find-branch
Mar 7, 2026
Merged

feat: issues find-branch command to find issue by Git branch name#106
flipbit03 merged 4 commits intoflipbit03:mainfrom
lightstrikelabs:feat/issues-find-branch

Conversation

@lightstrike
Copy link
Copy Markdown
Contributor

@lightstrike lightstrike commented Mar 1, 2026

Summary

  • Add execute_optional method to SDK Client for nullable GraphQL return types, refactor execute to delegate to itRemoved: execute::<Option<T>> already handles nullable responses via serde's Option deserialization, no new method needed
  • Add issueVcsBranchSearch query to operations.toml and regenerate SDK
  • New CLI subcommand: lineark issues find-branch <BRANCH> — finds the Linear issue associated with a Git branch name
  • Returns full issue detail (same as issues read) on match, exits non-zero with "No issue found" on no match
  • Update lineark usage reference

Test plan

  • cargo fmt --check — clean
  • cargo clippy --workspace -- -D warnings — clean
  • cargo test --workspace — all offline tests pass
  • CLI online tests pass
  • Manual smoke: lineark issues find-branch <branch> works, no-match exits non-zero
  • Merged origin/main to resolve conflicts

lightstrike and others added 2 commits February 28, 2026 18:37
Add issueVcsBranchSearch query support: given a Git branch name, find the
associated Linear issue. Returns full issue details on match, non-zero
exit on no match.

Key changes:
- Add `execute_optional` to SDK Client for nullable query responses,
  refactor `execute` to delegate to it
- Add `issueVcsBranchSearch` to operations.toml and regenerate SDK
- Add `issues find-branch <BRANCH>` CLI subcommand
- Add offline tests (help, subcommand listing, usage)
- Add online tests for both SDK and CLI (found + not-found cases)
…<Option<T>>

The existing execute method already handles nullable responses through
serde's Option deserialization — no new SDK method needed. Also fixed
usage.rs column alignment and resolved merge conflicts in online.rs.
@flipbit03
Copy link
Copy Markdown
Owner

Hey @lightstrike, nice feature — find-branch is a great addition! A few notes on the implementation:

execute_optional isn't needed — the existing execute method already handles this case through Rust's type system. When the API returns {"data": {"issueVcsBranchSearch": null}}:

  1. data.get(data_path) returns Some(&Value::Null) (the key exists, it's just null)
  2. serde_json::from_value::<Option<T>>(Value::Null) deserializes to Ok(None)

So the caller just needs to request Option<T> as the type parameter:

let result: Option<IssueDetail> = client
    .execute(&query, variables, "issueVcsBranchSearch")
    .await?;

No new SDK method required — serde's Option deserialization already does exactly what execute_optional does manually. It's worth keeping in mind that when you feel like you need to add a new code path for nullability, check whether the type system already handles it for you. Rust + serde are really good at this!

I've pushed a fix to your branch removing execute_optional and using execute::<Option<T>> directly. Also merged latest origin/main to resolve conflicts.

@flipbit03
Copy link
Copy Markdown
Owner

Note: This PR currently hand-rolls the GraphQL query for issueVcsBranchSearch because the generated SDK function can't handle nullable return types (see #120). Once #120 lands (blanket impl<T: GraphQLFields> GraphQLFields for Option<T>), the CLI handler and SDK tests should be updated to use the generated client.issue_vcs_branch_search::<Option<IssueDetail>>() directly instead of raw client.execute().

Blocked by #120.

@flipbit03 flipbit03 marked this pull request as ready for review March 6, 2026 20:33
@flipbit03 flipbit03 added the safe-to-test Maintainer-approved: run online tests with API secrets label Mar 6, 2026
@flipbit03
Copy link
Copy Markdown
Owner

Hey @lightstrike — pushed a final round of changes to your branch.

Your find-branch implementation exposed a real gap in the SDK: nullable GraphQL fields (like issueVcsBranchSearch: Issue without !) couldn't use generated functions because Option<T> didn't implement GraphQLFields. We fixed this properly in #120 with a blanket impl + codegen nullable support.

With that merged, this PR now uses the generated client.issue_vcs_branch_search() instead of hand-rolling the query. Also cleaned up: UUID suffixes on SDK test names, removed redundant manual issue_delete (RAII guard handles it), reordered FindBranch enum variant.

Thanks for the contribution that sparked a real SDK improvement!

@github-actions github-actions bot removed the safe-to-test Maintainer-approved: run online tests with API secrets label Mar 6, 2026
@flipbit03 flipbit03 self-requested a review March 6, 2026 20:37
# Conflicts:
#	crates/lineark-sdk/src/generated/client_impl.rs
#	crates/lineark-sdk/src/generated/queries.rs
Replace hand-rolled query with the generated function now that flipbit03#120
added nullable query support. Also: UUID suffix on SDK test names,
remove redundant manual issue_delete (RAII guard handles it), reorder
FindBranch enum variant next to other read operations.
@flipbit03 flipbit03 force-pushed the feat/issues-find-branch branch from 0b6c9fa to c4a7497 Compare March 6, 2026 20:40
@flipbit03 flipbit03 added the safe-to-test Maintainer-approved: run online tests with API secrets label Mar 7, 2026
@github-actions github-actions bot removed the safe-to-test Maintainer-approved: run online tests with API secrets label Mar 7, 2026
@flipbit03 flipbit03 merged commit 750524a into flipbit03:main Mar 7, 2026
9 checks passed
@flipbit03 flipbit03 deleted the feat/issues-find-branch branch March 7, 2026 13:24
Copy link
Copy Markdown
Owner

@flipbit03 flipbit03 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants