Search in sources :

Example 6 with GitFlowRepository

use of org.eclipse.egit.gitflow.GitFlowRepository in project egit by eclipse.

the class DynamicHistoryMenu method getRepository.

private GitFlowRepository getRepository() {
    IWorkbenchPart activePart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
    Repository repository = Utils.getAdapter(activePart, Repository.class);
    if (repository == null) {
        return null;
    }
    return new GitFlowRepository(repository);
}
Also used : GitFlowRepository(org.eclipse.egit.gitflow.GitFlowRepository) Repository(org.eclipse.jgit.lib.Repository) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) GitFlowRepository(org.eclipse.egit.gitflow.GitFlowRepository)

Example 7 with GitFlowRepository

use of org.eclipse.egit.gitflow.GitFlowRepository in project egit by eclipse.

the class RepositoryPropertyTester method test.

@Override
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
    if (receiver == null) {
        return false;
    }
    Repository repository = null;
    if (receiver instanceof String) {
        String gitDir = (String) receiver;
        repository = org.eclipse.egit.core.Activator.getDefault().getRepositoryCache().getRepository(new File(gitDir));
    } else if (receiver instanceof Repository) {
        repository = (Repository) receiver;
    }
    if (repository == null || repository.isBare()) {
        return false;
    }
    GitFlowRepository gitFlowRepository = new GitFlowRepository(repository);
    try {
        if (IS_INITIALIZED.equals(property)) {
            return gitFlowRepository.getConfig().isInitialized();
        } else if (IS_FEATURE.equals(property)) {
            return gitFlowRepository.isFeature();
        } else if (IS_RELEASE.equals(property)) {
            return gitFlowRepository.isRelease();
        } else if (IS_HOTFIX.equals(property)) {
            return gitFlowRepository.isHotfix();
        } else if (IS_DEVELOP.equals(property)) {
            return gitFlowRepository.isDevelop();
        } else if (IS_MASTER.equals(property)) {
            return gitFlowRepository.isMaster();
        } else if (HAS_DEFAULT_REMOTE.equals(property)) {
            return gitFlowRepository.getConfig().hasDefaultRemote();
        }
    } catch (IOException e) {
        Activator.getDefault().getLog().log(error(e.getMessage(), e));
    }
    return false;
}
Also used : GitFlowRepository(org.eclipse.egit.gitflow.GitFlowRepository) Repository(org.eclipse.jgit.lib.Repository) IOException(java.io.IOException) File(java.io.File) GitFlowRepository(org.eclipse.egit.gitflow.GitFlowRepository)

Example 8 with GitFlowRepository

use of org.eclipse.egit.gitflow.GitFlowRepository in project egit by eclipse.

the class FeatureFinishHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    final GitFlowRepository gfRepo = GitFlowHandlerUtil.getRepository(event);
    if (gfRepo == null) {
        return error(UIText.Handlers_noGitflowRepositoryFound);
    }
    final String featureBranch;
    Repository repo = gfRepo.getRepository();
    try {
        featureBranch = repo.getBranch();
    } catch (IOException e) {
        return error(e.getMessage(), e);
    }
    Shell activeShell = HandlerUtil.getActiveShell(event);
    FinishFeatureDialog dialog = new FinishFeatureDialog(activeShell, featureBranch);
    if (dialog.open() != Window.OK) {
        return null;
    }
    final boolean squash = dialog.isSquash();
    boolean keepBranch = dialog.isKeepBranch();
    try {
        try {
            if (squash && !UIRepositoryUtils.handleUncommittedFiles(repo, activeShell))
                return null;
        } catch (GitAPIException e) {
            Activator.logError(e.getMessage(), e);
            return null;
        }
        final FeatureFinishOperation operation = new FeatureFinishOperation(gfRepo);
        operation.setSquash(squash);
        operation.setKeepBranch(keepBranch);
        JobUtil.scheduleUserWorkspaceJob(operation, UIText.FeatureFinishHandler_finishingFeature, JobFamilies.GITFLOW_FAMILY, new JobChangeAdapter() {

            @Override
            public void done(IJobChangeEvent jobChangeEvent) {
                if (jobChangeEvent.getResult().isOK()) {
                    postMerge(gfRepo, featureBranch, squash, operation.getMergeResult());
                }
            }
        });
    } catch (WrongGitFlowStateException | CoreException | IOException | OperationCanceledException e) {
        return error(e.getMessage(), e);
    }
    return null;
}
Also used : JobChangeAdapter(org.eclipse.core.runtime.jobs.JobChangeAdapter) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) FinishFeatureDialog(org.eclipse.egit.gitflow.ui.internal.dialogs.FinishFeatureDialog) IOException(java.io.IOException) IJobChangeEvent(org.eclipse.core.runtime.jobs.IJobChangeEvent) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) GitFlowRepository(org.eclipse.egit.gitflow.GitFlowRepository) Repository(org.eclipse.jgit.lib.Repository) Shell(org.eclipse.swt.widgets.Shell) FeatureFinishOperation(org.eclipse.egit.gitflow.op.FeatureFinishOperation) CoreException(org.eclipse.core.runtime.CoreException) WrongGitFlowStateException(org.eclipse.egit.gitflow.WrongGitFlowStateException) GitFlowRepository(org.eclipse.egit.gitflow.GitFlowRepository)

