Skip to content

Instantly share code, notes, and snippets.

@zmc
Created September 7, 2016 16:23
Show Gist options
  • Save zmc/7ae755db6f97f4569101c28eda83cd93 to your computer and use it in GitHub Desktop.
Save zmc/7ae755db6f97f4569101c28eda83cd93 to your computer and use it in GitHub Desktop.
autobuild-ceph/pull/80
16:20:54 zack@teuthology ceph master $ cat /tmp/old.sh
#!/bin/sh -x
set -e


# Reformat version if needed to match RPM version and release
if expr index $(git describe --always) '-' > /dev/null ; then
    desc=$(git describe --always | sed 's/^v//')
    RPM_VER=$(echo $desc | cut -d'-' -f1)
    RPM_REL=$(echo $desc | cut -d- -f2- | tr '-' '.')
    VER=${RPM_VER}-${RPM_REL}
fi

echo $VER
16:20:57 zack@teuthology ceph master $ cat /tmp/new.sh
#!/bin/sh -x
set -e

# Reformat version if needed to match RPM version and release
desc=$(git describe --always | sed 's/^v//')
if expr index $desc '-' > /dev/null ; then
    RPM_VER=$(echo $desc | cut -d'-' -f1)
    RPM_REL=$(echo $desc | cut -d- -f2- | tr '-' '.')
else
    RPM_VER=$desc
    RPM_REL=0
fi
VER=${RPM_VER}-${RPM_REL}

echo $VER
16:20:59 zack@teuthology ceph master $ /tmp/old.sh
+ set -e
+ git describe --always
+ expr index v11.0.0-2117-g68cf9d8 -
+ git describe --always
+ sed s/^v//
+ desc=11.0.0-2117-g68cf9d8
+ echo 11.0.0-2117-g68cf9d8
+ cut -d- -f1
+ RPM_VER=11.0.0
+ echo 11.0.0-2117-g68cf9d8
+ cut -d- -f2-
+ tr - .
+ RPM_REL=2117.g68cf9d8
+ VER=11.0.0-2117.g68cf9d8
+ echo 11.0.0-2117.g68cf9d8
11.0.0-2117.g68cf9d8
16:22:05 zack@teuthology ceph master $ /tmp/new.sh
+ set -e
+ git describe --always
+ sed s/^v//
+ desc=11.0.0-2117-g68cf9d8
+ expr index 11.0.0-2117-g68cf9d8 -
+ echo 11.0.0-2117-g68cf9d8
+ cut -d- -f1
+ RPM_VER=11.0.0
+ cut -d- -f2-
+ tr - .
+ echo 11.0.0-2117-g68cf9d8
+ RPM_REL=2117.g68cf9d8
+ VER=11.0.0-2117.g68cf9d8
+ echo 11.0.0-2117.g68cf9d8
11.0.0-2117.g68cf9d8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment