libexec/compare in alpha_omega-0.0.151 vs libexec/compare in alpha_omega-0.0.152

- old
+ new

@@ -12,11 +12,11 @@ fi fi tmp_version=$(mktemp -t XXXXXXXXX) if [[ -n $local_file ]]; then - cp VERSION $tmp_version + cat VERSION | perl -ne 'm{^\s*v?(\d+)\.(\d+)\.(\d+)\s*$} && printf("%03d.%03d.%03d %d.%d.%d\n",$1,$2,$3,$1,$2,$3)' | sort -r | head -1 | awk '{print $2}' > $tmp_version else git tag | perl -ne 'm{^v(\d+)\.(\d+)\.(\d+)$} && printf("%03d.%03d.%03d %d.%d.%d\n",$1,$2,$3,$1,$2,$3)' | sort -r | head -1 | awk '{print $2}' > $tmp_version fi case "$1" in @@ -35,41 +35,45 @@ ;; esac > $tmp_version ;; *) ver_new=$1; shift - set $(echo "$ver_new" | sed 's#\.# #g') 0 - M=$1; shift - m=$1; shift - p=$1; shift - - (echo "$(($M+0)).$(($m+0)).$(($p+0))" > $tmp_version) 2>&- - ver_new_same=$(cat $tmp_version) - - if [[ $ver_new != $ver_new_same ]]; then - echo "ERROR: invalid version: $ver_new" 1>&2 - exit 1 - fi + ver_new=${ver_new#v} + echo $ver_new > $tmp_version ;; esac - ver_bumped=$(cat $tmp_version) + ver_new=$(cat $tmp_version) + set $(echo "$ver_new" | sed 's#\.# #g') 0 + M=$1; shift + m=$1; shift + p=$1; shift + + (echo "$(($M+0)).$(($m+0)).$(($p+0))" > $tmp_version) 2>&- + ver_new_same=$(cat $tmp_version) + + if [[ $ver_new != $ver_new_same ]]; then + echo "ERROR: invalid version: $ver_new" 1>&2 + exit 1 + fi + + ver_bumped="v$(cat $tmp_version)" rm -f $tmp_version - ensure_git_tag_available "v$ver_bumped" + ensure_git_tag_available $ver_bumped if [[ -n $local_file ]]; then - echo $ver_bumped > VERSION + echo ${ver_bumped#v} > VERSION git add VERSION if [[ -f Gemfile ]]; then bundle check 2>&1 >/dev/null || { bundle --quiet install --local --path vendor/bundle || bundle check > /dev/null; } git add Gemfile.lock fi git commit -m "bump: $ver_bumped" git push fi - git_tag "v$ver_bumped" + git_tag "$ver_bumped" echo $ver_bumped } function ensure_git_tag_available { version=$1; shift