refactor(release): unify ask via global ANSWER variable
This commit is contained in:
+8
-9
@@ -40,11 +40,11 @@ bump() {
|
|||||||
echo implode(".", $p);' "$1" "$2"
|
echo implode(".", $p);' "$1" "$2"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ANSWER=""
|
||||||
|
|
||||||
ask() {
|
ask() {
|
||||||
local prompt="$1" reply
|
printf '%s' "$1" >&2
|
||||||
printf '%s' "$prompt" >&2
|
read -r ANSWER || die "entrada agotada; pasa los argumentos o correlo en un TTY"
|
||||||
read -r reply || die "entrada agotada; pasa los argumentos o correlo en un TTY"
|
|
||||||
printf '%s' "$reply"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSUME_YES=0
|
ASSUME_YES=0
|
||||||
@@ -58,9 +58,8 @@ done
|
|||||||
|
|
||||||
confirm() {
|
confirm() {
|
||||||
[ "$ASSUME_YES" = "1" ] && return 0
|
[ "$ASSUME_YES" = "1" ] && return 0
|
||||||
local r
|
ask "$1 [Y/n] "
|
||||||
r="$(ask "$1 [Y/n] ")"
|
case "${ANSWER,,}" in ""|y|yes) return 0 ;; *) return 1 ;; esac
|
||||||
case "${r,,}" in ""|y|yes) return 0 ;; *) return 1 ;; esac
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# --- eleccion de paquete -----------------------------------------------------
|
# --- eleccion de paquete -----------------------------------------------------
|
||||||
@@ -74,7 +73,7 @@ else
|
|||||||
printf ' %2d) %-10s v%s\n' "$((i + 1))" "${PKGS[i]}" "$(version_of "${PKGS[i]}")"
|
printf ' %2d) %-10s v%s\n' "$((i + 1))" "${PKGS[i]}" "$(version_of "${PKGS[i]}")"
|
||||||
done
|
done
|
||||||
while :; do
|
while :; do
|
||||||
R="$(ask 'Elegir paquete (numero o nombre): ')"
|
ask 'Elegir paquete (numero o nombre): '; R="$ANSWER"
|
||||||
if [[ "$R" =~ ^[0-9]+$ ]] && [ "$R" -ge 1 ] && [ "$R" -le "${#PKGS[@]}" ]; then
|
if [[ "$R" =~ ^[0-9]+$ ]] && [ "$R" -ge 1 ] && [ "$R" -le "${#PKGS[@]}" ]; then
|
||||||
PACKAGE="${PKGS[R - 1]}"
|
PACKAGE="${PKGS[R - 1]}"
|
||||||
break
|
break
|
||||||
@@ -93,7 +92,7 @@ if [ "${#POSITIONAL[@]}" -ge 2 ]; then
|
|||||||
else
|
else
|
||||||
while :; do
|
while :; do
|
||||||
printf 'Incremento para %s (actual v%s):\n 1) patch\n 2) minor\n 3) major\n' "$PACKAGE" "$(version_of "$PACKAGE")" >&2
|
printf 'Incremento para %s (actual v%s):\n 1) patch\n 2) minor\n 3) major\n' "$PACKAGE" "$(version_of "$PACKAGE")" >&2
|
||||||
R="$(ask 'Elegir (numero o nombre): ')"
|
ask 'Elegir (numero o nombre): '; R="$ANSWER"
|
||||||
case "$R" in
|
case "$R" in
|
||||||
1|patch) TYPE=patch; break ;;
|
1|patch) TYPE=patch; break ;;
|
||||||
2|minor) TYPE=minor; break ;;
|
2|minor) TYPE=minor; break ;;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ Harness::it('release bumpea, commitea, tagea y publica', function () {
|
|||||||
seed_package($repo, '1.2.3');
|
seed_package($repo, '1.2.3');
|
||||||
git_commit($repo, 'init');
|
git_commit($repo, 'init');
|
||||||
|
|
||||||
exec('cd ' . escapeshellarg($repo) . ' && bash scripts/release http minor', $out, $code);
|
exec('cd ' . escapeshellarg($repo) . ' && bash scripts/release http minor --yes', $out, $code);
|
||||||
eq(0, $code, 'release debe terminar bien: ' . implode("\n", $out));
|
eq(0, $code, 'release debe terminar bien: ' . implode("\n", $out));
|
||||||
|
|
||||||
$pushed = exec('git -C ' . escapeshellarg($repo) . ' tag -l "http-v1.3.0"');
|
$pushed = exec('git -C ' . escapeshellarg($repo) . ' tag -l "http-v1.3.0"');
|
||||||
|
|||||||
Reference in New Issue
Block a user