use of com.oxygenxml.git.view.event.WorkingCopyGitEventInfo in project oxygen-git-client-addon by oxygenxml.
the class GitAccess method clone.
/**
* Creates a local clone of the given repository and loads it.
*
* @param url Remote repository to clone.
* @param directory Local directory in which to create the clone.
* @param progressDialog Progress support.
* @param branchName The name of the branch to clone and checkout. Must be
* specified as full ref names (e.g.
* "refs/heads/hotfixes/17.0").
*
* @throws GitAPIException
*/
public void clone(URIish url, File directory, final ProgressDialog progressDialog, String branchName) throws GitAPIException {
closeRepo();
// Intercept all authentication requests.
String host = url.getHost();
AuthenticationInterceptor.bind(host);
ProgressMonitor progressMonitor = createCloneProgressMonitor(progressDialog);
if (progressDialog != null) {
progressDialog.setNote("Initializing...");
}
CloneCommand cloneCommand = Git.cloneRepository().setCloneSubmodules(true).setURI(url.toString()).setDirectory(directory).setCredentialsProvider(AuthUtil.getCredentialsProvider(host)).setProgressMonitor(progressMonitor);
fireOperationAboutToStart(new WorkingCopyGitEventInfo(GitOperation.OPEN_WORKING_COPY, directory));
try {
if (branchName != null) {
git = cloneCommand.setBranch(branchName).call();
} else {
git = cloneCommand.call();
}
fireOperationSuccessfullyEnded(new WorkingCopyGitEventInfo(GitOperation.OPEN_WORKING_COPY, directory));
} catch (GitAPIException ex) {
fireOperationFailed(new WorkingCopyGitEventInfo(GitOperation.OPEN_WORKING_COPY, directory), ex);
throw ex;
}
}
use of com.oxygenxml.git.view.event.WorkingCopyGitEventInfo in project oxygen-git-client-addon by oxygenxml.
the class GitAccess method createNewRepository.
/**
* Creates a blank new Repository.
*
* @param path A string that specifies the git Repository folder
*
* @throws GitAPIException
*/
public void createNewRepository(String path) throws GitAPIException {
File wc = new File(path);
fireOperationAboutToStart(new WorkingCopyGitEventInfo(GitOperation.OPEN_WORKING_COPY, wc));
closeRepo();
try {
git = Git.init().setInitialBranch(DEFAULT_BRANCH_NAME).setBare(false).setDirectory(wc).call();
fireOperationSuccessfullyEnded(new WorkingCopyGitEventInfo(GitOperation.OPEN_WORKING_COPY, wc));
} catch (GitAPIException e) {
fireOperationFailed(new WorkingCopyGitEventInfo(GitOperation.OPEN_WORKING_COPY, wc), e);
throw e;
}
}
use of com.oxygenxml.git.view.event.WorkingCopyGitEventInfo in project oxygen-git-client-addon by oxygenxml.
the class OxygenGitPluginExtension method customizeGitStagingView.
/**
* Customize the Git Staging view.
*
* @param viewInfo View information.
*/
private void customizeGitStagingView(final ViewInfo viewInfo, final GitActionsManager gitActionsManager) {
boolean shouldRecreateStagingPanel = stagingPanel == null;
if (shouldRecreateStagingPanel) {
stagingPanel = new StagingPanel(gitRefreshSupport, gitController, OxygenGitPluginExtension.this, gitActionsManager);
gitRefreshSupport.setStagingPanel(stagingPanel);
}
viewInfo.setComponent(stagingPanel);
GitOperationUtil.installMouseBusyCursor(gitController, stagingPanel);
gitController.addGitListener(new GitEventAdapter() {
@Override
public void operationAboutToStart(GitEventInfo info) {
// not needed
}
@Override
public void operationSuccessfullyEnded(GitEventInfo info) {
final GitOperation operation = info.getGitOperation();
if (operation == GitOperation.CHECKOUT || operation == GitOperation.CONTINUE_REBASE || operation == GitOperation.RESET_TO_COMMIT || operation == GitOperation.OPEN_WORKING_COPY || operation == GitOperation.MERGE || operation == GitOperation.COMMIT || operation == GitOperation.REVERT_COMMIT || operation == GitOperation.STASH_CREATE || operation == GitOperation.STASH_DROP || operation == GitOperation.STASH_APPLY || operation == GitOperation.UPDATE_CONFIG_FILE || operation == GitOperation.STASH_POP || operation == GitOperation.CHECKOUT_FILE || operation == GitOperation.CHECKOUT_COMMIT || operation == GitOperation.CREATE_TAG || operation == GitOperation.DELETE_TAG || operation == GitOperation.DISCARD) {
gitRefreshSupport.call();
if (operation == GitOperation.CHECKOUT || operation == GitOperation.MERGE) {
try {
FileUtil.refreshProjectView();
} catch (NoRepositorySelected e) {
LOGGER.debug(e.getMessage(), e);
}
} else if (operation == GitOperation.OPEN_WORKING_COPY && GitAccess.getInstance().getBranchInfo().isDetached()) {
treatDetachedHead((WorkingCopyGitEventInfo) info);
}
}
}
@Override
public void operationFailed(GitEventInfo info, Throwable t) {
final GitOperation operation = info.getGitOperation();
if (operation == GitOperation.CONTINUE_REBASE || operation == GitOperation.RESET_TO_COMMIT) {
gitRefreshSupport.call();
}
}
});
gitRefreshSupport.call();
viewInfo.setIcon(Icons.getIcon(Icons.GIT_ICON));
viewInfo.setTitle(translator.getTranslation(Tags.GIT_STAGING));
}
use of com.oxygenxml.git.view.event.WorkingCopyGitEventInfo in project oxygen-git-client-addon by oxygenxml.
the class GitAccess method setSubmodule.
/**
* Sets the given submodule as the current repository
*
* @param submodule - the name of the submodule.
*
* @throws IOException Failed to load the submodule.
* @throws GitAPIException Failed to load the submodule.
*/
public void setSubmodule(String submodule) throws IOException, GitAPIException {
Repository parentRepository = git.getRepository();
File submoduleDir = SubmoduleWalk.getSubmoduleDirectory(parentRepository, submodule);
fireOperationAboutToStart(new WorkingCopyGitEventInfo(GitOperation.OPEN_WORKING_COPY, submoduleDir, true));
try {
Repository submoduleRepository = SubmoduleWalk.getSubmoduleRepository(parentRepository, submodule);
if (submoduleRepository == null) {
// The submodule wasn't updated.
git.submoduleInit().call();
CredentialsProvider credentialsProvider = AuthUtil.getCredentialsProvider(getHostName());
git.submoduleUpdate().setCredentialsProvider(credentialsProvider).call();
submoduleRepository = SubmoduleWalk.getSubmoduleRepository(parentRepository, submodule);
}
// Close the current repository.
closeRepo();
git = Git.wrap(submoduleRepository);
// Start intercepting authentication requests.
AuthenticationInterceptor.bind(getHostName());
fireOperationSuccessfullyEnded(new WorkingCopyGitEventInfo(GitOperation.OPEN_WORKING_COPY, submoduleDir, true));
} catch (Exception e) {
fireOperationFailed(new WorkingCopyGitEventInfo(GitOperation.OPEN_WORKING_COPY, submoduleDir, true), e);
}
}
use of com.oxygenxml.git.view.event.WorkingCopyGitEventInfo in project oxygen-git-client-addon by oxygenxml.
the class GitAccess method openRepository.
/**
* Open repo.
*
* @param path The path of the repo to open.
*
* @throws IOException
*/
private void openRepository(String path) throws IOException {
final File repo = new File(path + "/.git");
if (!isCurrentRepo(repo)) {
File workingCopy = repo.getParentFile();
fireOperationAboutToStart(new WorkingCopyGitEventInfo(GitOperation.OPEN_WORKING_COPY, workingCopy));
closeRepo();
try {
git = Git.open(repo);
repositoryOpened(workingCopy);
} catch (IOException e) {
fireOperationFailed(new WorkingCopyGitEventInfo(GitOperation.OPEN_WORKING_COPY, workingCopy), e);
throw e;
}
}
}
Aggregations