Create branch with a canned name#14191
Merged
Merged
Conversation
c3e55ab to
cd74203
Compare
Contributor
There was a problem hiding this comment.
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_createaccept an optional branch ref input so callers can request an auto-generated name. - Adds fallback logic in
branch_create_with_permto 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_createis exported via#[but_api(napi,…)], and takingOption<gix::refs::FullName>here is likely to generate a NAPI/TypeScript signature using the opaque type nameFullName | null(perbut-api-macrostype mapping). AcceptingOption<String>at the API boundary and parsing intogix::refs::FullNameinside keeps the external API asstring | nullwhile 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)]
cd74203 to
ba95791
Compare
| 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, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.