Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions src/west/app/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -1821,29 +1821,6 @@ def init_project(self, project):
)
# Reset the remote's URL to the project's fetch URL.
project.git(['remote', 'set-url', project.remote_name, project.url])
# Make sure we have a detached HEAD so we can delete the
# local branch created by git clone.
project.git('checkout --quiet --detach HEAD')
# Find the name of any local branch created by git clone.
# West commits to only touching 'manifest-rev' in the
# local branch name space.
local_branches = (
project.git(
['for-each-ref', '--format', '%(refname)', 'refs/heads/*'], capture_stdout=True
)
.stdout.decode('utf-8')
.splitlines()
)
# This should contain at most one branch in current
# versions of git, but we might as well get them all just
# in case that changes.
for branch in local_branches:
if not branch:
continue
# This is safe: it can't be garbage collected by git before we
# have a chance to use it, because we have another ref, namely
# f'refs/remotes/{project.remote_name}/{branch}'.
project.git(['update-ref', '-d', branch])

def project_auto_cache(self, project):
if self.auto_cache is None:
Expand Down
13 changes: 13 additions & 0 deletions tests/test_project_caching.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,19 @@ def setup_workspace_and_west_update(workspace, foo_head, bar_head):
for msg in msgs:
assert msg in stdout

# Rename remote default branches and update remote (results in dangling remote HEAD).
subprocess.check_call([GIT, 'branch', '-m', 'master', 'renamed-master'], cwd=foo_remote)
subprocess.check_call([GIT, 'branch', '-m', 'master', 'changed/main'], cwd=bar_remote)
subprocess.check_call([GIT, 'remote', 'update', '--prune'], cwd=auto_cache_dir_foo)
subprocess.check_call([GIT, 'remote', 'update', '--prune'], cwd=auto_cache_dir_bar)

# west update must succeed
setup_workspace_and_west_update(
tmpdir / 'workspace5',
foo_head='renamed-master',
bar_head='changed/main',
)


def test_update_caches_priorities(tmpdir):
# Test that the correct cache is used if multiple caches are specified
Expand Down