diff --git a/.circleci/config.yml b/.circleci/config.yml index 0ebe24477ef5d..9ce106590e8a5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -217,33 +217,21 @@ step-gclient-sync: &step-gclient-sync $GCLIENT_EXTRA_ARGS \ "$CIRCLE_REPOSITORY_URL" - if ! gclient sync --with_branch_heads --with_tags; then - python src/electron/script/reset_patched_repos.py - if ELECTRON_USE_THREE_WAY_MERGE_FOR_PATCHES=1 gclient sync -f --with_branch_heads --with_tags; then - # Re-export all the new patches now that they've been nicely 3-way - # merged - python src/electron/script/export_all_patches.py src/electron/patches/config.json - # Make a git commit with the updated patches - git -C src/electron add patches - GIT_COMMITTER_NAME="Electron Bot" GIT_COMMITTER_EMAIL="anonymous@electronjs.org" git commit -m "update patches" --author="Electron Bot " - # Export it - mkdir -p patches - git -C src/electron am -1 --stdout --keep-subject --no-stat --full-index > patches/update-patches.patch - # Upload it to artifacts - echo - echo "======================================================================" - echo "Sync failed with non-3way patch application, but succeeded with 3way." - echo "Check the CI artifacts for a patch you can apply to fix it." - echo "======================================================================" - echo - else - echo - echo "======================================================================" - echo "Sync failed even with 3way patch application. You'll need to resolve" - echo "this conflict locally." - echo "======================================================================" - echo - fi + ELECTRON_USE_THREE_WAY_MERGE_FOR_PATCHES=1 gclient sync --with_branch_heads --with_tags + # Re-export all the patches to check if there were changes. + python src/electron/script/export_all_patches.py src/electron/patches/config.json + if ! git diff-index --quiet HEAD --; then + # There are changes to the patches. Make a git commit with the updated patches + git -C src/electron add patches + GIT_COMMITTER_NAME="Electron Bot" GIT_COMMITTER_EMAIL="anonymous@electronjs.org" git commit -m "update patches" --author="Electron Bot " + # Export it + mkdir -p patches + git -C src/electron am -1 --stdout --keep-subject --no-stat --full-index > patches/update-patches.patch + echo + echo "======================================================================" + echo "There were changes to the patches when applying." + echo "Check the CI artifacts for a patch you can apply to fix it." + echo "======================================================================" exit 1 fi fi diff --git a/script/reset_patched_repos.py b/script/reset_patched_repos.py deleted file mode 100644 index 848264b6343e8..0000000000000 --- a/script/reset_patched_repos.py +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env python - -import argparse -import json -import subprocess - - -def reset_patched_repos(dirs): - for patch_dir, repo in dirs.iteritems(): - args = ['git', '-C', repo, 'am', '--abort'] - subprocess.call(args) # ignore failure - args = ['git', '-C', repo, 'checkout', 'refs/patches/upstream-head'] - subprocess.call(args) # ignore failure - - -def parse_args(): - parser = argparse.ArgumentParser(description='Reset patched repos') - parser.add_argument('config', nargs='+', - type=argparse.FileType('r'), - help='patches\' config(s) in the JSON format') - return parser.parse_args() - - -def main(): - configs = parse_args().config - for config_json in configs: - reset_patched_repos(json.load(config_json)) - - -if __name__ == '__main__': - main()