|
12 | 12 | # repository with the filtered contents into a directory specified by the |
13 | 13 | # argument passed to this script. The filtered contents are determined |
14 | 14 | # by the configuration in `.github/sync/webrender.paths`. |
15 | | -# 3. Cherry-pick the new commits into the repository in the current working |
16 | | -# directory. The commits applied from the filtered repository are determined |
17 | | -# by choosing every commit after the hash found in the file |
18 | | -# `.github/sync/UPSTREAM_COMMIT` |
| 15 | +# 3. Reset the `upstream` branch in the target repository to the new filtered |
| 16 | +# version. |
19 | 17 | # |
20 | 18 | # Note that this script relies on the idea that filtering `gecko-dev` the same |
21 | | -# way more than once will result in the same commit hashes. |
22 | | -# |
23 | | -# If at some point, `webrender.paths` is modified and the commit hashes change, |
24 | | -# then a single manual filter will have to happen in order to translate the |
25 | | -# hash in the original filtered repository to the new one. The procedure for this |
26 | | -# is roughly: |
27 | | -# |
28 | | -# 1. Run `git-filter-repo` locally and note the new hash of the latest |
29 | | -# commit included from upstream. |
30 | | -# 2. Replace the contents `UPSTREAM_COMMIT` with that hash and commit |
31 | | -# it together with your changes to `webrender.paths`. |
| 19 | +# way more than once will result in the same commit hashes, otherwise multiple |
| 20 | +# copies of the version control history will be included in the repository. |
32 | 21 | # |
33 | 22 | # [1]: <https://github.com/mozilla/gecko-dev/> mirrored from |
34 | 23 | # <https://hg.mozilla.org/mozilla-central> |
35 | 24 | # [2]: <https://github.com/mozilla/gecko-dev/> |
36 | | -set -eu |
| 25 | +set -eux |
37 | 26 |
|
38 | 27 | root_dir=$(pwd) |
39 | 28 | cache_dir=$root_dir/_cache |
@@ -89,15 +78,9 @@ cd "$root_dir" |
89 | 78 | git remote add filtered-upstream "$filtered" |
90 | 79 | git fetch filtered-upstream |
91 | 80 |
|
92 | | -hash_file=".github/sync/UPSTREAM_COMMIT" |
93 | | -hash=`cat $hash_file` |
94 | | -number_of_commits=`git log $hash..filtered-upstream/master --pretty=oneline | wc -l` |
| 81 | +step "Resetting 'upstream' branch to filtered repository HEAD" |
| 82 | +git switch -c upstream |
| 83 | +git reset --hard filtered-upstream/master |
95 | 84 |
|
96 | | -if [ $number_of_commits != '0' ]; then |
97 | | - step "Applying $number_of_commits new commits" |
98 | | - git -c user.email="$git_email" -c user.name="$git_name" cherry-pick $hash..filtered-upstream/master |
99 | | - git rev-parse filtered-upstream/master > "$hash_file" |
100 | | - git -c user.email="$git_email" -c user.name="$git_name" commit "$hash_file" -m "Syncing to upstream (`cat $hash_file`)" |
101 | | -else |
102 | | - step "No new commits. Doing nothing." |
103 | | -fi |
| 85 | +step Pushing new 'upstream' |
| 86 | +git push -f origin upstream |
0 commit comments