exercism / cli

A Go based command line tool for exercism.org.
https://exercism.org/docs/using/solving-exercises/working-locally
MIT License
1.33k stars 360 forks source link

Is that ok to ignore the workplace case sensitive on macOS #1133

Closed ccqpein closed 7 months ago

ccqpein commented 7 months ago

I find in macOS, path is actually case insensitive.

And I find exercism submit actually check the case sensitive on macOS.

https://github.com/exercism/cli/blob/8f1e8f296f7a08158a2f8138c810ddc95e39f279/workspace/workspace.go#L124-L131

Can we ignore this case sensitive and just submit?

github-actions[bot] commented 7 months ago

Hello. Thanks for opening an issue on Exercism 🙂

At Exercism we use our Community Forum, not GitHub issues, as the primary place for discussion. That allows maintainers and contributors from across Exercism's ecosystem to discuss your problems/ideas/suggestions without them having to subscribe to hundreds of repositories.

This issue will be automatically closed. Please use this link to copy your GitHub Issue into a new topic on the forum, where we look forward to chatting with you!

If you're interested in learning more about this auto-responder, please read this blog post.

ccqpein commented 7 months ago

I make the change in my local

modified   workspace/workspace.go
@@ -123,11 +123,11 @@ func (ws Workspace) Exercises() ([]Exercise, error) {
 func (ws Workspace) ExerciseDir(s string) (string, error) {
    if !strings.HasPrefix(s, ws.Dir) {
        var err = fmt.Errorf("not in workspace")
-       if runtime.GOOS == "darwin" {
-           err = fmt.Errorf("%w: directory location may be case sensitive: workspace directory: %s, "+
-               "submit path: %s", err, ws.Dir, s)
+       if runtime.GOOS != "darwin" {
+           return "", err
+       } else if !strings.HasPrefix(strings.ToLower(s), strings.ToLower(ws.Dir)) {
+           return "", err
        }
-       return "", err
    }

    path := s

And looks like it can handle both upper/lower case when I try to submit. (and the unit test failed ofc)

I am not sure if anywhere else use this method (I only find it referenced in cmd/submit.go.

If you guys think this change is making sense, I can give a PR to make this change.