Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: e01f3555d2302442492c7ad37a986face52821b1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*******************************************************************************
 * Copyright (C) 2016, Thomas Wolf <thomas.wolf@paranor.ch>
 *
 * 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
 *******************************************************************************/
package org.eclipse.egit.ui.internal.clone;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.egit.core.op.CloneOperation.PostCloneTask;
import org.eclipse.egit.ui.internal.KnownHosts;
import org.eclipse.jgit.annotations.NonNull;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.ui.PlatformUI;

/**
 * Stores the host name after a successful clone.
 */
public class RememberHostTask implements PostCloneTask {

	private final @NonNull String hostName;

	/**
	 * Creates a {@link PostCloneTask} that stores the given host name after a
	 * successful clone.
	 *
	 * @param hostName
	 *            to store
	 */
	public RememberHostTask(@NonNull String hostName) {
		this.hostName = hostName;
	}

	@Override
	public void execute(Repository repository, IProgressMonitor monitor)
			throws CoreException {
		PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {

			@Override
			public void run() {
				KnownHosts.addKnownHost(hostName);
			}
		});

	}

}

Back to the top