Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update sync-from-repo to recognize rename operations #3550

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,9 @@ public static String deleteItemRow(Long siteId, String path) {
return sql;
}

public static String moveItemRow(String site, String oldPath, String newPath, long onStatesBitMap,
public static String moveItemRow(Long siteId, String oldPath, String newPath, long onStatesBitMap,
long offStatesBitMap) {
String sql = StringUtils.replace(ITEM_MOVE,"#{site}", StringUtils.replace(site,"'", "''"));
String sql = StringUtils.replace(ITEM_MOVE,"#{siteId}", Long.toString(siteId));
sql = StringUtils.replace(sql,"#{oldPath}", StringUtils.replace(oldPath, "'", "''"));
sql = StringUtils.replace(sql,"#{newPath}", StringUtils.replace(newPath, "'", "''"));
sql = StringUtils.replace(sql,"#{onStatesBitMap}", Long.toString(onStatesBitMap));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import org.eclipse.jgit.api.errors.RefNotFoundException;
import org.eclipse.jgit.diff.DiffConfig;
import org.eclipse.jgit.diff.DiffEntry;
import org.eclipse.jgit.diff.RenameDetector;
import org.eclipse.jgit.errors.StopWalkException;
import org.eclipse.jgit.internal.storage.file.LockFile;
import org.eclipse.jgit.lib.*;
Expand Down Expand Up @@ -361,7 +362,9 @@ private List<RepoOperation> processDiffEntry(Git git, List<DiffEntry> diffEntrie
long startMark = logger.isDebugEnabled() ? System.currentTimeMillis() : 0;
List<RepoOperation> toReturn = new ArrayList<>();

for (DiffEntry diffEntry : diffEntries) {
RenameDetector renameDetector = new RenameDetector(git.getRepository());
renameDetector.addAll(diffEntries);
for (DiffEntry diffEntry : renameDetector.compute()) {
// Update the paths to have a preceding separator
String pathNew = FILE_SEPARATOR + diffEntry.getNewPath();
String pathOld = FILE_SEPARATOR + diffEntry.getOldPath();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ private void processMove(Site site, RepoOperation repoOperation, User user,
addUpdateParentIdScriptSnippets(site.getId(), repoOperation.getMoveToPath(),
updateParentIdScriptPath);
} else {
Files.write(repoOperationsScriptPath, moveItemRow(site.getSiteId(), repoOperation.getPath(),
Files.write(repoOperationsScriptPath, moveItemRow(site.getId(), repoOperation.getPath(),
repoOperation.getMoveToPath(), onStateBitMap, offStateBitmap).getBytes(UTF_8),
StandardOpenOption.APPEND);
Files.write(repoOperationsScriptPath, "\n\n".getBytes(UTF_8), StandardOpenOption.APPEND);
Expand Down