Skip to content

Commit 5a8df8a

Browse files
committed
WIP: script to sync changes
1 parent e472003 commit 5a8df8a

File tree

1 file changed

+55
-3
lines changed

1 file changed

+55
-3
lines changed

script/sync-translation

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,59 @@
22
#
33
# Sync changes from up stream
44
#
5+
# Usage: script/sync-upstream [remote]
6+
#
57
# TODO:
6-
# - create branch and merge upstream changes
7-
# - get diff of changes to notable files
8-
# - open PR with checkboxes for changes to translatable files
8+
# - [x] create branch and merge upstream changes
9+
# - [x] get diff of changes to notable files
10+
# - [ ] open PR with checkboxes for changes to translatable files
11+
# - [ ] handle merge conflicts with `git merge --continue`
12+
# - [ ] remove all the TODOs
13+
14+
set -e
15+
16+
# If there's not an upstream remote, set it.
17+
if ! git remote show | grep -q upstream; then
18+
git remote add upstream https://github.com/github/open-source-guide.git
19+
fi
20+
21+
git fetch upstream
22+
23+
REMOTE=${1:-"origin"}
24+
25+
# BASE=$(git rev-parse $REMOTE/gh-pages)
26+
# TODO: replace v with ^
27+
BASE=0fc50236af4da7a5a339f9681f7c30634f415120 # randomly selected old commit for testing
28+
HEAD=$(git rev-parse upstream/i18n)
29+
BRANCH="sync-${HEAD:0:8}"
30+
31+
TRANSLATABLE_FILES="
32+
_articles/en-US
33+
_data/locale/en-US.yml
34+
"
35+
36+
## Create a new branch and merge in the changes from upstream.
37+
# TODO: remove echos
38+
echo git co -b $BRANCH $BASE
39+
echo git merge --no-edit $HEAD
40+
41+
CHANGED_FILES=$(git diff --name-only $BASE $HEAD -- $TRANSLATABLE_FILES)
42+
43+
TEMPLATE="This pull request syncs changes from upstream.
44+
45+
[View changes](https://github.com/github/open-source-guide/compare/$BASE...$HEAD)
46+
47+
Check the changes in each of these files and update the translation accordingly:
48+
"
49+
50+
if [ -z "$CHANGED_FILES" ]; then
51+
TEMPLATE="$TEMPLATE\nNo translatable files were changed upstream."
52+
fi
53+
54+
for file in $CHANGED_FILES; do
55+
TEMPLATE="$TEMPLATE\n- [ ] $file"
56+
done
57+
58+
# TODO: remove echos
59+
echo "$TEMPLATE"
60+
echo $TEMPLATE | echo hub pull-request -o -F - -h $BRANCH -b gh-pages

0 commit comments

Comments
 (0)