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

project: Add origin remote #546

Closed
Closed
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
16 changes: 16 additions & 0 deletions src/west/app/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -1243,6 +1243,14 @@ def init_project(self, project):
# However, west always fetches project data by URL, not name.
# The user is therefore free to change the URL of this remote.
project.git(f'remote add -- {project.remote_name} {project.url}')

# Git submodules that use relative paths resolve them based
# on `origin` remote, make sure we have it
try:
project.git(f'remote get-url -- origin')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would not have helped in the case of sof.

Cause with Zephyr, the sof repo here:
https://github.com/zephyrproject-rtos/sof/

is a fork of:
https://github.com/thesofproject/sof

but the rimage repo has not been forked:
https://github.com/zephyrproject-rtos/rimage/

so even configuring a origin remote would not help in this case.

If users want to combine west and git submodules I think it is fair to set a requirement that all submodules must use real urls and not relative paths.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but the rimage repo has not been forked:

That's because Zephyr CI does not need rimage, at least not yet.

I'm pretty sure Zephyr has a requirement that all the code in the default, public west.yml manifest must come from a https://github.com/zephyrproject-rtos/ copy to make sure upstream projects don't come and go and maybe for other reasons. I doubt git submodules create an allowed "loophole", do they?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I doubt git submodules create an allowed "loophole", do they?

I don't think so, but that's not the main point.
Please see here for elaborated reason on why this is bad: #545 (comment)

except subprocess.CalledProcessError:
project.git(f'remote add -- origin {project.url}')

else:
log.small_banner(f'{project.name}: cloning from {cache_dir}')
# Clone the project from a local cache repository. Set the
Expand All @@ -1253,6 +1261,14 @@ 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])

# Git submodules that use relative paths resolve them based
# on `origin` remote, make sure we have it
try:
project.git(f'remote get-url -- origin')
except subprocess.CalledProcessError:
project.git(f'remote add -- origin {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')
Expand Down