Fork me on GitHub
#babashka
<
2024-05-02
>
didibus19:05:14

For some reason this:`(shell "git diff --quiet --cached -- || git commit -m \"Prepared for new release.\"")` doesn't work, but does when I run it as a command in my shell.

didibus19:05:01

Alternatively, is there a way to have bb task not stop when git commit exits with an error? My problem is if there is nothing to commit, git commit exits in an error, and that ends my build task.

Bob B20:05:52

<https://book.babashka.org/#_shell> talks about a :continue option for not throwing on a non-zero exit code - that might do what you're looking for

borkdude20:05:19

@U0K064KQV note that || etc don't work automatically with shell. it does not execute via bash, it just starts git and provides all the rest as arguments to git

😯 1
borkdude20:05:18

I would write the above as:

(try (shell "git diff --quiet --cached")
  (catch Exception _
    (shell "git commit -m" "Prepared for new release")))

👍 1
borkdude20:05:01

You can shell out to bash with:

(shell "bash -c" "whatever")

didibus20:05:17

Cool, ok I didn't know. I'll try those alternatives.

didibus01:05:57

That worked!

👍 1
didibus01:05:05

I also get how shell works now.