Skip to content

Added failing unit test for most common case; switching while file not in cwd#40

Open
TamaMcGlinn wants to merge 1 commit intoThePrimeagen:masterfrom
TamaMcGlinn:feature/fix_repo_root
Open

Added failing unit test for most common case; switching while file not in cwd#40
TamaMcGlinn wants to merge 1 commit intoThePrimeagen:masterfrom
TamaMcGlinn:feature/fix_repo_root

Conversation

@TamaMcGlinn
Copy link
Copy Markdown

@TamaMcGlinn TamaMcGlinn commented May 5, 2021

it is clear in this test that we would want to open file A.txt in the target dir, since we were editing A and A exists in the target. However, what actually happens is that '../featC/A.txt' is not found to be present in featD and hence it opens the root directory of the worktree. (I believe the test currently fails even slightly earlier, in switching, but this is probably due to not understanding the test framework; when I go through the steps manually in vim the switch of the cwd to featD does occur)

@polarmutex
Copy link
Copy Markdown
Collaborator

the test is failing early because the test repo does not contain a branch name featD, there is just master with A.txt, featB with A.txt and B.txt, and featC with A.txt and C.txt

@ThePrimeagen
Copy link
Copy Markdown
Owner

Is there any resolve on this? Is this a failing case, or a non case?

@polarmutex @TamaMcGlinn

@TamaMcGlinn
Copy link
Copy Markdown
Author

it fails, but not in the right way.

Success ||      git-worktree Switch in a featB worktree(bare) with file A open, switch to featC and switch to file A in other worktree
2 / 2: Running post switch callbacks
1 / 2: Checking for worktree featB
2 / 2: Running post switch callbacks
Fail    ||      git-worktree Switch in a featB worktree(bare) with file A inside featC open, switch to featD and switch to file A in other worktree
            ./tests/git_harness.lua:283: Vim:Error executing luv callback:
            ./lua/git-worktree/status.lua:63: 1 / 2: worktree does not exists, please create it first featD

            stack traceback:
                ./tests/git_harness.lua:283: in function <./tests/git_harness.lua:261>

How do I add the featD worktree?

@polarmutex
Copy link
Copy Markdown
Collaborator

In the test folder
Rename the .git-orig to .git
Then create a new branch
Then rename back

@TamaMcGlinn TamaMcGlinn force-pushed the feature/fix_repo_root branch from 86a8fe4 to 7abb179 Compare July 19, 2021 05:59
@TamaMcGlinn
Copy link
Copy Markdown
Author

Thank you, now it fails on the correct assertion - that the file is indeed not opened after switching to a worktree which has that file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants