aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org
diff options
context:
space:
mode:
authorDave Borowitz <dborowitz@google.com>2017-09-07 07:46:25 -0400
committerDave Borowitz <dborowitz@google.com>2017-09-07 07:46:25 -0400
commitbb09e093449b96fbec13b21577a1c9781e6ca45b (patch)
treefbbea96da8cc1172a3f9d851b0c8ade8445ba821 /org.eclipse.jgit/src/org
parente68a9b3ed8dbed4708f90d97ab2747c97aa0e123 (diff)
downloadjgit-bb09e093449b96fbec13b21577a1c9781e6ca45b.tar.gz
jgit-bb09e093449b96fbec13b21577a1c9781e6ca45b.zip
Add FetchCommand#setRefSpecs(String...) variant
Much of the time the caller can specify a RefSpec succinctly using a string, and doesn't care about calling setters. Add a convenience method for this case, and use it where applicable in JGit core. Change-Id: Ic3fac7fc568eee4759236a5264d2e7e5f9b9716d
Diffstat (limited to 'org.eclipse.jgit/src/org')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/FetchCommand.java21
1 files changed, 16 insertions, 5 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/FetchCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/FetchCommand.java
index 8f83de79ac..5270283edd 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/FetchCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/FetchCommand.java
@@ -42,10 +42,13 @@
*/
package org.eclipse.jgit.api;
+import static java.util.stream.Collectors.toList;
+
import java.io.IOException;
import java.net.URISyntaxException;
import java.text.MessageFormat;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import org.eclipse.jgit.annotations.Nullable;
@@ -392,13 +395,21 @@ public class FetchCommand extends TransportCommand<FetchCommand, FetchResult> {
*
* @param specs
* @return {@code this}
+ * @since 4.9
+ */
+ public FetchCommand setRefSpecs(String... specs) {
+ return setRefSpecs(
+ Arrays.stream(specs).map(RefSpec::new).collect(toList()));
+ }
+
+ /**
+ * The ref specs to be used in the fetch operation
+ *
+ * @param specs
+ * @return {@code this}
*/
public FetchCommand setRefSpecs(RefSpec... specs) {
- checkCallable();
- this.refSpecs.clear();
- for (RefSpec spec : specs)
- refSpecs.add(spec);
- return this;
+ return setRefSpecs(Arrays.asList(specs));
}
/**