Skip to content
10 changes: 8 additions & 2 deletions scaffold-project.py
Original file line number Diff line number Diff line change
Expand Up @@ -1205,7 +1205,10 @@ def _seed_legs(args, values: dict, names: dict, repositories: dict,
except CommandFailed as exc:
print(exc.loudly(f"pushing the {role} leg"), file=sys.stderr)
print(RULESET_HINT.format(work=work, repo=repositories[role],
role=role), file=sys.stderr)
role=role,
local=args.tracking_branch,
tracking=args.tracking_branch),
file=sys.stderr)
return None
print(f" {role:<9} {commit[:12]} tree {leg_digests[role][:12]}… "
f"-> {urls[role]}")
Expand Down Expand Up @@ -1321,7 +1324,10 @@ def _build_assembly_root(args, values: dict, names: dict, repositories: dict,
print(exc.loudly("pushing the assembly root"), file=sys.stderr)
print(RULESET_HINT.format(work=assembly,
repo=repositories["assembly"],
role="assembly"), file=sys.stderr)
role="assembly",
local=args.tracking_branch,
tracking=args.tracking_branch),
file=sys.stderr)
return False
print(f" assembly {run(['git', 'rev-parse', 'HEAD'], cwd=assembly)[:12]} "
f"-> {urls['assembly']}")
Expand Down
5 changes: 4 additions & 1 deletion scripts/family.py
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,10 @@ def _create_holder_worktree(args, work: Path, values: dict, shape_commit: str,
except CommandFailed as exc:
print(exc.loudly("pushing the family holder"), file=sys.stderr)
print(RULESET_HINT.format(work=work, repo=repository,
role="family"), file=sys.stderr)
role="family",
local=args.tracking_branch,
tracking=args.tracking_branch),
file=sys.stderr)
return 2
return None

Expand Down
17 changes: 15 additions & 2 deletions scripts/shape_materialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,19 @@ def loudly(self, what: str) -> str:
)


#: Two fields name a branch, and they are NOT the same thing (#324):
#: `{tracking}` is the run's tracking branch (`--tracking-branch`): the
#: branch of the REMOTE the refused push targeted, and so the base a
#: seeding pull request lands on.
#: `{local}` is the ref in `{work}` that the refused push carried. Each
#: caller -- the scaffold's legs and assembly root, the family holder --
#: pushed the tracking branch BY NAME from a clone made on it, so each
#: passes the tracking branch for both; a push of `HEAD:` would name `HEAD`.
#: An adoption prints its own `ADOPT_RULESET_HINT` (`adopt-project.py`,
#: #177), which names the tracking branch the same way and no command.
#: Every caller passes both, after `checked_value` has admitted the tracking
#: branch, so each is a safe argument and neither is quoted here. A call that
#: leaves one out fails `tests/test_ruleset_hint_tracking_branch.py`.
RULESET_HINT = """
If the organisation applies a ruleset requiring changes to arrive by pull
request, a direct push to the default branch is refused BY DESIGN and must not
Expand All @@ -742,8 +755,8 @@ def loudly(self, what: str) -> str:
(1) have an operator holding the bypass right seed the default branch once,
then re-run this scaffold; or
(2) push a seed BRANCH and open a pull request:
git -C {work} push -u origin main:seed/scaffold
gh pr create --repo {repo} --base main --head seed/scaffold \\
git -C {work} push -u origin {local}:seed/scaffold
gh pr create --repo {repo} --base {tracking} --head seed/scaffold \\
--title 'Seed the {role} leg' --body 'Scaffolded shape.'

NOTHING has been rolled back. What already exists is listed above; delete it
Expand Down
Loading
Loading