@@ -575,9 +575,8 @@ cat_github_output() {
575575 assert_line " changes_detected=true"
576576}
577577
578- @test " script fails to push commit to new branch that does not exist yet" {
578+ @test " It pushes commit to new branch that does not exist yet" {
579579 INPUT_BRANCH=" not-existend-branch"
580- INPUT_CREATE_BRANCH=false
581580
582581 run git branch
583582 refute_line --partial " not-existend-branch"
@@ -589,25 +588,24 @@ cat_github_output() {
589588
590589 run git_auto_commit
591590
592- assert_failure
591+ assert_success
593592
594593 assert_line " INPUT_REPOSITORY value: ${INPUT_REPOSITORY} "
595594 assert_line " INPUT_BRANCH value: not-existend-branch"
596- assert_line " fatal: invalid reference: not-existend-branch"
597595
598596 run git branch
597+ assert_line --partial ${FAKE_DEFAULT_BRANCH}
599598 refute_line --partial " not-existend-branch"
600599
601600 run git branch -r
602- refute_line --partial " origin/not-existend-branch"
601+ assert_line --partial " origin/not-existend-branch"
603602
604603 run cat_github_output
605604 assert_line " changes_detected=true"
606605}
607606
608- @test " It creates new local branch and pushes the new branch to remote" {
607+ @test " It does not create new local branch and pushes the commit to a new branch on remote" {
609608 INPUT_BRANCH=" not-existend-branch"
610- INPUT_CREATE_BRANCH=true
611609
612610 run git branch
613611 refute_line --partial " not-existend-branch"
@@ -632,9 +630,12 @@ cat_github_output() {
632630 assert_line " ::debug::Apply push options "
633631 assert_line " ::debug::Push commit to remote branch not-existend-branch"
634632
633+ # Assert that local repo is still on default branch and not on new branch.
635634 run git branch
636- assert_line --partial " not-existend-branch"
635+ assert_line --partial ${FAKE_DEFAULT_BRANCH}
636+ refute_line --partial " not-existend-branch"
637637
638+ # Assert branch has been created on remote
638639 run git branch -r
639640 assert_line --partial " origin/not-existend-branch"
640641
@@ -643,8 +644,7 @@ cat_github_output() {
643644 assert_line -e " commit_hash=[0-9a-f]{40}$"
644645}
645646
646- @test " it does not create new local branch if local branch already exists" {
647-
647+ @test " It does not create new local branch if local branch already exists" {
648648 git checkout -b not-existend-remote-branch
649649 git checkout ${FAKE_DEFAULT_BRANCH}
650650
@@ -674,6 +674,11 @@ cat_github_output() {
674674 assert_line " ::debug::Apply push options "
675675 assert_line " ::debug::Push commit to remote branch not-existend-remote-branch"
676676
677+ # Assert checked out branch is still the same.
678+ run git rev-parse --abbrev-ref HEAD
679+ assert_line --partial ${FAKE_DEFAULT_BRANCH}
680+ refute_line --partial " not-existend-remote-branch"
681+
677682 run git branch
678683 assert_line --partial " not-existend-remote-branch"
679684
0 commit comments