Skip to content

Commit

Permalink
Use the askpass package instead of getPass
Browse files Browse the repository at this point in the history
  • Loading branch information
stewid committed Jul 3, 2020
1 parent 52caf28 commit 1ec5e30
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Imports:
Depends:
R (>= 3.1)
Suggests:
getPass
askpass
Type: Package
LazyData: true
Biarch: true
Expand Down
16 changes: 8 additions & 8 deletions R/credential.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ cred_token <- function(token = "GITHUB_PAT") {
##'
##' @family git credential functions
##' @param username The username of the credential
##' @param password The password of the credential. If getPass is installed
##' and the only input is username, \code{getPass::getPass()} will be
##' @param password The password of the credential. If askpass is installed
##' and the only input is username, \code{askpass::askpass()} will be
##' called to allow for interactive and obfuscated interactive
##' input of the password.
##' @return A list of class \code{cred_user_pass} with entries:
Expand All @@ -110,8 +110,8 @@ cred_token <- function(token = "GITHUB_PAT") {
cred_user_pass <- function(username = NULL, password = NULL) {
if (!is.null(username)) {
if (is.null(password)) {
if (requireNamespace("getPass", quietly = TRUE)) {
password <- getPass::getPass()
if (requireNamespace("askpass", quietly = TRUE)) {
password <- askpass::askpass()
}
}
}
Expand All @@ -128,8 +128,8 @@ cred_user_pass <- function(username = NULL, password = NULL) {
##' @param privatekey The path to the private key of the
##' credential. Default is \code{ssh_path("id_rsa")}
##' @param passphrase The passphrase of the credential. Default is
##' \code{character(0)}. If getPass is installed and private key
##' is passphrase protected \code{getPass::getPass()} will be
##' \code{character(0)}. If askpass is installed and private key
##' is passphrase protected \code{askpass::askpass()} will be
##' called to allow for interactive and obfuscated interactive
##' input of the passphrase.
##' @return A list of class \code{cred_ssh_key} with entries:
Expand Down Expand Up @@ -161,8 +161,8 @@ cred_ssh_key <- function(publickey = ssh_path("id_rsa.pub"),

if (length(passphrase) == 0) {
if (ssh_key_needs_passphrase(privatekey)) {
if (requireNamespace("getPass", quietly = TRUE)) {
passphrase <- getPass::getPass()
if (requireNamespace("askpass", quietly = TRUE)) {
passphrase <- askpass::askpass()
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions man/cred_ssh_key.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/cred_user_pass.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1ec5e30

Please sign in to comment.