chore(trail): trim comments in trail create branch handling · Entire

chore(trail): trim comments in trail create branch handling

95b41a4→main·

dipree·4w ago·2 files·+7 added/-23 removed

Sessions

cf20056d6e7eView transcript

[?
Fix Trail Creation Branch Handling and ValidationPi·Opus 4.8·3 steps](/content/gh/entireio/cli/session/019ed956-c81a-74d1-9437-9fb289e1410f#timeline-cf20056d6e7e/index.html)

Changes

2

78 unmodified lines

79
80
81
82
83
84
85
86
87
82
83
84
85
86

78 unmodified lines

Title      string `json:"title"`
    Body       string `json:"body,omitempty"`
    BranchName string `json:"branch_name"`
    // BranchAction tells the server how to bind BranchName. The CLI always
    // pushes the branch to the remote before creating the trail, so it sends
    // "link" to attach the already-delivered branch. This prevents the server
    // from backfilling a backing branch at the base tip when the branch was
    // never delivered (which would silently anchor the trail to empty/diverged
    // content). Valid values: "create" (default, server-side) or "link".
    // BranchAction is "create" (default) or "link". The CLI sends "link" to
    // attach the already-pushed branch instead of backfilling it at base.
    BranchAction string   `json:"branch_action,omitempty"`
    Base         string   `json:"base,omitempty"`
    Status       string   `json:"status,omitempty"`

Mcmd/entire/cli/api/trail_types.go+2/-6

641 unmodified lines

642
643
644
645
646
647
648
649
650
651
652
653
645
646
647
648
655
656
657
658
659
649
650
651
662
652
653
654
9 unmodified lines

664
665
666
678
679
667
668
669
670

641 unmodified lines

fmt.Fprintf(w, "Note: trail will be created for branch %q (not the current branch)\n", branch)
    }

// Delivering the branch to origin is a PRECONDITION for trail creation, not
    // an optional follow-up. A trail binds to a *remote* branch; if the branch
    // never reaches origin the server has nothing to anchor to and backfills it
    // at the base tip, producing a trail whose backing branch does not reflect
    // the user's work (local branch, remote branch, and actual work all differ).
    // We therefore always push and hard-fail on error, regardless of whether we
    // created the branch locally. (Previously this was gated on needsCreation,
    // so `git checkout -b foo && entire trail create --branch foo` created the
    // trail without ever pushing foo.)
    // Always push the branch first: the trail binds to a remote branch, so
    // deliver it before creating the trail rather than letting the server
    // backfill it at the base tip.
    {
        // branchExistsOnOrigin tells us whether origin already has this branch
        // (e.g. a teammate pushed it, or we pushed it on a previous run). In that
        // case our push may merely fast-forward it and we must not delete it
        // during cleanup. Only treat the remote branch as created-by-us when it
        // did not already exist before our push.
        // Don't delete a remote branch we didn't create during cleanup.
        existedOnOrigin, existErr := branchExistsOnOrigin(branch)
        if existErr != nil {
            // Be conservative: if we cannot tell, do not delete the remote branch.
            fmt.Fprintf(errW, "Warning: could not check whether branch %s already exists on origin: %v\n", branch, existErr)
            existedOnOrigin = true
        }
9 unmodified lines

Title:      title,
        Body:       body,
        BranchName: branch,
        // We pushed the branch to origin above, so ask the server to link the
        // already-delivered branch rather than backfill it at the base tip.
        // Branch already pushed above; link it instead of backfilling at base.
        BranchAction: "link",
        Base:         base,
        Status:       statusStr,

Mcmd/entire/cli/trail_cmd.go+5/-17