Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ and versions follow [Semantic Versioning](https://semver.org/).

## [Unreleased]

## [0.5.1] - 2026-10-16

### Fixed
- Project names that Windows cannot create (`CON`, `NUL`, `COM1`, `LPT1`, a trailing dot) are refused with a clear message on every platform, so a project made on Linux can be checked out on Windows.

## [0.5.0] - 2026-10-16

### Added
Expand Down
21 changes: 21 additions & 0 deletions internal/project/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,31 @@ func ValidateName(name string) error {
return errors.New(`project name cannot contain any of : * ? " < > |`)
case len(name) > 100:
return errors.New("project name is longer than 100 characters")
case strings.HasSuffix(name, "."):
return errors.New("project name cannot end with a dot (Windows cannot create such a folder)")
case isWindowsReserved(name):
return fmt.Errorf("%q is a reserved device name on Windows; choose another project name", name)
}
return nil
}

// isWindowsReserved reports whether name (ignoring any extension) is a Windows device name such as CON or COM1.
// Projects are meant to be portable, so the name is refused on every platform.
func isWindowsReserved(name string) bool {
base := strings.ToUpper(name)
if i := strings.Index(base, "."); i >= 0 {
base = base[:i]
}
switch base {
case "CON", "PRN", "AUX", "NUL":
return true
}
if len(base) == 4 && (strings.HasPrefix(base, "COM") || strings.HasPrefix(base, "LPT")) {
return base[3] >= '1' && base[3] <= '9'
}
return false
}

// BuildPlan walks the template and decides what a project would contain. It writes nothing.
func BuildPlan(opts Options) (*Plan, error) {
if opts.Now.IsZero() {
Expand Down
4 changes: 2 additions & 2 deletions internal/project/project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,12 @@ func TestExecutableBitIsPreserved(t *testing.T) {
}

func TestValidateName(t *testing.T) {
for _, ok := range []string{"app", "my-app", "My App", "a.b_c"} {
for _, ok := range []string{"app", "my-app", "My App", "a.b_c", "console", "com", "com10", "COM0"} {
if err := ValidateName(ok); err != nil {
t.Errorf("%q: %v", ok, err)
}
}
for _, bad := range []string{"", " ", ".", "..", "a/b", `a\b`, "a:b", "a*b", " x", strings.Repeat("x", 101)} {
for _, bad := range []string{"", " ", ".", "..", "a/b", `a\b`, "a:b", "a*b", " x", strings.Repeat("x", 101), "CON", "nul", "Com1", "lpt9.txt", "app."} {
if err := ValidateName(bad); err == nil {
t.Errorf("%q should be invalid", bad)
}
Expand Down
Loading