Repository navigation
Add 'mob start --create-base <branch>' to automatically create base branch and open mob branch - #489
ruben-carvalho wants to merge 3 commits into
Conversation
|
Thanks a lot for this, @ruben-carvalho, and for the thorough tests! This has come up before in #211, which proposed exactly this and went through quite a bit of discussion. There we agreed on extending the existing flag rather than adding a new one: We shipped it in two steps. The first,
These are the invocations we'd need to support ( Existing, must keep working: New: Ambiguous, a number after Invalid, should fail with an error: So after This should make the change much smaller than the current diff. Would you be up for reworking the PR in this direction? Happy to help if anything is unclear. |
|
Hi, thank you for the answer! Sure I'll take a look and change accordingly. My proposal stated that we wouldn't even need to be on the default main branch to run the command, but maybe that's an overstep and we should still checkout the branch where we want to create the base and mob branch off. Will update this soon! |
…se branch from updated remote default branch and create the mob branch right from it Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
As discussed in the review and in remotemobprogramming#211, 'mob start --create' now takes an optional branch name instead of introducing a new --create-base flag: - After -c/--create, the next argument is the branch name only if it does not start with '-' and is not a number (a number stays the timer, so 'mob start -c 10' keeps working). - The branch is created from the current branch's up-to-date remote (git checkout -b <branch> --no-track origin/<current>), with no default-branch detection. - An existing branch is no longer refused: a local branch is switched to, a remote one is checked out, so everyone in the mob can run the same command. A diverged local branch still stops with the existing unpushed-commits error. - 'mob start -c 10 feature' fails with an error suggesting 'mob start --create <branch> <timer>'. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
69e8402 to
744fe2b
Compare
|
Pushed the changes preserving the command mob start -c and adding the optional branch name. Please take a look 🙂. One question: Best, |
With --include-uncommitted-changes or --discard-uncommitted-changes, start() stashed or hard-reset the working tree before the checks that can refuse the branch given to --create (wip branch name, on a wip branch, current branch without a remote, unpushed commits on the target branch). A failing check then left the user's changes stashed, or already discarded, without starting anything. Run all validations first, and only then stash or reset and switch branches. The unpushed-commits check on an existing local target branch now also runs before the checkout, so a refused start stays on the original branch. Also key the too-many-arguments error on a literally typed -c/--create instead of configuration.StartCreate, so users with MOB_START_CREATE=true and a stray extra argument don't get an error about a flag they never typed, and restore the mocked exit via t.Cleanup in the new test. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
When working with feature branchs and PRs starting a mob on a new story is always the same ritual: checkout main, pull, create the feature branch, push it with upstream set, and only then mob start. We ended up writing a wrapper script to automate this because mob itself had no way to create the base branch. mob start --create assumes you already created and checked out the branch, and getting there requires an up-to-date local main.
What this adds: mob start --create-base does the whole thing in one step:
fetches and detects the remote default branch (origin/HEAD, falling back to main/master)
creates directly from origin/. The default branch doesn’t need to be checked out locally, or even exist locally pushes it with upstream set and starts the session on the wip branch mob/
It refuses to run when you’re on a wip branch, when the branch already exists locally or on the remote, or when it can’t find a default branch. A dirty working tree is handled the same way as plain mob start, with --include-uncommitted-changes / --discard-uncommitted-changes. --create-base implies --create, can’t be combined with --join, and aborts with a hint when no branch name is given.
Added integration tests on the git testbed, help text, and a CHANGELOG entry.