Fix briefing_git() leaking a system2 status-128 warning on non-repos - #34
Merged
Merged
Conversation
briefing_git() prechecked with dir.exists(".git"), which passes for
worktrees (where .git is a file), invalid .git dirs, and dubious-
ownership cases where git still exits non-zero. The resulting "had
status 128" warning from system2() propagated past the error-only
tryCatch and leaked to the user (e.g. corteza's load_saber_briefing()
in a non-git directory).
Replace the precheck with 'git rev-parse --is-inside-work-tree' and
wrap both system2() calls in suppressWarnings(), so this best-effort
helper stays silent and returns character(0) when git can't read the
repo. Fixes #33.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #33.
briefing_git()prechecked the repo withdir.exists(file.path(repo_dir, ".git")), which passes in cases wheregit logthen fails with a non-zero exit: git worktrees (.gitis a file, not a directory), invalid/empty.gitdirs, and dubious-ownership states.system2()raises asimpleWarning("had status 128") on non-zero exit, and the surroundingtryCatchonly handlederror, so the warning leaked to the user.It surfaced via corteza's
load_saber_briefing()atchat()setup when run in a non-git directory.Changes
dir.exists(".git")precheck withgit rev-parse --is-inside-work-tree, which correctly reports non-repos (including worktrees) before we rungit log.system2()calls insuppressWarnings()so a non-zero exit returns empty silently instead of leaking a "had status N" warning past the best-effort helper.Tests
Two regression tests in
test_briefing.R:.git(passesdir.exists, failsgit log) returnscharacter(0)with no warning.Full suite: 169 pass, 0 fail.