Skip to content

feat: add an option to checkout Electron from a fork#863

Open
lucasterra wants to merge 1 commit into
electron:mainfrom
lucasterra:add-fork-as-origin-option
Open

feat: add an option to checkout Electron from a fork#863
lucasterra wants to merge 1 commit into
electron:mainfrom
lucasterra:add-fork-as-origin-option

Conversation

@lucasterra
Copy link
Copy Markdown

Problem

Right now it's impossible to use @electron/build-tools to build from a fork. I actively maintain a fork of Electron with features that wouldn't make sense upstream, but I still regularly merge upstream to keep up with Chromium/Node upgrades.

Currently my workaround is to do this:

# Initialize
e init \
    --root ./electron \
    --import release \
    --remote-build "none" \
    --target-cpu "x64" \
    --fork cool-fork/electron \
    release-x64

# Replace origin with fork in `.gclient`
sed -i 's|https://github.com/electron/electron|https://github.com/cool-fork/electron|g' ./electron/.gclient

# Sync and build
e sync
e build electron:electron_dist_zip --no-remote

Solution

This PR adds a flag for --fork-as-origin to e init for users who want to checkout Electron directly from their fork rather than electron/electron.

This would simplify my build script to this:

# Initialize, sync and build
e init \
    --root ./electron \
    --import release \
    --remote-build "none" \
    --target-cpu "x64" \
    --fork cool-fork/electron \
    --fork-as-origin \ # 👈 New flag
    release-x64

# Sync and build
e sync
e build electron:electron_dist_zip --no-remote

Behavior

  • The existing behavior from --fork is maintained:
    • origin and .gclient checkout from electron/electron
    • fork remote is pointed to the option passed by --fork
  • When passing --fork cool-fork/electron --fork-as-origin:
    • origin and .gclient check out from the fork
    • upstream is added pointing at electron/electron

Testing

Added new tests for existing behavior, checking out with SSH, HTTPS and checking out with --fork-as-origin.

@lucasterra lucasterra requested review from a team and ckerr as code owners May 16, 2026 12:13
@dsanders11
Copy link
Copy Markdown
Member

Right now it's impossible to use @electron/build-tools to build from a fork.

Can you describe more of the difficulty you're having? There's definitely folks building from a fork using @electron/build-tools. You'd generally just switch to the target branch of your fork in your checkout after doing the initial sync, and then running sync again as needed.

It's a bit inefficient since you'll have the extra sync, but it's the same inefficiency as setting things up to build an older branch of Electron as well.

Alternatively for you, instead of your current workaround you could try e sync --spec=... similar to what we do here.

@lucasterra
Copy link
Copy Markdown
Author

It’s exactly that. The sync → switch → sync causes the pain. The initial sync from electron/main is completely wasted time if I don’t plan on building from main.

And I have to build it 5x for every release (all platforms I support).

The --spec param might work. I’ll try and get back to you. Thanks for the tip.

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.

2 participants