From b18e0557e68df7c439d483f1a9990aa12f9cb9ad Mon Sep 17 00:00:00 2001 From: Arni Magnusson Date: Wed, 11 Dec 2019 09:59:35 +0100 Subject: [PATCH] Parse @ref first, then owner/repo/subdir --- DESCRIPTION | 2 +- NEWS | 3 ++- R/parse.repo.R | 15 ++++++++------- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 8ab9288..6daa76d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: icesTAF Version: 3.3-1 -Date: 2019-12-06 +Date: 2019-12-11 Title: Functions to Support the ICES Transparent Assessment Framework Authors@R: c(person("Arni", "Magnusson", role=c("aut","cre"), email="arni.magnusson@ices.dk"), person("Colin", "Millar", role="aut"), diff --git a/NEWS b/NEWS index 2eb10ac..878c441 100644 --- a/NEWS +++ b/NEWS @@ -1,7 +1,8 @@ -------------------------------------------------------------------------------- -icesTAF 3.3-1 (2019-12-06) +icesTAF 3.3-1 (2019-12-11) -------------------------------------------------------------------------------- o Improved handling of SOFTWARE.bib GitHub entries that have owner/repo/subdir. + Code contributed by Ibrahim Umar. o Improved process.bib() so it verifies that 'access' values match the allowed values. diff --git a/R/parse.repo.R b/R/parse.repo.R index 8a73f3f..9fd44d5 100644 --- a/R/parse.repo.R +++ b/R/parse.repo.R @@ -8,14 +8,15 @@ parse.repo <- function(repo) { - x <- unlist(strsplit(repo, "/")) - - username <- head(x, 1) - repo.ref <- tail(x, 1) - subdir <- if(length(x) == 2) "" else unlist(strsplit(x[3], "@"))[1] + ## 1 Read ref, then remove @reference tail + ref <- if(grepl("@",repo)) unlist(strsplit(repo,"@"))[2] else "" + repo <- sub("@.*", "", repo) - repo <- if(length(x) == 2) unlist(strsplit(repo.ref, "@"))[1] else x[2] - ref <- if(grepl("@", repo.ref)) unlist(strsplit(repo.ref, "@"))[2] else "" + ## 2 Read username, repo, subdir + x <- unlist(strsplit(repo, "/")) + username <- x[1] + repo <- x[2] + subdir <- if(length(x) > 2) paste(x[-c(1,2)],collapse="/") else "" list(username=username, repo=repo, subdir=subdir, ref=ref) }