Browse Source

Stop using deprecated methods of RemoteSetUrlCommand/RemoteRemoveCommand

Change-Id: I5234474b359a32bdae501b181f0726be2af1ec6a
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
stable-5.4
David Pursehouse 6 years ago
parent
commit
1a2db96c79
  1. 9
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Remote.java
  2. 2
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RemoteDeleteCommandTest.java
  3. 11
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RemoteSetUrlCommandTest.java

9
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Remote.java

@ -53,6 +53,7 @@ import org.eclipse.jgit.api.RemoteAddCommand;
import org.eclipse.jgit.api.RemoteListCommand; import org.eclipse.jgit.api.RemoteListCommand;
import org.eclipse.jgit.api.RemoteRemoveCommand; import org.eclipse.jgit.api.RemoteRemoveCommand;
import org.eclipse.jgit.api.RemoteSetUrlCommand; import org.eclipse.jgit.api.RemoteSetUrlCommand;
import org.eclipse.jgit.api.RemoteSetUrlCommand.UriType;
import org.eclipse.jgit.api.errors.JGitInternalException; import org.eclipse.jgit.api.errors.JGitInternalException;
import org.eclipse.jgit.pgm.internal.CLIText; import org.eclipse.jgit.pgm.internal.CLIText;
import org.eclipse.jgit.pgm.opt.CmdLineParser; import org.eclipse.jgit.pgm.opt.CmdLineParser;
@ -99,13 +100,13 @@ class Remote extends TextBuiltin {
cmd.call(); cmd.call();
} else if ("remove".equals(command) || "rm".equals(command)) { //$NON-NLS-1$ //$NON-NLS-2$ } else if ("remove".equals(command) || "rm".equals(command)) { //$NON-NLS-1$ //$NON-NLS-2$
RemoteRemoveCommand cmd = git.remoteRemove(); RemoteRemoveCommand cmd = git.remoteRemove();
cmd.setName(name); cmd.setRemoteName(name);
cmd.call(); cmd.call();
} else if ("set-url".equals(command)) { //$NON-NLS-1$ } else if ("set-url".equals(command)) { //$NON-NLS-1$
RemoteSetUrlCommand cmd = git.remoteSetUrl(); RemoteSetUrlCommand cmd = git.remoteSetUrl();
cmd.setName(name); cmd.setRemoteName(name);
cmd.setUri(new URIish(uri)); cmd.setRemoteUri(new URIish(uri));
cmd.setPush(push); cmd.setUriType(push ? UriType.PUSH : UriType.FETCH);
cmd.call(); cmd.call();
} else if ("update".equals(command)) { //$NON-NLS-1$ } else if ("update".equals(command)) { //$NON-NLS-1$
// reuse fetch command for basic implementation of remote update // reuse fetch command for basic implementation of remote update

2
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RemoteDeleteCommandTest.java

@ -56,7 +56,7 @@ public class RemoteDeleteCommandTest extends AbstractRemoteCommandTest {
// execute the command to remove the remote // execute the command to remove the remote
RemoteRemoveCommand cmd = Git.wrap(db).remoteRemove(); RemoteRemoveCommand cmd = Git.wrap(db).remoteRemove();
cmd.setName(REMOTE_NAME); cmd.setRemoteName(REMOTE_NAME);
RemoteConfig remote = cmd.call(); RemoteConfig remote = cmd.call();
// assert that the removed remote is the initial remote // assert that the removed remote is the initial remote

11
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RemoteSetUrlCommandTest.java

@ -45,6 +45,7 @@ package org.eclipse.jgit.api;
import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import org.eclipse.jgit.api.RemoteSetUrlCommand.UriType;
import org.eclipse.jgit.transport.RemoteConfig; import org.eclipse.jgit.transport.RemoteConfig;
import org.eclipse.jgit.transport.URIish; import org.eclipse.jgit.transport.URIish;
import org.junit.Test; import org.junit.Test;
@ -58,9 +59,9 @@ public class RemoteSetUrlCommandTest extends AbstractRemoteCommandTest {
// execute the command to change the fetch url // execute the command to change the fetch url
RemoteSetUrlCommand cmd = Git.wrap(db).remoteSetUrl(); RemoteSetUrlCommand cmd = Git.wrap(db).remoteSetUrl();
cmd.setName(REMOTE_NAME); cmd.setRemoteName(REMOTE_NAME);
URIish newUri = new URIish("git://test.com/test"); URIish newUri = new URIish("git://test.com/test");
cmd.setUri(newUri); cmd.setRemoteUri(newUri);
RemoteConfig remote = cmd.call(); RemoteConfig remote = cmd.call();
// assert that the changed remote has the new fetch url // assert that the changed remote has the new fetch url
@ -79,10 +80,10 @@ public class RemoteSetUrlCommandTest extends AbstractRemoteCommandTest {
// execute the command to change the push url // execute the command to change the push url
RemoteSetUrlCommand cmd = Git.wrap(db).remoteSetUrl(); RemoteSetUrlCommand cmd = Git.wrap(db).remoteSetUrl();
cmd.setName(REMOTE_NAME); cmd.setRemoteName(REMOTE_NAME);
URIish newUri = new URIish("git://test.com/test"); URIish newUri = new URIish("git://test.com/test");
cmd.setUri(newUri); cmd.setRemoteUri(newUri);
cmd.setPush(true); cmd.setUriType(UriType.PUSH);
RemoteConfig remote = cmd.call(); RemoteConfig remote = cmd.call();
// assert that the changed remote has the old fetch url and the new push // assert that the changed remote has the old fetch url and the new push

Loading…
Cancel
Save