added version increment script

This commit is contained in:
hellerve
2016-08-29 19:06:24 +02:00
parent bed68d00ea
commit b0dbbb19e3
2 changed files with 32 additions and 1 deletions

30
.scripts/vincr.zp Normal file
View File

@@ -0,0 +1,30 @@
(define (die msg)
(begin
(write msg)
(exit 1)))
(define (usage)
(die "increment_version [position]\n\tposition defaults to 2"))
(define (parse-args)
(cond
((eq? 0 (length zepto:args)) 2)
((and (string:num? (car zepto:args))
(eq? 1 (length zepto:args)))
(string->number (car zepto:args)))
(else (usage))))
(define (main position)
(if (not (file-exists? "VERSION"))
(die "A version file is needed in the current directory")
(let* ((version (read-contents "VERSION"))
(new-version (|> (string:split version ".")
(curry map string->number)
list->vector
($ (vector:update % position add1))
(curry vector:map number->string)
($ (string:join % ".")))))
(with-output-file "VERSION" (curry write new-version)))))
(main (parse-args))
(exit 0)

3
zshrc
View File

@@ -38,6 +38,7 @@ alias dob="git branch --merged | grep -vE '(\*)|(master)|(dev)' | xargs -n 1 git
alias vi="stty stop '' -ixoff ; vim" alias vi="stty stop '' -ixoff ; vim"
alias gcc="gcc-6" alias gcc="gcc-6"
alias g++="g++-6" alias g++="g++-6"
alias increment_version="zepto ~/.scripts/vincr.zp"
alias psh="perl ~/.scripts/psh" alias psh="perl ~/.scripts/psh"
alias push="git push" alias push="git push"
alias pull="git pull" alias pull="git pull"
@@ -418,4 +419,4 @@ function zeptosay () {
fortune | zeptosay fortune | zeptosay
#source ~/.zshrc.priv source ~/.zshrc.priv