Skip to content

fix(init): write .gitignore for the go template - #2833

Merged
houko merged 2 commits into
mainfrom
fix/2830-init-gitignore
Dec 1, 2026
Merged

houko merged 2 commits into
mainfrom
fix/2830-init-gitignore

Conversation

@houko

@houko houko commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

nsgo init -template go, the default template, wrote no .gitignore, although a Go app gets .nsgo/ (development builds, automation sessions with their token, test builds and screenshots, the check lock) and dist/ from nsgo build exactly as a TSX app does. A first git add . after nsgo build or nsgo test then committed binaries, packages and .nsgo/automation.yaml.

  • The go template now writes the same .gitignore the tsx and mixed templates do, ignoring .nsgo/ and dist/. Its entries come from one list, ignoredDirs, in cmd/nsgo/init.go.
  • For every built-in template, a .gitignore already in the target directory, such as a repository's own, is kept instead of making init refuse the directory. When it has no line for .nsgo/ or dist/ (written as dir with an optional leading / or **/ and an optional trailing /, /* or /**), init warns which entries it lacks and leaves the file untouched. The check is advisory: a .gitignore init cannot read, such as a directory or a file without read permission, only warns, so init never fails after it has written the app.
  • TestInitWritesGitignore checks every template writes the file with both entries, and that an existing .gitignore is kept, with a warning only when it lacks an entry, no warning for globbed forms such as **/.nsgo/ or /dist/*, and a warning rather than an error when it cannot be read.
  • Docs: the getting-started file table (all 14 locales), docs/architecture/tool.md and the nsgo skill list .gitignore for every template; a changelog.d fragment records the fix.

Module templates (-template <module>) are unchanged: they write what the module ships.

Fixes #2830

Targets

  • Shared code (core, base, ui, tsx, the nsgo tool)
  • macOS
  • iOS
  • tvOS
  • watchOS
  • Android
  • Windows
  • Linux
  • Web
  • Mini programs
  • Docs or website only

Screenshots

None

Verification

  • head: c8453ed178bad72593dbd7045fc73ffef11a0c5a
  • base: 8e5c1cc14ee7cd3cc4673eed0655f9ff482b7908
  • commands:
    • go tool nsgo test -run 'TestInit|TestSkill|TestDirAppName' ./cmd/nsgo ./skills/... (darwin/amd64, at c8453ed17) → 0
    • go vet ./cmd/nsgo (darwin/amd64, at c8453ed17) → 0
    • go tool nsgo test ./cmd/nsgo ./internal/moduletest ./tools/changelog (darwin/amd64, Command Line Tools only, over SSH, at 7337c89bf, before the review fixes) → 1: 346 passed, 5 failed, none in code this change touches: TestTVBrandAssets and TestCompileBrandAssets need Xcode's actool, TestRuntimeStale failed on the host's git setup (nothing to commit), TestPublicAPINamesNoInternalType got no export data for tsx/ui/chat, and the package hit its 10-minute timeout inside TestInitModuleTemplate, which fetches a module template through the network and takes the initModuleTemplate path this change leaves alone
  • result: fail
  • not covered: go tool nsgo check across targets did not finish locally (the build host's sync stalled when the local disk filled up), so cross-target vet is left to CI; the full ./cmd/nsgo package run was not repeated after the review fixes, which touch only init.go, its test and docs; Linux and Windows runtime tests; TestInitModuleTemplate and the Xcode-dependent icon tests

houko added 2 commits December 1, 2026 11:17
…tries

An existing .gitignore init cannot read now warns instead of failing an init that has already written the app. The entry check also accepts **/dir, dir/* and dir/**. The getting-started file table gains the .gitignore row in the remaining 12 locales.
@github-actions github-actions Bot added bug Something isn't working size/M labels Dec 1, 2026
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown

The Local CI block declares fail for this pull request's head commit, so a maintainer audits the pull request before merging it.

@github-actions github-actions Bot added local-ci-fail The head commit declares failing local checks, so a maintainer audits it documentation Improvements or additions to documentation cli labels Dec 1, 2026
@houko
houko merged commit bf7fe32 into main Dec 1, 2026
48 checks passed
@houko
houko deleted the fix/2830-init-gitignore branch December 1, 2026 04:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working cli documentation Improvements or additions to documentation local-ci-fail The head commit declares failing local checks, so a maintainer audits it size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cmd/nsgo: nsgo init -template go writes no .gitignore, though Go apps write .nsgo/ and dist/ like TSX ones

1 participant