autoriser --allow-emptyp pour l'action --show

This commit is contained in:
Jephté Clain 2015-03-23 14:39:10 +04:00
parent f90ad4d061
commit 9389fb01e8
1 changed files with 15 additions and 5 deletions

View File

@ -134,6 +134,7 @@ function pver() {
local file= local file=
local git= local git=
local version= local version=
local allow_empty=
local convert=auto local convert=auto
local operator= local operator=
local oversion= local oversion=
@ -154,6 +155,7 @@ function pver() {
-g:,--git-string: '$set@ git; source=git-string' \ -g:,--git-string: '$set@ git; source=git-string' \
-s:,--string: '$set@ version; source=string' \ -s:,--string: '$set@ version; source=string' \
--show action=show \ --show action=show \
--allow-empty allow_empty=1 \
--check action=check \ --check action=check \
--convert convert=1 \ --convert convert=1 \
--no-convert convert= \ --no-convert convert= \
@ -230,7 +232,8 @@ function pver() {
version="$(git cat-file blob "$branch:$name" 2>/dev/null)" version="$(git cat-file blob "$branch:$name" 2>/dev/null)"
fi fi
fi fi
[ -n "$version" ] || version=0.0.0 [ "$action" == show ] || allow_empty=
[ -n "$version" -o -n "$allow_empty" ] || version=0.0.0
# Conversion éventuelle du numéro de version # Conversion éventuelle du numéro de version
psemver_parse "$version" psemver_parse "$version"
@ -306,12 +309,19 @@ BEGIN {
# Actions # Actions
if [ "$action" == show ]; then if [ "$action" == show ]; then
if isatty; then if [ -n "$version" ]; then
estepi "La version actuelle est $version" if isatty; then
estepi "La version actuelle est $version"
else
echo "$version"
fi
return 0
else else
echo "$version" if isatty; then
estepi "Il n'y a pas de version définie"
fi
return 1
fi fi
return 0
fi fi
if [ "$action" == check ]; then if [ "$action" == check ]; then