Skip to content

Commit e3071ae

Browse files
committed
add get_github_url
1 parent 3b1ca4e commit e3071ae

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

R/get_github_url.R

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
get_github_url <- function(desc_file){
2-
if(length(grep("github",desc_file$URL))>0){
3-
return(desc_file$URL)
2+
## These fields sometimes contain >1 link.
3+
## Find the one that's actually for the GitHub repo.
4+
get_gh <- function(URL){
5+
urls <- trimws(strsplit(URL,",")[[1]])
6+
grep("https://github.com", urls, value = TRUE)
7+
}
8+
#### Parse ####
9+
if(length(grep("github",desc_file$URL))>0){
10+
return(get_gh(desc_file$URL))
411
} else if (length(grep("github",desc_file$BugReports))>0){
512
return(
6-
trimws(gsub("issues$","",desc_file$BugReports),
13+
trimws(gsub("issues$","",get_gh(desc_file$BugReports)),
714
whitespace = "/")
815
)
916
} else if (!is.null(desc_file$git_url)){
@@ -15,4 +22,4 @@ get_github_url <- function(desc_file){
1522
} else {
1623
return(NULL)
1724
}
18-
}
25+
}

0 commit comments

Comments
 (0)