WIP: make_update: support Github style of remote organization #104479

Closed
Sergey Sharybin wants to merge 1 commits from Sergey:make_update into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.

This is rather common workflow in all sort of forges like Github, Gitlab,
perhaps even Gitea. Having better support of our tools for it seems to
have string benefits.

The idea of this change is to make it so make update will perform the
steps needed to update the branch of the fork to the upstream version.

This includes:

  • Fetch the upstream remote
  • git merge --ff-only upstream/branch if the current branch exists in
    the upstream.
  • If the branch does not exist in the upstream, then it will be pulled
    from the origin instead (the behavior prior to this change).

The same logic is implemented for the submodules.

The make update will also check for the forked submodules within the
same user/organization as the blender.git fork and add the "origin" to
the submodule when such a fork is detected. This allows to fork the
submodule repository after the make update has been run for the first
time.

Some of the new code still follows the old os.path convention. This is
to avoid a bigger refactor or endanger some things not working. Such a
refactor can happen later as a dedicated focused activity of bringing the
Python usage to the more modern level.

This is rather common workflow in all sort of forges like Github, Gitlab, perhaps even Gitea. Having better support of our tools for it seems to have string benefits. The idea of this change is to make it so `make update` will perform the steps needed to update the branch of the fork to the upstream version. This includes: - Fetch the `upstream` remote - `git merge --ff-only upstream/branch` if the current branch exists in the upstream. - If the branch does not exist in the upstream, then it will be pulled from the `origin` instead (the behavior prior to this change). The same logic is implemented for the submodules. The `make update` will also check for the forked submodules within the same user/organization as the blender.git fork and add the "origin" to the submodule when such a fork is detected. This allows to fork the submodule repository after the `make update` has been run for the first time. Some of the new code still follows the old `os.path` convention. This is to avoid a bigger refactor or endanger some things not working. Such a refactor can happen later as a dedicated focused activity of bringing the Python usage to the more modern level.
Sergey Sharybin requested review from Brecht Van Lommel 2023-02-08 18:57:36 +01:00
Sergey Sharybin requested review from Bastien Montagne 2023-02-08 18:57:48 +01:00
Brecht Van Lommel requested changes 2023-02-09 17:21:32 +01:00
Brecht Van Lommel left a comment
Owner

When I have the upstream workflow configured for the Blender repo, and then do this to have it reinit the submodules:

git submodule deinit --all
make update

I ended up with main branches in the submodule not tracking any upstream branch. I think they should be tracking origin/main.

When I have the upstream workflow configured for the Blender repo, and then do this to have it reinit the submodules: ``` git submodule deinit --all make update ``` I ended up with `main` branches in the submodule not tracking any upstream branch. I think they should be tracking `origin/main`.
@ -187,0 +219,4 @@
if not make_utils.git_branch_exists(args.git_command, upstream_branch):
return False
call((args.git_command, "merge", "--ff-only", upstream_branch))

This aborts everything if the main branch in the Blender repo has changes. I think we should instead skip just the Blender repo update and continue with the submodules and libraries, same as we already do when there are unstaged changes.

This aborts everything if the main branch in the Blender repo has changes. I think we should instead skip just the Blender repo update and continue with the submodules and libraries, same as we already do when there are unstaged changes.
Sergey marked this conversation as resolved
@ -187,0 +239,4 @@
update_command = [args.git_command, "pull", "--rebase"]
if remote_branch:
update_command.append(remote_branch)

Getting this error:

git pull --rebase main
fatal: 'main' does not appear to be a git repository
fatal: Could not read from remote repository.

Can we just leave out the remote branch name here? When not using the upstream workflow it seems reasonable to pull from whatever this branch is tracking.

Getting this error: ``` git pull --rebase main fatal: 'main' does not appear to be a git repository fatal: Could not read from remote repository. ``` Can we just leave out the remote branch name here? When not using the upstream workflow it seems reasonable to pull from whatever this branch is tracking.
Sergey marked this conversation as resolved
@ -191,0 +277,4 @@
#
# - Rename "origin" to "upstream" in the submodule, matching the naming convention in the main
# repository.
# This leaves the submodule with detached head and main branch tracking upstream remote.

We don't want the main branch tracking the upstream remote as I understand it, both for the main Blender repo and submodules.

So this behavior seems wrong.

We don't want the main branch tracking the upstream remote as I understand it, both for the main Blender repo and submodules. So this behavior seems wrong.
Sergey marked this conversation as resolved
@ -191,0 +305,4 @@
# The check should not be needed in the final production, but during development it
# is possible that the old configuration is still present, despite the deinit, so make
# a sanity check that the rename is still needed.
if make_utils.git_remote_exist(args.git_command, "origin"):

Can we add and not make_utils.git_remote_exist(args.git_command, upstream_origin)?

I did rm -rf release/script/addons and then make update. But that didn't remove the remotes for the add-on, so got this error:

git remote rename origin upstream
fatal: remote upstream already exists.

Probably not the right thing to do but still can avoid giving an error.

Can we add `and not `make_utils.git_remote_exist(args.git_command, upstream_origin)? I did `rm -rf release/script/addons` and then `make update`. But that didn't remove the remotes for the add-on, so got this error: ``` git remote rename origin upstream fatal: remote upstream already exists. ``` Probably not the right thing to do but still can avoid giving an error.
Sergey marked this conversation as resolved
@ -191,0 +334,4 @@
if make_utils.git_remote_exist(args.git_command, "origin"):
return
if not make_utils.git_is_remote_repository(args.git_command, origin_submodule_url):

When having only an upstream remote in a submodule and this code runs to add an origin repo, it prints this to the console:

git ls-remote git@projects.blender.org:brecht/blender-addons.git HEAD
Gitea: Unauthorized
fatal: Could not read from remote repository.

It works correctly, but can we suppress writing that out because it looks like something goes wrong.

When having only an `upstream` remote in a submodule and this code runs to add an origin repo, it prints this to the console: ``` git ls-remote git@projects.blender.org:brecht/blender-addons.git HEAD Gitea: Unauthorized fatal: Could not read from remote repository. ``` It works correctly, but can we suppress writing that out because it looks like something goes wrong.
Sergey marked this conversation as resolved
Sergey Sharybin force-pushed make_update from 9b5ae2152c to bec0d5f4d2 2023-02-09 18:04:37 +01:00 Compare
Brecht Van Lommel requested review from Brecht Van Lommel 2023-02-09 18:21:33 +01:00
Brecht Van Lommel approved these changes 2023-02-09 18:52:56 +01:00
Sergey Sharybin changed title from make_update: support Github style of remote organization to WIP: make_update: support Github style of remote organization 2023-02-10 15:46:18 +01:00
Author
Owner

Putting on hold until #104573 is signed off, as the submodule part would need to be reconsidered.

Putting on hold until #104573 is signed off, as the submodule part would need to be reconsidered.
Author
Owner

Actually, a much bigger change is coming.

Actually, a much bigger change is coming.
Sergey Sharybin closed this pull request 2023-02-14 18:21:16 +01:00
Sergey Sharybin deleted branch make_update 2023-02-14 18:21:25 +01:00

Pull request closed

Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#104479
No description provided.