use of org.eclipse.egit.core.op.CommitOperation in project jbosstools-openshift by jbosstools.
the class EGitUtils method commit.
private static RevCommit commit(IProject project, String commitMessage, Repository repository, IProgressMonitor monitor) throws CoreException {
Assert.isLegal(project != null, "Could not commit project. No project provided");
Assert.isLegal(repository != null, MessageFormat.format("Could not commit. Project \"{0}\" is not connected to a repository (call #connect(project, repository) first)", project.getName()));
/**
* TODO: add capability to commit selectively
*/
UserConfig userConfig = getUserConfig(repository);
CommitOperation op = new CommitOperation(null, null, null, getFormattedUser(userConfig.getAuthorName(), userConfig.getAuthorEmail()), getFormattedUser(userConfig.getCommitterName(), userConfig.getCommitterEmail()), commitMessage);
op.setCommitAll(true);
op.setRepository(repository);
op.execute(monitor);
return op.getCommit();
}
use of org.eclipse.egit.core.op.CommitOperation in project egit by eclipse.
the class LocalRepositoryTestCase method addAndCommit.
protected static void addAndCommit(IFile file, String commitMessage) throws Exception {
IProject prj = file.getProject();
if (!prj.isAccessible())
throw new IllegalStateException("No project to touch");
IFile[] commitables = new IFile[] { file };
ArrayList<IFile> untracked = new ArrayList<IFile>();
untracked.addAll(Arrays.asList(commitables));
CommitOperation op = new CommitOperation(commitables, untracked, TestUtil.TESTAUTHOR, TestUtil.TESTCOMMITTER, commitMessage);
op.execute(null);
TestUtil.waitForJobs(50, 5000);
}
use of org.eclipse.egit.core.op.CommitOperation in project egit by eclipse.
the class LocalRepositoryTestCase method touchAndSubmit.
/**
* Modify with the given content and commit.
*
* @param newContent
* new file content
* @param commitMessage
* may be null
* @throws Exception
*/
protected static void touchAndSubmit(String newContent, String commitMessage) throws Exception {
IFile file = touch(newContent);
IFile[] commitables = new IFile[] { file };
ArrayList<IFile> untracked = new ArrayList<IFile>();
untracked.addAll(Arrays.asList(commitables));
String message = commitMessage;
if (message == null)
message = newContent;
CommitOperation op = new CommitOperation(commitables, untracked, TestUtil.TESTAUTHOR, TestUtil.TESTCOMMITTER, message);
op.execute(null);
TestUtil.waitForJobs(50, 5000);
}
use of org.eclipse.egit.core.op.CommitOperation in project egit by eclipse.
the class LocalRepositoryTestCase method createProjectAndCommitToRepository.
protected File createProjectAndCommitToRepository(String repoName, String project1Name, String project2Name) throws Exception {
Repository myRepository = createLocalTestRepository(repoName);
File gitDir = myRepository.getDirectory();
// we need to commit into master first
IProject firstProject = createStandardTestProjectInRepository(myRepository, project1Name);
try {
new ConnectProviderOperation(firstProject, gitDir).execute(null);
} catch (Exception e) {
Activator.logError("Failed to connect project to repository", e);
}
assertConnected(firstProject);
IProject secondProject = null;
if (project2Name != null) {
secondProject = createStandardTestProjectInRepository(myRepository, project2Name);
try {
new ConnectProviderOperation(secondProject, gitDir).execute(null);
} catch (Exception e) {
Activator.logError("Failed to connect project to repository", e);
}
assertConnected(secondProject);
}
IFile dotProject = firstProject.getFile(".project");
assertTrue(".project is not accessible: " + dotProject, dotProject.isAccessible());
IFolder folder = firstProject.getFolder(FOLDER);
IFile textFile = folder.getFile(FILE1);
IFile textFile2 = folder.getFile(FILE2);
IFile[] commitables = null;
if (secondProject != null) {
folder = secondProject.getFolder(FOLDER);
IFile secondtextFile = folder.getFile(FILE1);
IFile secondtextFile2 = folder.getFile(FILE2);
commitables = new IFile[] { dotProject, textFile, textFile2, secondtextFile, secondtextFile2 };
} else {
commitables = new IFile[] { dotProject, textFile, textFile2 };
}
ArrayList<IFile> untracked = new ArrayList<IFile>();
untracked.addAll(Arrays.asList(commitables));
// commit to stable
CommitOperation op = new CommitOperation(commitables, untracked, TestUtil.TESTAUTHOR, TestUtil.TESTCOMMITTER, "Initial commit");
op.execute(null);
// now create a stable branch (from master)
createStableBranch(myRepository);
// and check in some stuff into master again
String newContent = "Touched at " + System.currentTimeMillis();
IFile file = touch(firstProject.getName(), FOLDER + '/' + FILE1, newContent);
addAndCommit(file, newContent);
// Make sure cache entry is already listening for changes
IndexDiffCache cache = Activator.getDefault().getIndexDiffCache();
cache.getIndexDiffCacheEntry(lookupRepository(gitDir));
return gitDir;
}
use of org.eclipse.egit.core.op.CommitOperation in project egit by eclipse.
the class AbstractSynchronizeViewTest method createAndCommitDotGitignore.
private static void createAndCommitDotGitignore() throws CoreException, UnsupportedEncodingException {
IProject secondPoject = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJ2);
IFile gitignore = secondPoject.getFile(".gitignore");
gitignore.create(new ByteArrayInputStream("/.project\n".getBytes(secondPoject.getDefaultCharset())), false, null);
IFile[] commitables = new IFile[] { gitignore };
ArrayList<IFile> untracked = new ArrayList<IFile>();
untracked.addAll(Arrays.asList(commitables));
CommitOperation op = new CommitOperation(commitables, untracked, TestUtil.TESTAUTHOR, TestUtil.TESTCOMMITTER, "Add .gitignore file");
op.execute(null);
}
Aggregations