Skip to content
Merged
4 changes: 3 additions & 1 deletion docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,9 @@ options:
given, and needs --branch — there is no commit to put
a line on without one
--push push the branch to origin (needs --branch)
--pr open a pull request with `gh` (needs --branch)
--pr open a pull request with `gh` (needs --branch); a
later run on that branch with nothing left to write
opens it if it is still missing
```

### `shape-doctor.py`
Expand Down
31 changes: 27 additions & 4 deletions tests/test_update_shape_add_ignored.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,10 +517,6 @@ def operators_staged_work(root) -> None:
"REFUSED creating the branch shape/update/ignored",
("kept HEAD on main, where it started",
"absent shape/update/ignored (never created)"), "unstaged"),
("branch-invalid", lambda root: None, "shape/update..ignored",
"REFUSED creating the branch shape/update..ignored",
("kept HEAD on main, where it started",
"absent shape/update..ignored (never created)"), "unstaged"),
("branch-exists", the_branch_already_exists, BRANCH,
f"REFUSED update-branch-exists: --branch {BRANCH} already exists", (),
"deleted"),
Expand Down Expand Up @@ -593,6 +589,33 @@ def test_a_failure_before_the_commit_puts_the_tree_back_and_names_the_step(
assert "nothing to do" not in again.stdout


def test_a_branch_git_cannot_name_is_refused_before_any_write(
root, standard, quiet):
"""`shape/update..ignored` WAS this file's branch-creation failure after
the writes: `git checkout -b` refuses `..`, so the copies, the pin and
the README line had to be put back. Since #204 `main` asks `git
check-ref-format --branch` about `--branch` before anything is read or
written, so the same name is refused as `update-branch-invalid`, with
nothing on stdout and nothing to put back, and the operator's staged
work is untouched. `branch-df` above still makes `git checkout -b` fail
after the writes."""
operators_staged_work(root)
checked = check(root, standard, quiet)
before = snapshot(root, quiet)

result = apply(root, standard, quiet, *ADD_ARGS,
"--branch", "shape/update..ignored")

assert result.returncode == 2, result.stdout + result.stderr
assert result.stderr.startswith(
"REFUSED update-branch-invalid: --branch 'shape/update..ignored' "), (
result.stderr)
assert result.stdout == "", "refused before anything was written"
assert "ROLLED BACK" not in result.stderr
assert_same_tree(before, snapshot(root, quiet))
assert check(root, standard, quiet).stdout == checked.stdout


def test_a_rollback_git_will_not_finish_says_so_and_names_the_fix(
root, standard, quiet):
"""A PARTIAL ROLLBACK IS SAID TO BE ONE. Every undo is judged by reading
Expand Down
Loading
Loading