@@ -86,18 +86,50 @@ run <- function(tutorial, ..., update = ask, ask = interactive()) {
8686 github_response(req )
8787 }
8888
89+ get_last_tag <- function () {
90+ # Check if run from within a SciViews Box
91+ hostname <- " "
92+ if (file.exists(" /etc/hostname" ))
93+ hostname <- readLines(" /etc/hostname" )[1 ]
94+ if (! grepl(" ^box[0-9]{4}" , hostname ))
95+ warning(paste(" Not run from withing a SciViews Box:" ,
96+ " no update and expect weird behavior of the tutorials" ))
97+
98+ # Get the year of the SciViews Box
99+ box_year <- substr(hostname , 4 , 7 )
100+ # Pattern is v[box_year].x.y
101+ v_pat <- paste0(" ^[vV]" , box_year , " \\ .[0-9]+\\ .[0-9]+$" )
102+
103+ # Get all tags for BioDataScience
104+ good_tags <- character (0 )
105+ all_tags_data <- try(github_GET(
106+ " repos/BioDataScience-Course/BioDataScience/releases" ),
107+ silent = TRUE )
108+ if (! inherits(all_tags_data , " try-error" )) {
109+ all_tags <- sapply(all_tags_data , getElement , " tag_name" )
110+ # Keep only tags related to this svbox
111+ good_tags <- all_tags [grepl(v_pat , all_tags )]
112+ }
113+ # Return latest (first one) among all valid tags
114+ if (length(good_tags )) good_tags [1 ] else NULL
115+ }
116+
89117 # Look what is latest release and compare with current version of the package
90118 updated <- FALSE
91119 if (isTRUE(update )) {
92- last_tag <- try(github_GET(
93- " repos/BioDataScience-Course/BioDataScience/releases/latest" )$ tag_name ,
94- silent = TRUE )
95- if (! inherits(last_tag , " try-error" ) &&
96- grepl(" ^[vV][0-9]+\\ .[0-9]+\\ .[0-9]+$" , last_tag )) {
120+ # last_tag <- try(github_GET(
121+ # "repos/BioDataScience-Course/BioDataScience/releases/latest")$tag_name,
122+ # silent = TRUE)
123+ # if (!inherits(last_tag, "try-error") &&
124+ # grepl("^[vV][0-9]+\\.[0-9]+\\.[0-9]+$", last_tag)) {
125+ last_tag <- get_last_tag()
126+ if (! is.null(last_tag )) {
97127 last_rel <- sub(" ^[vV]([0-9]+\\ .[0-9]+)\\ .([0-9]+)$" , " \\ 1-\\ 2" , last_tag )
98128 curr_rel <- sub(" ^([0-9]+\\ .[0-9]+)\\ .([0-9]+)$" , " \\ 1-\\ 2" ,
99129 packageVersion(" BioDataScience" ))
100- status <- try(compareVersion(last_rel , curr_rel ) > 0 , silent = TRUE )
130+ # In previous version we tested if compareVersion() > 0, but here, we
131+ # rather check if it is different, cf. may need to downgrade possibly
132+ status <- try(compareVersion(last_rel , curr_rel ) != 0 , silent = TRUE )
101133 if (! inherits(status , " try-error" )) {
102134 if (status > 0 ) {
103135 # We need to update the package
0 commit comments