Example 9 with GitFlowRepository

use of org.eclipse.egit.gitflow.GitFlowRepository in project egit by eclipse.

the class FeatureRebaseHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    final GitFlowRepository gfRepo = GitFlowHandlerUtil.getRepository(event);
    FeatureRebaseOperation rebaseOperation = new FeatureRebaseOperation(gfRepo);
    JobUtil.scheduleUserWorkspaceJob(rebaseOperation, UIText.FeatureRebaseHandler_rebasingFeature, JobFamilies.GITFLOW_FAMILY);
    IJobManager jobMan = Job.getJobManager();
    try {
        jobMan.join(GITFLOW_FAMILY, null);
    } catch (OperationCanceledException | InterruptedException e) {
        return error(e.getMessage(), e);
    }
    RebaseResult operationResult = rebaseOperation.getOperationResult();
    RebaseResult.Status status = operationResult.getStatus();
    if (status.isSuccessful()) {
        return null;
    }
    if (STOPPED.equals(status)) {
        try {
            showInteractiveRebaseView(event);
        } catch (PartInitException e) {
            return error(e.getMessage(), e);
        }
    }
    openWarning(operationResult);
    return null;
}
Also used : OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) IJobManager(org.eclipse.core.runtime.jobs.IJobManager) PartInitException(org.eclipse.ui.PartInitException) FeatureRebaseOperation(org.eclipse.egit.gitflow.op.FeatureRebaseOperation) GitFlowRepository(org.eclipse.egit.gitflow.GitFlowRepository) RebaseResult(org.eclipse.jgit.api.RebaseResult)

Example 10 with GitFlowRepository

use of org.eclipse.egit.gitflow.GitFlowRepository in project egit by eclipse.

the class FeatureStartHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    final GitFlowRepository gfRepo = GitFlowHandlerUtil.getRepository(event);
    InputDialog inputDialog = new InputDialog(HandlerUtil.getActiveShell(event), UIText.FeatureStartHandler_provideFeatureName, UIText.FeatureStartHandler_pleaseProvideANameForTheNewFeature, // $NON-NLS-1$
    "", new FeatureNameValidator(gfRepo));
    if (inputDialog.open() != Window.OK) {
        return null;
    }
    final String featureName = inputDialog.getValue();
    FeatureStartOperation featureStartOperation = new FeatureStartOperation(gfRepo, featureName);
    JobUtil.scheduleUserWorkspaceJob(featureStartOperation, UIText.FeatureStartHandler_startingNewFeature, JobFamilies.GITFLOW_FAMILY);
    return null;
}
Also used : InputDialog(org.eclipse.jface.dialogs.InputDialog) FeatureStartOperation(org.eclipse.egit.gitflow.op.FeatureStartOperation) FeatureNameValidator(org.eclipse.egit.gitflow.ui.internal.validation.FeatureNameValidator) GitFlowRepository(org.eclipse.egit.gitflow.GitFlowRepository)

Aggregations

GitFlowRepository (org.eclipse.egit.gitflow.GitFlowRepository)57 Repository (org.eclipse.jgit.lib.Repository)35 Test (org.junit.Test)33 RevCommit (org.eclipse.jgit.revwalk.RevCommit)19 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)7 BranchOperation (org.eclipse.egit.core.op.BranchOperation)7 IOException (java.io.IOException)6 CoreException (org.eclipse.core.runtime.CoreException)6 Shell (org.eclipse.swt.widgets.Shell)6 IJobManager (org.eclipse.core.runtime.jobs.IJobManager)5 WrongGitFlowStateException (org.eclipse.egit.gitflow.WrongGitFlowStateException)5 File (java.io.File)4 Ref (org.eclipse.jgit.lib.Ref)4 GitFlowConfig (org.eclipse.egit.gitflow.GitFlowConfig)3 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)3 ExecutionException (org.eclipse.core.commands.ExecutionException)2 MultiStatus (org.eclipse.core.runtime.MultiStatus)2 InitParameters (org.eclipse.egit.gitflow.InitParameters)2 FeatureBranchSelectionDialog (org.eclipse.egit.gitflow.ui.internal.dialogs.FeatureBranchSelectionDialog)2 InputDialog (org.eclipse.jface.dialogs.InputDialog)2