Play your own Switch games on iPhone/iPad — one-click macOS app, no terminal. | 把 Switch 游戏装进 iPhone:图形界面一键构建,不用命令行。Bring your own game.
Swift apple-siliconcustom-formathomebrewiosipaipadipadosiphonemetalnative-portnintendo-switchnxnativeromfsswitch-games
pre-push: reject a push to main for every tool
v0lumehif132802b1c69
diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.mdindex b8ecdc07..0af2953a 100644--- a/.github/copilot-instructions.md+++ b/.github/copilot-instructions.md@@ -2,7 +2,7 @@Read [AGENTS.md](../AGENTS.md) (the fork's, at the root) and [CONTRIBUTING.md](../CONTRIBUTING.md) first, and they win over this file.-- First, in your checkout, run `git config core.hooksPath .githooks`. The hooks run the checks before a commit and a push. Keep them installed, never use `--no-verify`, and never push to `main`: every change goes through a PR.+- First, in your checkout, run `git config core.hooksPath .githooks`. The hooks run the checks before a commit and a push. Keep them installed, never use `--no-verify`, and never push to `main`: every change goes through a PR. The pre-push hook rejects a push to `main` for every tool, and the "Main rule" ruleset on GitHub rejects it for everyone, with no bypass.- `frontend/` and `frontend-qt/` are this fork's own: change them directly. `cd frontend && swift test` is the check.- The engine (`dm/`, `scripts/`, `docs/`, `ref/`) is not in this repository: it is seedds/nxnative at `.upstream-ref` plus `patches/`, built into `engine/` by `python3 tools/engine.py sync`. Do not add files under those paths in a PR (the `pr-scope` check fails it). A change to the engine is a pull request to seedds/nxnative first, and a patch in `patches/` (a commit in `engine/`, then `python3 tools/engine.py export`) only while the fork has to carry it.- Never touch the shader translation chain (`dm/gfx/tools/dmsh_*`, `dm/gfx/nvn/dmsh_chain.h`, `dmsh_chain.lock`, the translator).diff --git a/AGENTS.md b/AGENTS.mdindex 4c1f5c43..5b5a2023 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -2,7 +2,7 @@This is the fork's guide. The engine has its own, upstream's: [engine/AGENTS.md](engine/AGENTS.md) (after `python3 tools/engine.py sync`, or [seedds/nxnative's AGENTS.md](https://github.com/seedds/nxnative/blob/main/AGENTS.md)). Read this file first, the engine's for any work in `engine/`.-- **Install the git hooks first.** In every clone and worktree, before any other work, run `git config core.hooksPath .githooks`. `python3 tools/engine.py sync`, `check` and `export` and the Claude Code session start do it when it is unset. Keep the hooks installed. Never use `--no-verify` on `git commit` or `git push`. Never push to `main` directly, every change goes through a PR, patches included.+- **Install the git hooks first.** In every clone and worktree, before any other work, run `git config core.hooksPath .githooks`. `python3 tools/engine.py sync`, `check` and `export` and the Claude Code session start do it when it is unset. Keep the hooks installed. Never use `--no-verify` on `git commit` or `git push`. Never push to `main` directly, every change goes through a PR, patches included. The pre-push hook rejects a push to `main` for every tool, and the "Main rule" ruleset on GitHub rejects it for everyone, with no bypass.- **Layout.** NX2Apple is the launcher and the glue around [seedds/nxnative](https://github.com/seedds/nxnative), which runs Nintendo Switch games natively on Apple platforms. This repository commits: `frontend/` (the Mac launcher, SwiftUI), `frontend-qt/` (the Qt front end), `frontend-ios/` (the iPhone shell), `tools/` (`engine.py`, `patches.py`, `release_manifest.py` and their tests), `patches/` (the series), `.upstream-ref` (the nxnative commit we build on), `.github/` (CI, forms, triage), the player and developer pages (`README*.md`, `GAMES*.md`, `BUILDING*.md`, `CONTRIBUTING*.md`, `CHANGELOG*.md`). The engine (`dm/`, `scripts/`, `docs/`, `ref/`) is **not** here: it is nxnative at the pin plus `patches/`, built into `engine/` by `python3 tools/engine.py sync`. `engine/` is a real git repository that this one ignores. A root `.ignore` keeps it visible to ripgrep.- **Commit with your own git identity, never upstream's.** Use the identity configured for your clone, or your own name and email. `engine/AGENTS.md` ends with a `git -c user.name=seedds -c user.email=…` line because it is written for seedds/nxnative, where seedds is the maintainer. Do not copy it here: it makes fork commits, and the `From:` line of patches made with `tools/engine.py export`, show upstream's author. Commit only when asked.- **Here first, upstream in parallel.** A fix to the engine, to a game profile or to upstream's docs may land here first, as a patch. The same change goes to seedds/nxnative as a pull request in parallel, from a branch off their main (`git -C engine fetch seedds`, `engine/` has the remote). If you cannot open that pull request, a maintainer sends it. A patch here is a bridge until upstream has it, and the next bump drops it once the change is in. [patches/README.md](patches/README.md#here-first-upstream-in-parallel) has the rule and the `Upstream-Status` values.diff --git a/CLAUDE.md b/CLAUDE.mdindex 72912728..c56b32c3 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -1,6 +1,6 @@# Notes for Claude-- First step in every clone or worktree: `git config core.hooksPath .githooks` (the SessionStart hook does it when unset). Never use `--no-verify`, never push to `main`: a PreToolUse hook in `.claude/settings.json` blocks both. See AGENTS.md.+- First step in every clone or worktree: `git config core.hooksPath .githooks` (the SessionStart hook does it when unset). Never use `--no-verify`, never push to `main`. A PreToolUse hook in `.claude/settings.json` blocks `--no-verify` and a push to `main`, and the pre-push hook and the "Main rule" ruleset on GitHub block a push to `main` for every tool. See AGENTS.md.- Read [AGENTS.md](AGENTS.md) first: this repository's layout and rules. For engine work read [engine/AGENTS.md](engine/AGENTS.md) too, upstream's guide from seedds/nxnative at the pin. `engine/` is made by `python3 tools/engine.py sync` (the SessionStart hook in `.claude/settings.json` runs it).- For an issue or a pull request, follow [CONTRIBUTING.md](CONTRIBUTING.md), section "For AI agents and other tools", and the templates in `.github/`.- A PR that changes the launcher needs before and after screenshots: see "For AI agents and other tools" in CONTRIBUTING.md for how to capture them and attach them with `gh pr create --attach`.diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex 641105e0..d3d2c9a6 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -35,7 +35,7 @@ missing piece.## A pull request-- Before any work in a clone or worktree, run `git config core.hooksPath .githooks`. The hooks run the checks for what you commit and push (`python3 tools/engine.py check` for `patches/`, the tests for the code you changed, see `tools/githooks.py`). `tools/engine.py sync`, `check` and `export` install the hooks when they are not. Keep them installed and never use `--no-verify`. Never push to `main` directly.+- Before any work in a clone or worktree, run `git config core.hooksPath .githooks`. The hooks run the checks for what you commit and push (`python3 tools/engine.py check` for `patches/`, the tests for the code you changed, see `tools/githooks.py`). `tools/engine.py sync`, `check` and `export` install the hooks when they are not. Keep them installed and never use `--no-verify`. Never push to `main` directly. The pre-push hook rejects it for every tool, and the "Main rule" ruleset on GitHub rejects it for everyone, with no bypass.- One change per PR, off `main`. Commit messages say what changed and why, in plain English, as `git log` does.- Fill in the PR template: what and why, what was checked, screenshots for UI changes.- A PR that changes anything visible in the launcher attaches before and after screenshots to the PR, under Screenshots. Show every view the PR changes, in each language it touches. A PR without them is not reviewed. A PR with no visible change writes "None, no visible change".diff --git a/tools/githooks.py b/tools/githooks.pyindex c62f56c9..75df5bbf 100755--- a/tools/githooks.py+++ b/tools/githooks.py@@ -68,6 +68,9 @@ def pushed_paths(lines):def pre_push(lines):+ if any(len(f) == 4 and f[2] == 'refs/heads/main' for f in map(str.split, lines)):+ print('pre-push: pushing to main is not allowed. Open a pull request.', file=sys.stderr)+ return 1paths = pushed_paths(lines)if paths is None: print('pre-push: no base to compare with (is origin/main fetched?), so every check runs')return run('pre-push', CHECKS if paths is None else checks_for(paths))diff --git a/tools/tests/test_githooks.py b/tools/tests/test_githooks.pyindex 5d0b6c70..85567f0b 100644--- a/tools/tests/test_githooks.py+++ b/tools/tests/test_githooks.py@@ -179,6 +179,25 @@ class PushedPaths(unittest.TestCase):code = H.pre_push([f'refs/heads/feature {head} refs/heads/feature {H.ZERO}'])return code, out.getvalue()+ def test_a_push_to_main_is_rejected_before_any_check(self):+ err = io.StringIO()+ for remote in ('refs/heads/main',):+ for local in (f'refs/heads/feature {self.main}', f'HEAD {self.main}'):+ with mock.patch.object(H, 'sh', side_effect=AssertionError('no check may run')), mock.patch.object(H, 'pushed_paths', side_effect=AssertionError('no diff')), \+ contextlib.redirect_stderr(err):+ self.assertEqual(H.pre_push([f'{local} {remote} {self.main}']), 1)+ self.assertIn('pushing to main is not allowed. Open a pull request.', err.getvalue())++ def test_one_push_to_main_among_several_refs_rejects_all(self):+ lines = [f'refs/heads/feature {self.main} refs/heads/feature {H.ZERO}', f'refs/heads/feature {self.main} refs/heads/main {self.main}']+ with mock.patch.object(H, 'sh', side_effect=AssertionError('no check may run')), contextlib.redirect_stderr(io.StringIO()):+ self.assertEqual(H.pre_push(lines), 1)++ def test_other_branches_with_main_in_the_name_are_pushed(self):+ for remote in ('refs/heads/maintenance', 'refs/heads/feature/main', 'refs/tags/main'):+ with mock.patch.object(H, 'sh', side_effect=AssertionError('nothing may run')), contextlib.redirect_stdout(io.StringIO()):+ self.assertEqual(H.pre_push([f'refs/heads/x {self.main} {remote} {self.main}']), 0)+def test_docs_only_push_runs_nothing(self):with mock.patch.object(H, 'sh', side_effect=AssertionError('nothing may run')):code, out = self.run_hook('README.md')