@@ -47,13 +47,13 @@ module.exports = async (langInfo) => {
47
47
48
48
let conflictFiles = await run ( `git diff --name-only --diff-filter=U` , { cwd : translatedPath } ) ;
49
49
conflictFiles = conflictFiles . split ( '\n' ) ;
50
- //
50
+
51
51
// if (conflictFiles[0] === 'Readme.md' && conflictFiles.length === 1) {
52
52
// await run(`git checkout --ours Readme.md`, {cwd: translatedPath });
53
53
// await run(`git commit -m 'readme only' Readme.md`, {cwd: translatedPath });
54
54
// }
55
55
56
- if ( conflictFiles [ 0 ] === '' ) conflictFiles . shift ( ) ; // if no conflicts, becomes ['']
56
+ if ( conflictFiles [ 0 ] === '' ) conflictFiles . shift ( ) ; // if no conflicts, conflictFiles becomes ['']
57
57
58
58
if ( conflictFiles . length ) {
59
59
await run ( `git commit -am "merging all conflicts"` , { cwd : translatedPath } ) ;
@@ -82,6 +82,8 @@ module.exports = async (langInfo) => {
82
82
conflictList = `<details><summary>Click to open a list of ${ conflictFiles . length } files</summary>\n\n${ conflictList } \n</details>` ;
83
83
}
84
84
85
+ const readmeTip = conflictFiles . map ( f => f . toLowerCase ( ) ) . includes ( 'readme.md' ) ? '\nPlease ignore changes in Readme.md (git checkout --ours Readme.md && git commit -m ignore Readme.md).\n' : '' ;
86
+
85
87
if ( conflictList ) {
86
88
conflictList = `
87
89
The following files have conflicts and may need new translations:
@@ -97,21 +99,23 @@ Please fix the conflicts by pushing new commits to this pull request, either by
97
99
let tips = '' ;
98
100
if ( conflictList ) {
99
101
tips = `
100
- We recommend to merge conflicting changes manually and close this PR .
102
+ We recommend to close this PR and merge conflicting changes manually .
101
103
102
104
The steps are:
103
- 1. Setup upstream (if haven't yet )
105
+ 1. Add remote upstream that links to the English version (only needs to be done once )
104
106
- \`git add remote upstream https://github.com/javascript-tutorial/en.javascript.info\`
105
- 2. Commit all current work and \`git checkout master\`
107
+ 2. Commit all current work locally and \`git checkout master\`
106
108
3. Pull the recent changes from the English version:
107
109
- \`git pull upstream master\`
108
- 4. Deal with the conflicts. If a conflict touches a few lines, then just fix them. Otherwise, if there are many changes, you can see them like this:
109
- - Checkout your version, \`git checkout --ours README.md\`
110
- - See what changed in the original file:
111
- - \`git diff --word-diff master...upstream/master README.md\` (please note: three dots in the command)
112
- - Re-translate or otherwise sync the translated version and commit it:
113
- - \`git commit -m synced README.md\`
114
- 5. When conflicts resolved, \`git push origin master\`
110
+ 4. Deal with the conflicts. If a conflict touches a few lines, then just fix them. Otherwise, following commands can help:
111
+ - Checkout translated version of a file/folder at the given path:
112
+ - \`git checkout --ours <path>\`
113
+ - Checkout upstream version of a file/folder at the given path:
114
+ - \`git checkout --theirs <path>\`
115
+ - See what changed in the upstream file since branches diverged:
116
+ - \`git diff --word-diff master...upstream/master <path>\` (please note: three dots in the command)
117
+ 5. When conflicts resolved, commit them and \`git push origin master\`
118
+ ${ readmeTip }
115
119
` ;
116
120
}
117
121
@@ -128,7 +132,7 @@ ${tips}
128
132
129
133
130
134
let existingPrs = await octokitBot . search . issuesAndPullRequests ( {
131
- q : `type:pr Sync with upstream in:title is:open author:${ config . botUser } repo:${ config . org } /${ langInfo . code } .${ config . repoSuffix } `
135
+ q : `type:pr Sync with upstream in:title is:open author:${ config . botUser } repo:${ config . org } /${ langInfo . code } .${ config . repoSuffix } `
132
136
} ) ;
133
137
134
138
for ( let existingPr of existingPrs . data . items ) {
0 commit comments