1 /*
2 * Copyright (C) 2015, Kaloyan Raev <kaloyan.r@zend.com> and others
3 *
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Distribution License v. 1.0 which is available at
6 * https://www.eclipse.org/org/documents/edl-v10.php.
7 *
8 * SPDX-License-Identifier: BSD-3-Clause
9 */
10 package org.eclipse.jgit.api;
11
12 import java.net.URISyntaxException;
13 import java.util.List;
14
15 import org.eclipse.jgit.api.errors.GitAPIException;
16 import org.eclipse.jgit.api.errors.JGitInternalException;
17 import org.eclipse.jgit.lib.Repository;
18 import org.eclipse.jgit.transport.RemoteConfig;
19
20 /**
21 * Used to obtain the list of remotes.
22 *
23 * This class has setters for all supported options and arguments of this
24 * command and a {@link #call()} method to finally execute the command.
25 *
26 * @see <a href=
27 * "http://www.kernel.org/pub/software/scm/git/docs/git-remote.html" > Git
28 * documentation about Remote</a>
29 * @since 4.2
30 */
31 public class RemoteListCommand extends GitCommand<List<RemoteConfig>> {
32
33 /**
34 * <p>
35 * Constructor for RemoteListCommand.
36 * </p>
37 *
38 * @param repo
39 * the {@link org.eclipse.jgit.lib.Repository}
40 */
41 protected RemoteListCommand(Repository repo) {
42 super(repo);
43 }
44
45 /**
46 * {@inheritDoc}
47 * <p>
48 * Executes the {@code remote} command with all the options and parameters
49 * collected by the setter methods of this class.
50 */
51 @Override
52 public List<RemoteConfig> call() throws GitAPIException {
53 checkCallable();
54
55 try {
56 return RemoteConfig.getAllRemoteConfigs(repo.getConfig());
57 } catch (URISyntaxException e) {
58 throw new JGitInternalException(e.getMessage(), e);
59 }
60 }
61
62 }