Skip to content

Conversation

@jonkeane
Copy link
Contributor

I added some unit tests for the isFromCranlikeRepo() function and ensured that other tests passed (locally at least). I did need to make the URL detectors slightly more flexible to match the test fixtures (though realistically the URLs in the fixtures probably could be updated to be more like real ones instead.

resolves #747

R/gitlab.R Outdated
isGitlabURL <- function(url) {
is.string(url) &&
grepl("^http(?:s)?://(?:www|api).gitlab.(org|com)", url, perl = TRUE)
grepl("^(http(?:s)?://)?(www|api)?.?gitlab.(org|com)", url, perl = TRUE)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not totally sure why the look ahead option didn't work here, but the gitlab.com URL that is in the fixture seemingly required me to do (www|api)?.?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A super-nit here would be to move the . into the pattern, and also properly escape it so it's matching a literal . and not any character. E.g. ((www|api)\\.)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes that's much better

jonkeane and others added 3 commits October 23, 2025 22:54
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
R/restore.R Outdated
Comment on lines 29 to 34
git_remote <- isBitbucketURL(pkgRecord$remote_host) ||
isGitHubURL(pkgRecord$remote_host) ||
isGitlabURL(pkgRecord$remote_host)
if (git_remote) {
return(FALSE)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main downside is that this will do the wrong thing for users with hosted / enterprise instances of these services, when they're accessible from non-default URLs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also simply look for the presence of remote_host along with maybe remote_repo?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! I've also backed out the URL changes (those are probably better / slightly more flexible, but if they aren't needed here I don't want to increase the chance that there's a bug in there that could disrupt other things)

@jonkeane jonkeane requested a review from kevinushey October 28, 2025 12:29
Copy link
Contributor

@kevinushey kevinushey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Contributor

@karawoo karawoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it'd be good to add a test case for the remote_host/remote_repo case; otherwise LGTM

jonkeane and others added 2 commits October 28, 2025 14:21
Co-authored-by: Kara Woo <karawoo@users.noreply.github.com>
@jonkeane
Copy link
Contributor Author

Ok, I've added NEWS and will merge in a sec

@karawoo karawoo merged commit 8be367f into main Oct 28, 2025
10 checks passed
@karawoo karawoo deleted the github_name_as_repo_source branch October 28, 2025 19:47
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

Successfully merging this pull request may close these issues.

If someone names a CRAN-like repository "GitHub", restore() fails in a surprising way.

4 participants