refactor: simplify collection.toArray()
[egit/eclipse.git] / org.eclipse.egit.core / src / org / eclipse / egit / core / op / SetChangeIdTask.java
blob32a874bb8f25cb12c0fafa08a471ad14ac1c0b67
1 /*******************************************************************************
2 * Copyright (C) 2011, Stefan Lay <stefan.lay@sap.com>
3 * Copyright (C) 2011, Matthias Sohn <matthias.sohn@sap.com>
5 * All rights reserved. This program and the accompanying materials
6 * are made available under the terms of the Eclipse Public License 2.0
7 * which accompanies this distribution, and is available at
8 * https://www.eclipse.org/legal/epl-2.0/
10 * SPDX-License-Identifier: EPL-2.0
11 *******************************************************************************/
12 package org.eclipse.egit.core.op;
14 import java.io.IOException;
16 import org.eclipse.core.runtime.CoreException;
17 import org.eclipse.core.runtime.IProgressMonitor;
18 import org.eclipse.egit.core.Activator;
19 import org.eclipse.egit.core.op.CloneOperation.PostCloneTask;
20 import org.eclipse.jgit.lib.ConfigConstants;
21 import org.eclipse.jgit.lib.Repository;
23 /**
24 * Sets the config property gerrit.createchangeid
26 public class SetChangeIdTask implements PostCloneTask {
28 private final boolean createchangeid;
30 /**
31 * @param createchangeid
33 public SetChangeIdTask(boolean createchangeid) {
34 this.createchangeid = createchangeid;
37 @Override
38 public void execute(Repository repository, IProgressMonitor monitor)
39 throws CoreException {
40 try {
41 repository.getConfig().setBoolean(ConfigConstants.CONFIG_GERRIT_SECTION,
42 null, ConfigConstants.CONFIG_KEY_CREATECHANGEID, createchangeid);
43 repository.getConfig().save();
44 } catch (IOException e) {
45 throw new CoreException(Activator.error(e.getMessage(), e));