Debian Codegraph @

tools/set-version

raw
1 #!/usr/bin/env Rscript
2
3 get_version_from_git <- function() {
4 tag <- system2("git", c("describe", "--tags", "--match", "v*"),
5 stdout=TRUE, stderr=TRUE)
6 is_clean <- system2("git", c("diff-index", "--quiet", tag)) == 0
7 tt <- sub("v", "", tag, fixed=TRUE)
8 tt <- paste(strsplit(tt, "-")[[1]][1:2], collapse="-")
9 if (!is_clean)
10 tt <- sub("-.*", sprintf("-%i", as.integer(Sys.time())), tt)
11 tt
12 }
13
14 desc <- read.dcf("pkg/DESCRIPTION")
15 desc[,"Version"] <- get_version_from_git()
16 write.dcf(desc, file="pkg/DESCRIPTION")