Skip to content

Create branch with a canned name#14191

Merged
Caleb-T-Owens merged 2 commits into
masterfrom
caleb/create-branch-with-canned-name
Jun 12, 2026
Merged

Create branch with a canned name#14191
Caleb-T-Owens merged 2 commits into
masterfrom
caleb/create-branch-with-canned-name

Conversation

@Caleb-T-Owens

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings June 11, 2026 19:00
@github-actions github-actions Bot added the rust Pull requests that update Rust code label Jun 11, 2026
@Caleb-T-Owens Caleb-T-Owens force-pushed the caleb/create-branch-with-canned-name branch from c3e55ab to cd74203 Compare June 11, 2026 19:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the but-api branch creation endpoint to support omitting the target refname, generating a default (“canned”) branch name when none is provided.

Changes:

  • Makes branch_create accept an optional branch ref input so callers can request an auto-generated name.
  • Adds fallback logic in branch_create_with_perm to compute a canned refname when none is supplied.
  • Updates imports to support the new canned-name generation.
Comments suppressed due to low confidence (1)

crates/but-api/src/branch.rs:575

  • branch_create is exported via #[but_api(napi,…)], and taking Option<gix::refs::FullName> here is likely to generate a NAPI/TypeScript signature using the opaque type name FullName | null (per but-api-macros type mapping). Accepting Option<String> at the API boundary and parsing into gix::refs::FullName inside keeps the external API as string | null while preserving internal type safety.
///
/// This acquires exclusive worktree access from `ctx`, creates the branch,
/// and records an oplog snapshot on success. For lower-level implementation
/// details, see [`but_workspace::branch::create_reference()`].
#[but_api(napi, try_from = json::BranchCreateResult)]

Comment thread crates/but-api/src/branch.rs Outdated
Comment thread crates/but-api/src/branch.rs
Copilot AI review requested due to automatic review settings June 11, 2026 19:46
@Caleb-T-Owens Caleb-T-Owens force-pushed the caleb/create-branch-with-canned-name branch from cd74203 to ba95791 Compare June 11, 2026 19:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.

pub struct BranchCreateResult {
/// Workspace state after creating the branch.
pub workspace: WorkspaceState,
/// The name of the crated reference
pub struct BranchCreateResult {
/// Workspace state after creating the branch.
pub workspace: crate::json::WorkspaceState,
/// The name of the crated reference
Comment on lines 577 to 580
pub fn branch_create(
ctx: &mut but_ctx::Context,
new_ref: &gix::refs::FullNameRef,
#[but_api(crate::json::MaybeLossyFullNameRef)] new_ref: Option<gix::refs::FullName>,
placement: json::BranchCreatePlacement,
@Caleb-T-Owens Caleb-T-Owens merged commit f339add into master Jun 12, 2026
66 of 68 checks passed
@Caleb-T-Owens Caleb-T-Owens deleted the caleb/create-branch-with-canned-name branch June 12, 2026 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants