use of com.oxygenxml.git.service.entities.FileStatus in project oxygen-git-client-addon by oxygenxml.
the class FileGitEventInfo method getAffectedFileStatuses.
/**
* @return the files affected by the current event.
*/
public List<FileStatus> getAffectedFileStatuses() {
List<FileStatus> fss = new LinkedList<>();
for (Iterator<String> iterator = affectedFiles.iterator(); iterator.hasNext(); ) {
String path = iterator.next();
fss.add(new FileStatus(GitChangeType.UNKNOWN, path));
}
return fss;
}
use of com.oxygenxml.git.service.entities.FileStatus in project oxygen-git-client-addon by oxygenxml.
the class TreeViewTest method testConflict_resolveUsingMine.
/**
* Resolve a conflict using my copy.
*
* @throws Exception If it fails.
*/
public void testConflict_resolveUsingMine() throws Exception {
/**
* Local repository location.
*/
String localTestRepository = "target/test-resources/testConflict_resolveUsingMine_local";
/**
* Remote repository location.
*/
String remoteTestRepository = "target/test-resources/testConflict_resolveUsingMine_remote";
String localTestRepository2 = localTestRepository + "2";
File file2 = new File(localTestRepository2 + "/test.txt");
// Create repositories
Repository remoteRepo = createRepository(remoteTestRepository);
Repository localRepo1 = createRepository(localTestRepository);
Repository localRepo2 = createRepository(localTestRepository2);
// Bind the local repository to the remote one.
bindLocalToRemote(localRepo2, remoteRepo);
// Bind the local repository to the remote one.
bindLocalToRemote(localRepo1, remoteRepo);
// Create a new file and push it.
new File(localTestRepository).mkdirs();
File file = new File(localTestRepository + "/test.txt");
createNewFile(localTestRepository, "test.txt", "content");
add(new FileStatus(GitChangeType.UNKNOWN, "test.txt"));
GitAccess.getInstance().commit("First version.");
PushResponse push = push("", "");
assertEquals("status: OK message null", push.toString());
GitAccess.getInstance().setRepositorySynchronously(localTestRepository2);
// Commit a new version of the file.
setFileContent(file2, "modified from 2nd local repo");
add(new FileStatus(GitChangeType.MODIFIED, "test.txt"));
GitAccess.getInstance().commit("modified from 2nd local repo");
push("", "");
// Change back the repo.
GitAccess.getInstance().setRepositorySynchronously(localTestRepository);
// Change the file. Create a conflict.
setFileContent(file, "modified from 1st repo");
add(new FileStatus(GitChangeType.MODIFIED, "test.txt"));
GitAccess.getInstance().commit("modified from 2nd local repo");
// Get the remote. The conflict appears.
pull();
flushAWT();
sleep(300);
assertTreeModels("CONFLICT, test.txt", "");
stagingPanel.getGitController().asyncResolveUsingMine(Arrays.asList(new FileStatus(GitChangeType.CONFLICT, "test.txt")));
waitForScheduler();
waitForScheluerBetter();
assertTreeModels("", "");
// Check the commit.
CommitAndStatusPanel commitPanel = stagingPanel.getCommitPanel();
assertEquals("Commit_to_merge", commitPanel.getCommitMessageArea().getText());
commitPanel.getCommitButton().doClick();
waitForScheduler();
// TODO What should it assert here?
assertEquals("", "");
}
use of com.oxygenxml.git.service.entities.FileStatus in project oxygen-git-client-addon by oxygenxml.
the class TreeViewTest method testConflict_resolveUsingTheirsAndRestartMerge.
/**
* Resolve a conflict using "their" copy, restart merge, and resolve again.
*
* @throws Exception If it fails.
*/
public void testConflict_resolveUsingTheirsAndRestartMerge() throws Exception {
/**
* Local repository location.
*/
String localTestRepository = "target/test-resources/testConflict_resolveUsingTheirs_local";
/**
* Remote repository location.
*/
String remoteTestRepository = "target/test-resources/testConflict_resolveUsingTheirs_remote";
String localTestRepository2 = localTestRepository + "2";
File file2 = new File(localTestRepository2 + "/test.txt");
// Create repositories
Repository remoteRepo = createRepository(remoteTestRepository);
Repository localRepo1 = createRepository(localTestRepository);
Repository localRepo2 = createRepository(localTestRepository2);
// Bind the local repository to the remote one.
bindLocalToRemote(localRepo2, remoteRepo);
// Bind the local repository to the remote one.
bindLocalToRemote(localRepo1, remoteRepo);
// Create a new file and push it.
new File(localTestRepository).mkdirs();
File file = createNewFile(localTestRepository, "test.txt", "content");
add(new FileStatus(GitChangeType.UNKNOWN, "test.txt"));
GitAccess.getInstance().commit("First version.");
PushResponse push = push("", "");
assertEquals("status: OK message null", push.toString());
GitAccess.getInstance().setRepositorySynchronously(localTestRepository2);
// Commit a new version of the file.
setFileContent(file2, "modified from 2nd local repo");
add(new FileStatus(GitChangeType.MODIFIED, "test.txt"));
GitAccess.getInstance().commit("modified from 2nd local repo");
push("", "");
// Change back the repo.
GitAccess.getInstance().setRepositorySynchronously(localTestRepository);
// Change the file. Create a conflict.
setFileContent(file, "modified from 1st repo");
add(new FileStatus(GitChangeType.MODIFIED, "test.txt"));
GitAccess.getInstance().commit("modified from 2nd local repo");
// Get the remote. The conflict appears.
pull();
flushAWT();
assertTreeModels("CONFLICT, test.txt", "");
// Resolve using theirs
stagingPanel.getGitController().asyncResolveUsingTheirs(Arrays.asList(new FileStatus(GitChangeType.CONFLICT, "test.txt")));
waitForScheduler();
assertTreeModels("", "CHANGED, test.txt");
// Restart merge
ScheduledFuture<?> restartMerge = GitAccess.getInstance().restartMerge();
restartMerge.get();
flushAWT();
assertTreeModels("CONFLICT, test.txt", "");
// Resolve again using theirs
stagingPanel.getGitController().asyncResolveUsingTheirs(Arrays.asList(new FileStatus(GitChangeType.CONFLICT, "test.txt")));
waitForScheduler();
assertTreeModels("", "CHANGED, test.txt");
// Commit
GitAccess.getInstance().commit("commit");
flushAWT();
assertTreeModels("", "");
}
use of com.oxygenxml.git.service.entities.FileStatus in project oxygen-git-client-addon by oxygenxml.
the class GitAccess method addAll.
/**
* Adds multiple files to the staging area. Preparing the for commit
*
* @param files The files to be added.
*/
public void addAll(List<FileStatus> files) {
Collection<String> filePaths = getFilePaths(files);
try {
fireOperationAboutToStart(new FileGitEventInfo(GitOperation.STAGE, filePaths));
RmCommand removeCmd = null;
AddCommand addCmd = null;
for (FileStatus file : files) {
if (file.getChangeType() == GitChangeType.MISSING) {
if (removeCmd == null) {
removeCmd = git.rm().setCached(true);
}
removeCmd.addFilepattern(file.getFileLocation());
} else {
if (addCmd == null) {
addCmd = git.add();
}
addCmd.addFilepattern(file.getFileLocation());
}
}
if (addCmd != null) {
addCmd.call();
}
if (removeCmd != null) {
removeCmd.call();
}
fireOperationSuccessfullyEnded(new FileGitEventInfo(GitOperation.STAGE, filePaths));
} catch (GitAPIException e) {
fireOperationFailed(new FileGitEventInfo(GitOperation.STAGE, filePaths), e);
LOGGER.error(e.getMessage(), e);
}
}
use of com.oxygenxml.git.service.entities.FileStatus in project oxygen-git-client-addon by oxygenxml.
the class GitAccess method getFilePaths.
/**
* Get file paths for the given file statuses.
*
* @param files The file statuses.
*
* @return the paths.
*/
private Collection<String> getFilePaths(List<FileStatus> files) {
List<String> paths = new LinkedList<>();
for (Iterator<FileStatus> iterator = files.iterator(); iterator.hasNext(); ) {
FileStatus fileStatus = iterator.next();
paths.add(fileStatus.getFileLocation());
}
return paths;
}
Aggregations