Skip to content

Commit a07c957

Browse files
committed
Get rid of rematch2 dependency (which was bringing in tibble)
Closes #437
1 parent 9feea31 commit a07c957

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

DESCRIPTION

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ Imports:
2929
gh,
3030
git2r (>= 0.23),
3131
glue,
32-
rematch2,
3332
rlang,
3433
rprojroot (>= 1.2),
3534
rstudioapi,

NEWS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ build paths within it (#415, #425).
5151

5252
New Imports: fs, glue, utils
5353

54-
No longer in Imports: backports, httr, rmarkdown (moved to Suggests), styler (moved to Suggests)
54+
No longer in Imports: backports, httr, rematch2, rmarkdown (moved to Suggests), styler (moved to Suggests)
5555

5656
# usethis 1.3.0
5757

R/browse.R

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,39 @@ github_url_rx <- function() {
110110
## output: "https://github.com/r-lib/gh"
111111
github_home <- function(package = NULL) {
112112
gh_link <- github_link(package)
113-
df <- rematch2::re_match(gh_link, github_url_rx())
113+
df <- re_match_inline(gh_link, github_url_rx())
114114
glue("https://github.com/{df$owner}/{df$repo}")
115115
}
116+
117+
## inline a simplified version of rematch2::re_match()
118+
re_match_inline <- function(text, pattern) {
119+
match <- regexpr(pattern, text, perl = TRUE)
120+
start <- as.vector(match)
121+
length <- attr(match, "match.length")
122+
end <- start + length - 1L
123+
124+
matchstr <- substring(text, start, end)
125+
matchstr[ start == -1 ] <- NA_character_
126+
127+
res <- data.frame(
128+
stringsAsFactors = FALSE,
129+
.text = text,
130+
.match = matchstr
131+
)
132+
133+
if (!is.null(attr(match, "capture.start"))) {
134+
135+
gstart <- attr(match, "capture.start")
136+
glength <- attr(match, "capture.length")
137+
gend <- gstart + glength - 1L
138+
139+
groupstr <- substring(text, gstart, gend)
140+
groupstr[ gstart == -1 ] <- NA_character_
141+
dim(groupstr) <- dim(gstart)
142+
143+
res <- cbind(groupstr, res, stringsAsFactors = FALSE)
144+
}
145+
146+
names(res) <- c(attr(match, "capture.names"), ".text", ".match")
147+
res
148+
}

0 commit comments

Comments
 (0)