Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use_git_config() behavior inconsistent with article #668

Closed
ijlyttle opened this issue Mar 26, 2019 · 4 comments
Closed

use_git_config() behavior inconsistent with article #668

ijlyttle opened this issue Mar 26, 2019 · 4 comments

Comments

@ijlyttle
Copy link
Contributor

ijlyttle commented Mar 26, 2019

Edit: I did not look at this carefully enough; as @cderv points out, this is very likely a documentation issue.


As best as I can tell, this was working in usethis 1.4.0:

## reveals config, even if not changing anything
use_git_config()

I updated one of my machines to the dev version, and it returns without printing anything to the screen.

The operative code in usethis seems to be in an internal function git_config(), which then calls git2r::config():

usethis/R/git-utils.R

Lines 297 to 310 in 37a774e

git_config <- function(..., .repo = NULL) {
values <- list(...)
if (is.null(.repo)) {
old <- git2r::config()$global[names(values)]
do.call(git2r::config, c(list(global = TRUE), values))
} else {
old <- git2r::config(.repo)$local[names(values)]
do.call(git2r::config, c(list(repo = .repo), values))
}
names(old) <- names(values)
invisible(old)
}

When I updated my usethis, it updated git2r 0.24.0 -> 0.25.2

Happy to dig further, but wanted to surface this now in case you had some ideas already.

Thanks!

@ijlyttle
Copy link
Contributor Author

Upon further consideration, I suspect a "culprit" is the invisible(old) line that returns from usethis:::git_config(), not git2r.

@cderv
Copy link
Contributor

cderv commented Mar 27, 2019

@ijlyttle I think this is an intended change as it is documented in the NEWS file for the current dev version.

use_git_config() now invisibly returns the previous values of the settings.

and it is in place since since bbc6b47

also documented

usethis/R/git.R

Line 105 in f08ecb6

#' @return Invisibly, the previous values of the modified components.

Before that, yes this function was returning visibly all the time for user name and email only

usethis/R/git.R

Lines 132 to 133 in a4c0113

nms <- c("user.name", "user.email")
return(stats::setNames(cfg[nms], nms))

now it returns invisibly only the modified values.

I guess only usethis-setup.Rmd should be updated ?
Unless old behaviour should be restored by printing configuration if interactive() and no value to modify is provided : usethis::use_git_config() ? or like a possible git_config_sitrep() ?
However, git2r::config() does exactly this and return a pretty descent list with all the configuration if nothing is modified.

@ijlyttle
Copy link
Contributor Author

ijlyttle commented Mar 27, 2019

Hi @cderv,

Of course, you are correct; my understanding was incomplete, I needed to look more-thoroughly :)

Given that this is the intended behavior of use_git_config(), I concur with @cderv's suggestion that usethis-setup.Rmd be updated, and I would be happy to make such a PR.

image

@ijlyttle ijlyttle changed the title use_git_config() does not reveal config use_git_config() behavior inconsistent with article Mar 27, 2019
@jennybc
Copy link
Member

jennybc commented Mar 27, 2019

Yes I'd appreciate a change to the setup vignette. Note that I just pushed a bit of a update to that document myself. But I didn't touch this stuff.

ijlyttle added a commit to ijlyttle/usethis that referenced this issue Mar 27, 2019
jennybc pushed a commit that referenced this issue Mar 27, 2019
* Fix #668 by including git_sitrep() in setup article

* Remove stray space
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants