test(flog): update flog test

pull/17/head
Kevin Zhuang 4 years ago
parent b1ee2f11fa
commit ec37d7914b

@ -59,7 +59,7 @@ function draw_menu() {
menu="${menu}checkout: checkout the selected commit\n"
menu="${menu}exit: quit dotbare flog"
message=$(
/usr/bin/git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" \
git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" \
log --format=%B -n 1 "${selected_commit}"
)
header="commit ${selected_commit}: ${message}"
@ -130,19 +130,19 @@ fi
case "${selected_action}" in
revert)
/usr/bin/git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" \
git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" \
revert "${selected_commit}"
;;
reset)
/usr/bin/git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" \
git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" \
reset "${selected_commit}"
;;
edit)
/usr/bin/git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" \
git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" \
rebase -i "${selected_commit}"~
;;
checkout)
/usr/bin/git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" \
git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" \
checkout "${selected_commit}"
;;
exit)

@ -30,20 +30,12 @@ reset() {
[ "${lines[0]}" = "Invalid option: -p" ]
}
@test "flog check routing" {
if ! "${BATS_TEST_DIRNAME}"/../dotbare log &>/dev/null; then
skip
fi
@test "flog menu" {
run menu
[ "${status}" -eq 0 ]
}
@test "flog reset" {
if ! "${BATS_TEST_DIRNAME}"/../dotbare log &>/dev/null; then
skip
fi
run reset
[ "${status}" -eq 129 ]
[[ "${output}" =~ "usage: git reset [--mixed | --soft | --hard | --merge | --keep] [-q] [<commit>]" ]]
[[ "${output}" =~ "flog_reset" ]]
[[ "${output}" =~ "reset --flog_reset" ]]
}

@ -39,6 +39,9 @@ elif [[ "$*" =~ "--header=select tracked files to edit" ]]; then
elif [[ "$*" =~ '--no-multi --header=select the target commit for HEAD' ]] && [[ "$*" =~ "show --color" ]]; then
# dotbare freset --commit -y -- "./freset.bats" @test "freset select commit"
echo "--freset_commit"
elif [[ "$*" =~ "--no-multi --header=commit --flog_reset" ]]; then
# dotbare flog -- "./flog.bats" @test "flog checkout routing"
echo "exit"
elif [[ "$*" =~ '--header=select a commit' ]] && [[ "$*" =~ "show --color" ]]; then
# dotbare flog --reset -y -- "./flog.bats" @test "flog reset"
echo "--flog_reset"
@ -57,9 +60,6 @@ elif [[ "$*" =~ '--header=select stash to apply' ]] && [[ "$*" =~ "show -p __ --
elif [[ "$*" =~ "--header=select files to unstage" ]] && [[ "$*" =~ "diff HEAD --color=always" ]]; then
# dotbare freset -- "./freset.bats" @test "freset select files"
echo "-- freset_file"
elif [[ "$*" =~ "--no-multi --header=commit --flog_reset" ]]; then
# dotbare flog -- "./flog.bats" @test "flog checkout routing"
echo "exit"
else
echo "$@"
fi

Loading…
Cancel
Save