From 063f6540dc198111e66456f875a5d0527e50a107 Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Sat, 21 May 2022 14:15:14 +0200 Subject: [PATCH] Set GIT_SSH_COMMAND='ssh -o "BatchMode yes"' to block prompts when using SSH auth. --- CHANGELOG.md | 5 ++++- src/Literate.jl | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a92a9ad..2d34ec2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Fixed - Update remote HEAD branch detection to use `addenv` instead of `setenv` such that e.g. - ssh-agent variables are still available to the git command. ([#197][github-197]) + ssh-agent variables are available to the git command. Also set + `GIT_SSH_COMMAND='ssh -o "BatchMode yes"'` to supress prompts when using ssh. + ([#197][github-197]) + ## [2.13.2] - 2022-04-22 ### Fixed diff --git a/src/Literate.jl b/src/Literate.jl index 4270ff8..962c975 100644 --- a/src/Literate.jl +++ b/src/Literate.jl @@ -270,8 +270,12 @@ function create_configuration(inputfile; user_config, user_kwargs, type=nothing) fallback_edit_commit = "master" if (git = Sys.which("git"); git !== nothing) try + env = copy(ENV) + # Set environment variables to block interactive prompt + env["GIT_TERMINAL_PROMPT"] = "0" + env["GIT_SSH_COMMAND"] = get(ENV, "GIT_SSH_COMMAND", "ssh -o \"BatchMode yes\"") str = read(pipeline(ignorestatus( - addenv(`$(git) remote show origin`, ["GIT_TERMINAL_PROMPT=0"]; dir=dirname(inputfile)) + setenv(`$(git) remote show origin`, env; dir=dirname(inputfile)) ), stderr=devnull), String) if (m = match(r"^\s*HEAD branch:\s*(.*)$"m, str); m !== nothing) fallback_edit_commit = String(m[1])