Skip to content

Commit

Permalink
[Fix #33] Don't ask for password when running headless
Browse files Browse the repository at this point in the history
Also, don't supply password to `gpg` when no password is supplied
  • Loading branch information
slipset committed Sep 18, 2021
1 parent abc7a76 commit 1ef3d46
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/deps_deploy/gpg.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
(or (System/getenv "DEPS_DEPLOY_GPG") "gpg"))

(defn read-passphrase []
(let [console (System/console)]
(when-let [console (System/console)]
(String. (.readPassword console "%s" (into-array ["gpg passphrase: "])))))

(defn gpg [{:keys [passphrase args]}]
Expand Down Expand Up @@ -36,9 +36,11 @@
(update cmd :args into ["--yes" "--armour" "--detach-sign" file]))

(defn add-passphrase [cmd passphrase]
(-> cmd
(update :args #(into ["--batch" "--pinentry-mode" "loopback" "--passphrase-fd" "0"] %))
(assoc :passphrase passphrase)))
(if passphrase
(-> cmd
(update :args #(into ["--batch" "--pinentry-mode" "loopback" "--passphrase-fd" "0"] %))
(assoc :passphrase passphrase))
(update cmd :args #(into ["--batch"] %))))

(defn add-key [cmd key]
(update cmd :args #(into ["--default-key" key] %)))
Expand Down

0 comments on commit 1ef3d46

Please sign in to comment.