Skip to content

Commit a80e93d

Browse files
authored
Automatically commit generated schema files (#3590)
## Description Updates the `sync-architectures` script to commit the generated Java files automatically. ## Test plan Update the schema file and commit it - the generated files should be committed alongside it instead of being left out. Do the same with `architectures-consistency-check` script.
1 parent df87e60 commit a80e93d

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

scripts/codegen-utils.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,12 @@ async function generateCodegenJavaOldArch() {
114114
`[${ERROR_PREFIX}] ${file} file does not exist in codegen artifacts source destination. Please check if you still need this interface/delagete.`
115115
);
116116
} else {
117+
const filesTheSame = compareFileAtTwoPaths(file, codegenPath, oldArchPath);
117118
exec(`cp -rf ${codegenPath}/${file} ${oldArchPath}/${file}`);
119+
120+
if (!filesTheSame) {
121+
exec(`git add ${oldArchPath}/${file}`);
122+
}
118123
}
119124
});
120125
});
@@ -124,11 +129,7 @@ function compareFileAtTwoPaths(filename, firstPath, secondPath) {
124129
const fileA = fs.readFileSync(`${firstPath}/${filename}`, 'utf-8');
125130
const fileB = fs.readFileSync(`${secondPath}/${filename}`, 'utf-8');
126131

127-
if (fileA !== fileB) {
128-
throw new Error(
129-
`[${ERROR_PREFIX}] File ${filename} is different at ${firstPath} and ${secondPath}. Make sure you committed codegen autogenerated files.`
130-
);
131-
}
132+
return fileA === fileB
132133
}
133134

134135
async function checkCodegenIntegrity() {
@@ -137,7 +138,11 @@ async function checkCodegenIntegrity() {
137138
SOURCE_FOLDERS.forEach(({ codegenPath, oldArchPath }) => {
138139
const oldArchFiles = readdirSync(oldArchPath);
139140
oldArchFiles.forEach((file) => {
140-
compareFileAtTwoPaths(file, codegenPath, oldArchPath);
141+
if (!compareFileAtTwoPaths(file, codegenPath, oldArchPath)) {
142+
throw new Error(
143+
`[${ERROR_PREFIX}] File ${file} is different at ${codegenPath} and ${oldArchPath}. Make sure you committed codegen autogenerated files.`
144+
);
145+
}
141146
});
142147
});
143148
}

0 commit comments

Comments
 (0)