Skip to content

Commit

Permalink
Merge pull request #89 from inbo/88-bug-increment-version-doesnt-work…
Browse files Browse the repository at this point in the history
…-like-it-should

Update increment_version.R
  • Loading branch information
SanderDevisscher authored Oct 11, 2024
2 parents d362595 + f3aa0be commit 26a9dd7
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: fistools
Title: Tools & data used for wildlife management & invasive species in Flanders
Version: 1.2.10
Version: 1.2.11
Authors@R: c(
person(given = "Sander", middle = "", family = "Devisscher", "[email protected]",
role = c("aut", "cre"), comment = c(ORCID = "0000-0003-2015-5731")),
Expand Down
49 changes: 48 additions & 1 deletion preprocessing/increment_version.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,55 @@ if(grepl("new-function", branch) |
}

# Check if the version in the DESCRIPTION file is lower than the one in the package
# Convert to a list of numbers
version_local <- as.numeric(unlist(strsplit(version_local, "\\.")[1]))
version_remote <- as.numeric(unlist(strsplit(version_remote, "\\.")[1]))

if(version_local == version_remote){
maj_local <- version_local[1]
maj_remote <- version_remote[1]

min_local <- version_local[2]
min_remote <- version_remote[2]

patch_local <- version_local[3]
patch_remote <- version_remote[3]

increment <- FALSE
# equilise the version:
# larger major version in remote
while(maj_local < maj_remote){
message("The local version in DESCRIPTION file is lower than the one in the package")
usethis::use_version(which = "major", push = FALSE)
maj_local <- maj_local + 1
increment <- TRUE
}

# larger minor version in remote
if(maj_local == maj_remote){
while(min_local < min_remote){
message("The local version in DESCRIPTION file is lower than the one in the package")
usethis::use_version(which = "minor", push = FALSE)
min_local <- min_local + 1
increment <- TRUE
}
}

# larger patch version in remote
if(maj_local == maj_remote & min_local == min_remote){
while(patch_local < patch_remote){
message("The local version in DESCRIPTION file is lower than the one in the package")
usethis::use_version(which = "patch", push = FALSE)
patch_local <- patch_local + 1
increment <- TRUE
}
}

if(maj_local == maj_remote & min_local == min_remote & patch_local == patch_remote){
message("The local version in DESCRIPTION file is equal to the one in the package")
increment <- TRUE
}

if(increment){
usethis::use_version(which = type)
}else{
print("Version in DESCRIPTION file is already higher than the one in the package")
Expand Down

0 comments on commit 26a9dd7

Please sign in to comment.