/******************************************************************************
* Copyright (c) 2011 GitHub Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Kevin Sawicki (GitHub Inc.) - initial API and implementation
*****************************************************************************/
package org.eclipse.egit.ui.internal.commit.command;
import java.util.List;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.egit.ui.internal.branch.BranchOperationUI;
import org.eclipse.egit.ui.internal.commit.RepositoryCommit;
/**
* Checkout commit handler
*/
public class CheckoutHandler extends CommitCommandHandler {
/**
* Command id
*/
public static final String ID = "org.eclipse.egit.ui.commit.Checkout"; //$NON-NLS-1$
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
final List<RepositoryCommit> commits = getCommits(event);
if (commits.size() == 1) {
final RepositoryCommit commit = commits.get(0);
BranchOperationUI.checkout(commit.getRepository(),
commit.getRevCommit().name()).start();
}
return null;
}
}