session-start hook: gate local-source load on Package == 'saber'#31
Merged
Conversation
The hook's local-load fallback (intended for saber developers iterating on saber itself) sources every R/*.R in the current git repo and looks up the named function. From any repo that exports a function with the same name as a saber export but a different signature, this picked up the wrong function. Concretely: cerebro::briefing(name, ...) was loaded instead of saber::briefing(project, scan_dir, ...), and the hook's scan_dir = scan_dir call blew up. Guard the local-load path on the local DESCRIPTION's Package field being 'saber'. Everywhere else, fall through to the installed saber namespace as before.
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.
Summary
The session-start hook's local-load fallback (intended so saber developers iterating on saber itself see their changes immediately) sources every
R/*.Rfile in the current git repo and looks up the named function. From any repo that happens to export a function with the same name as a saber export, this picked up the wrong function.Concretely, from
~/cerebrothe hook foundcerebro::briefing(name, ...)(a different beast — the daily-briefing capability) instead ofsaber::briefing(project, scan_dir, ...). The hook'sbriefing_fun(project, scan_dir = scan_dir)call then failed with "unused argument (scan_dir = scan_dir)" and the SessionStart briefing degraded to the "saber not available:" fallback.Fix: guard the local-load dance on the local
DESCRIPTION'sPackage:field beingsaber. Everywhere else, fall through to the installed saber namespace as before.Test plan
~/cerebro(which hascerebro::briefing): hook now produces a normal briefing instead of the "saber not available" fallback.~/saber(the local-dev case): hook still sources locally and produces the briefing.tinypkgr::check()clean.Release plan
No version bump in this PR. Bundle into the next saber release whenever there's something else to ship — the impact is narrow (only fires when (a) saber is installed AND (b) the current repo exports a function with the same name as a saber export).