Skip to content

Commit

Permalink
Merge pull request open-telemetry#137 from MSNev/MSNev/AddComponents
Browse files Browse the repository at this point in the history
fix: Fixup repo merging with a submodule (./protos)
  • Loading branch information
MSNev committed Jul 11, 2023
2 parents f342aea + 2d25286 commit cfa232e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
17 changes: 13 additions & 4 deletions sandbox-tools/merge-repos/src/git/resolveConflictsToTheirs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,19 @@ function getFileStatus(status: StatusResult, name: string): FileStatusResult {
conflicted
]);

await git.raw([
"add",
"-f",
conflicted]);
try {
await git.raw([
"add",
"-f",
conflicted]);
} catch (e) {
if (!conflicted.endsWith("/protos")) {
throw e;
} else {
log(` - !! Ignoring git add for known submodule folder - ${conflicted}`);
await git.rm(conflicted);
}
}
} else {
commitMessage = logAppendMessage(gitRoot, commitMessage, fileStatus, `Removed from ${fileStatus.working_dir === "D" ? "both" : "theirs"}`);
await git.rm(conflicted);
Expand Down
19 changes: 11 additions & 8 deletions sandbox-tools/merge-repos/src/support/mergeFixup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,17 @@ export async function checkFixBadMerges(
let destStats = fs.statSync(destFolder + "/" + destFile);
if (destStats.isDirectory()) {
commitDetails.message = logAppendMessage(mergeGitRoot, commitDetails.message, { index: "*", working_dir: "F", path: destFolder + "/" + destFile } , `Removing extra folder ${destFile}`);
await git.raw([
"rm",
"-f",
"-r",
destFolder + "/" + destFile]);
// fs.rmdirSync(destFolder + "/" + destFile, {
// recursive: true
// });
try {
await git.raw([
"rm",
"-f",
"-r",
destFolder + "/" + destFile]);
} catch (e) {
fs.rmdirSync(destFolder + "/" + destFile, {
recursive: true
});
}
} else {
commitDetails.message = logAppendMessage(mergeGitRoot, commitDetails.message, { index: "*", working_dir: "E", path: destFolder + "/" + destFile } , "Removing extra file");
await git.rm(destFolder + "/" + destFile);
Expand Down

0 comments on commit cfa232e

Please sign in to comment.