Feature: sync a branch whose tracking branch was shipped in offline mode

  Background:
    Given the feature branches "feature-1" and "feature-2"
    And the commits
      | BRANCH    | LOCATION      | MESSAGE          | FILE NAME      | FILE CONTENT      |
      | feature-1 | local, origin | feature-1 commit | feature-1-file | feature 1 content |
      | feature-2 | local, origin | feature-2 commit | feature-2-file | feature 2 content |
    And origin ships the "feature-1" branch
    And the current branch is "feature-1"
    And an uncommitted file
    And offline mode is enabled
    When I run "git-town sync"

  Scenario: result
    Then it runs the commands
      | BRANCH    | COMMAND                              |
      | feature-1 | git add -A                           |
      |           | git stash                            |
      |           | git checkout main                    |
      | main      | git rebase origin/main               |
      |           | git checkout feature-1               |
      | feature-1 | git merge --no-edit origin/feature-1 |
      |           | git merge --no-edit main             |
      |           | git stash pop                        |
    And the current branch is still "feature-1"
    And the uncommitted file still exists
    And the initial branches and lineage exist

  Scenario: undo
    When I run "git-town undo"
    Then it runs the commands
      | BRANCH    | COMMAND       |
      | feature-1 | git add -A    |
      |           | git stash     |
      |           | git stash pop |
    And the current branch is now "feature-1"
    And the uncommitted file still exists
    And the initial branches and lineage exist
