]> git.rmz.io Git - dotfiles.git/commitdiff
vim: add pkgver to PKGBUILD snippets
authorSamir Benmendil <samir.benmendil@gmail.com>
Tue, 27 Jan 2015 22:10:24 +0000 (22:10 +0000)
committerSamir Benmendil <samir.benmendil@gmail.com>
Tue, 27 Jan 2015 22:10:24 +0000 (22:10 +0000)
vim/ultisnips/PKGBUILD.snippets

index ef52592062397c7e6e1e09b8cfb4692a247b24c5..b18ae811cc5cabf50985e11dc4ed4a0d49066acf 100644 (file)
@@ -1,23 +1,33 @@
+snippet pkgver "pkgver() function" b
+pkgver() {
+  cd ${1:$pkgname-$pkgver}
+  ( set -o pipefail
+    git describe --long --tags 2>/dev/null | sed 's/\([^-]*-g\)/r\1/;s/-/./g' ||
+    printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
+  )
+}
+endsnippet
+
 snippet prep "prepare() function" b
 prepare() {
-       cd ${1:$pkgname-$pkgver}
-       $0
+  cd ${1:$pkgname-$pkgver}
+  $0
 }
 endsnippet
 
 snippet build "build() function" b
 build() {
-       cd ${1:$pkgname-$pkgver}
-       ./configure \
-               --prefix=/usr $2
-       $0
+  cd ${1:$pkgname-$pkgver}
+  ./configure \
+    --prefix=/usr $2
+  $0
 }
 endsnippet
 
 snippet pack "package() function" b
 package() {
-       cd ${1:$pkgname-$pkgver}
-       make DESTDIR="$pkgdir" install
-       $0
+  cd ${1:$pkgname-$pkgver}
+  make DESTDIR="$pkgdir" install
+  $0
 }
 endsnippet