babashka / neil

A CLI to add common aliases and features to deps.edn-based projects
MIT License
367 stars 27 forks source link

`neil new` crashes on certain forms of invalid input #167

Closed teodorlu closed 5 months ago

teodorlu commented 1 year ago

Example below. invalid-template is not a provided built-in template - but I don't think that's easy to read from the stack trace.

$ neil new invalid-template some-gibberish
----- Error --------------------------------------------------------------------
Type:     clojure.lang.ExceptionInfo
Message:  Failed to parse :git/url
Data:     {:git/url "https://github.com/invalid-template"}
Location: /home/teodorlu/.local/bin/neil:285:7

----- Context ------------------------------------------------------------------
281:   (let [[[_ gh-user repo-name]] (or (re-seq github-repo-ssh-regex git-url)
282:                                     (re-seq github-repo-http-regex git-url))]
283:     (if (and gh-user repo-name)
284:       {:gh-user gh-user :repo-name repo-name}
285:       (throw (ex-info "Failed to parse :git/url" {:git/url git-url})))))
           ^--- Failed to parse :git/url
286:
287: (defn- git-url->lib-sym [git-url]
288:   (when-let [{:keys [gh-user repo-name]} (parse-git-url git-url)]
289:     (symbol (str "io.github." gh-user) repo-name)))
290:

----- Stack trace --------------------------------------------------------------
babashka.neil.new/parse-git-url     - /home/teodorlu/.local/bin/neil:285:7
babashka.neil.new/parse-git-url     - /home/teodorlu/.local/bin/neil:280:1
babashka.neil.new/git-url->lib-sym  - /home/teodorlu/.local/bin/neil:288:42
babashka.neil.new/git-url->lib-sym  - /home/teodorlu/.local/bin/neil:287:1
babashka.neil.new                   - /home/teodorlu/.local/bin/neil:303:57
... (run with --debug to see elided elements)
babashka.neil.new                   - /home/teodorlu/.local/bin/neil:470:18
babashka.neil/-main                 - /home/teodorlu/.local/bin/neil:1556:3
babashka.neil/-main                 - /home/teodorlu/.local/bin/neil:1555:1
babashka.neil                       - /home/teodorlu/.local/bin/neil:1616:3
babashka.neil                       - /home/teodorlu/.local/bin/neil:1615:1
borkdude commented 5 months ago

Seems to be already fixed

teodorlu commented 5 months ago

Thanks! 💯