remotemobprogramming / mob

Tool for smooth git handover.
https://mob.sh
MIT License
1.66k stars 147 forks source link

"mob start" fails when base branch isn't a local branch #451

Open stefanscheidt opened 3 days ago

stefanscheidt commented 3 days ago

I'm not sure if this is a feature or a bug: Let's assume an ensemble works on a task with the base branch some-task. Now a colleague joins, clones the repo, switches immediately to mob/some-task (!) and enters mob s 10. Then he/she will see:

  git fetch origin --prune
ERROR git rev-list --count --left-only refs/heads/some-task...refs/remotes/origin/some-task
ERROR fatal: ambiguous argument 'refs/heads/some-task...refs/remotes/origin/some-task': unknown revision or path not in the working tree.
ERROR Use '--' to separate paths from revisions, like this:
ERROR 'git <command> [<revision>...] -- [<file>...]'
ERROR exit status 128

Of course he/she should have switched to some-task and do a mob s 10 (or probably mob s 10 --join ). Is the current behaviour intended or could this be improved?

stefanscheidt commented 3 days ago

Hi. Sorry, but the above error message is probably misleading. I anonymized a real output, replacing our branch name with some-task. I just found out that base branches with hyphen in there name actually behave differently.

If you provoke the above with a base branch without hyphens in its name, you will get:

❯ git sw mob/basebranchwithouthyphen
branch 'mob/basebranchwithouthyphen' set up to track 'origin/mob/basebranchwithouthyphen'.
Switched to a new branch 'mob/basebranchwithouthyphen'

❯ mob s
  git fetch origin --prune
ERROR git rev-list --count --left-only refs/heads/basebranchwithouthyphen...refs/remotes/origin/basebranchwithouthyphen
ERROR fatal: ambiguous argument 'refs/heads/basebranchwithouthyphen...refs/remotes/origin/basebranchwithouthyphen': unknown revision or path not in the working tree.
ERROR Use '--' to separate paths from revisions, like this:
ERROR 'git <command> [<revision>...] -- [<file>...]'
ERROR exit status 128

If you do the same with a base branch with hyphens in its name, you'll get:

❯ git sw mob/base-branch-with-hyphens
branch 'mob/base-branch-with-hyphens' set up to track 'origin/mob/base-branch-with-hyphens'.
Switched to a new branch 'mob/base-branch-with-hyphens'

❯ mob s
  git fetch origin --prune
ERROR Remote branch origin/base is missing
👉 To start and create the remote branch

  mob start --create
gregorriegler commented 3 days ago

Good find, thank you @stefanscheidt