@@ -439,6 +439,65 @@ function test_convert_to_stack() {
439439 git branch -D dj/my-feature-0
440440}
441441
442+ # Test push command functionality
443+ function test_push_command() {
444+ echo " Testing push command..."
445+
446+ # Set up a fake remote to test pushing
447+ git init --bare " $TEST_DIR /remote.git"
448+ git remote add origin " $TEST_DIR /remote.git"
449+
450+ # Create a test stack with multiple branches
451+ git checkout main 2> /dev/null || git checkout master 2> /dev/null
452+ " $SCRIPT_DIR /gitstack.sh" create push-test
453+ echo " test1" > test1.txt
454+ git add test1.txt
455+ git commit -m " test1"
456+
457+ " $SCRIPT_DIR /gitstack.sh" increment
458+ echo " test2" > test2.txt
459+ git add test2.txt
460+ git commit -m " test2"
461+
462+ " $SCRIPT_DIR /gitstack.sh" increment
463+ echo " test3" > test3.txt
464+ git add test3.txt
465+ git commit -m " test3"
466+
467+ # Test push from current stack branch
468+ if " $SCRIPT_DIR /gitstack.sh" push 2>&1 | grep -q " Successfully force-pushed all branches" ; then
469+ echo " ✅ push command successfully pushed from current stack"
470+ else
471+ fail " push command failed to push from current stack"
472+ fi
473+
474+ # Verify all branches were pushed to remote
475+ local remote_branches
476+ remote_branches=$( git ls-remote --heads origin | awk ' {print $2}' | sed ' s|refs/heads/||' )
477+
478+ if echo " $remote_branches " | grep -q " push-test-0" && \
479+ echo " $remote_branches " | grep -q " push-test-1" && \
480+ echo " $remote_branches " | grep -q " push-test-2" ; then
481+ echo " ✅ All stack branches successfully pushed to remote"
482+ else
483+ fail " Not all stack branches were pushed to remote"
484+ fi
485+
486+ # Test push with explicit stack name from different branch
487+ git checkout main 2> /dev/null || git checkout master 2> /dev/null
488+ if " $SCRIPT_DIR /gitstack.sh" push push-test 2>&1 | grep -q " Successfully force-pushed all branches" ; then
489+ echo " ✅ push command with explicit stack name worked"
490+ else
491+ fail " push command with explicit stack name failed"
492+ fi
493+
494+ # Clean up
495+ git remote remove origin
496+ rm -rf " $TEST_DIR /remote.git"
497+ " $SCRIPT_DIR /gitstack.sh" delete -f push-test
498+ rm -f test1.txt test2.txt test3.txt
499+ }
500+
442501# Run all tests
443502function run_all_tests() {
444503 source_gitstack
@@ -450,6 +509,7 @@ function run_all_tests() {
450509 test_fix_command
451510 test_stack_navigation
452511 test_convert_to_stack
512+ test_push_command
453513}
454514
455515# Create a temporary test directory
0 commit comments