Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Cannot checkout current branch #555

Closed
oliv3r opened this issue Jan 14, 2024 · 2 comments
Closed

[BUG] Cannot checkout current branch #555

oliv3r opened this issue Jan 14, 2024 · 2 comments
Assignees

Comments

@oliv3r
Copy link

oliv3r commented Jan 14, 2024

While trying to debug by reproducing ERROR:kicad-diff.py:Nothing to compare! here https://gitlab.com/olliver/lapod/-/jobs/5926844760, I noticed that things may not work as expected when trying to compare using the branch that is the same as the currently checked out branch. This because git worktree refuses to checkout the same branch twice. Normally this is not a good idea, as one might be committing to the same branch from two different locations, but kibot only does read-only operations, so this is a non-issue, and kibot also removes the created branch afterwards. Because of that, we probably should use the --force parameter to git worktree add.

ERROR:Running ['/usr/bin/git', 'worktree', 'add', '/tmp/tmpfd90sbcp', 'dev'] returned 128 (kibot.gs - gs.py:791)
I have no name!@3c5acab7ecdb:/workspace/lapod/hello$ git worktree list
/workspace/lapod  815ec22 [dev]
I have no name!@3c5acab7ecdb:/workspace/lapod/hello$ git worktree add /tmp/asdf dev
Preparing worktree (checking out 'dev')
fatal: 'dev' is already checked out at '/workspace/lapod'
I have no name!@3c5acab7ecdb:/workspace/lapod/hello$ git worktree add -f /tmp/asdf dev
Preparing worktree (checking out 'dev')
HEAD is now at 815ec22 test
I have no name!@3c5acab7ecdb:/workspace/lapod/hello$ git worktree list
/workspace/lapod  815ec22 [dev]
/tmp/asdf         815ec22 [dev]

P.S. My issue might be due to some caching of the git tree, the worktree that kibot adds, based on the branch name, is some old/weird sha. I am doing GIT_DIFF_REF_NEW: "${CI_COMMIT_REF_NAME}" right now, where CI_COMMIT_REF_NAME should be the current relevant branch name, which is nicer in the filename then HEAD, so if this is the issue, and a --force, then I may need to add a bug report for that :)
Looking at the history, might be related to either 9ea3e39, as it was working fine before, or gitlab cache issue, where the 'dev' branch is not up to date (they clone and checkout 'HEAD', not a specific branch.

@set-soft
Copy link
Member

Hi @oliv3r !

During normal use you shouldn't need to checkout the same branch twice. But is true that you could get a collision if you don't pay attention.

The above patch adds a --force

@oliv3r
Copy link
Author

oliv3r commented Jan 15, 2024

Thanks @set-soft!!

I agree on the 'normally', but the patch is still wise I recon, especially since we are in a contained environment, doing our own cleanup.

Sadly, this didn't fix my bug :( So I'll investigate as to what causes 'Nothing to compare', and see if it is indeed a caching issue with gitlab, and just requires me to forcefully do a 'git fetch'.

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

No branches or pull requests

2 participants