Browse Source
Change-Id: Ia92c91e1226da7d6455ab14f1e255a1546f8f357 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>stable-4.2
Matthias Sohn
9 years ago
147 changed files with 5994 additions and 776 deletions
@ -0,0 +1,159 @@
|
||||
/* |
||||
* Copyright (C) 2015, Kaloyan Raev <kaloyan.r@zend.com> |
||||
* and other copyright owners as documented in the project's IP log. |
||||
* |
||||
* This program and the accompanying materials are made available |
||||
* under the terms of the Eclipse Distribution License v1.0 which |
||||
* accompanies this distribution, is reproduced below, and is |
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
* |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or |
||||
* without modification, are permitted provided that the following |
||||
* conditions are met: |
||||
* |
||||
* - Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* |
||||
* - Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following |
||||
* disclaimer in the documentation and/or other materials provided |
||||
* with the distribution. |
||||
* |
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the |
||||
* names of its contributors may be used to endorse or promote |
||||
* products derived from this software without specific prior |
||||
* written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND |
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
*/ |
||||
package org.eclipse.jgit.pgm; |
||||
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals; |
||||
import static org.junit.Assert.assertEquals; |
||||
import static org.junit.Assert.assertTrue; |
||||
|
||||
import java.util.List; |
||||
|
||||
import org.eclipse.jgit.api.Git; |
||||
import org.eclipse.jgit.lib.CLIRepositoryTestCase; |
||||
import org.eclipse.jgit.lib.Repository; |
||||
import org.eclipse.jgit.lib.StoredConfig; |
||||
import org.eclipse.jgit.transport.RefSpec; |
||||
import org.eclipse.jgit.transport.RemoteConfig; |
||||
import org.eclipse.jgit.transport.URIish; |
||||
import org.junit.Before; |
||||
import org.junit.Test; |
||||
|
||||
public class RemoteTest extends CLIRepositoryTestCase { |
||||
|
||||
private StoredConfig config; |
||||
|
||||
private RemoteConfig remote; |
||||
|
||||
@Before |
||||
@Override |
||||
public void setUp() throws Exception { |
||||
super.setUp(); |
||||
|
||||
// create another repository
|
||||
Repository remoteRepository = createWorkRepository(); |
||||
|
||||
// set it up as a remote to this repository
|
||||
config = db.getConfig(); |
||||
remote = new RemoteConfig(config, "test"); |
||||
remote.addFetchRefSpec( |
||||
new RefSpec("+refs/heads/*:refs/remotes/test/*")); |
||||
URIish uri = new URIish( |
||||
remoteRepository.getDirectory().toURI().toURL()); |
||||
remote.addURI(uri); |
||||
remote.update(config); |
||||
config.save(); |
||||
|
||||
Git.wrap(remoteRepository).commit().setMessage("initial commit").call(); |
||||
} |
||||
|
||||
@Test |
||||
public void testList() throws Exception { |
||||
assertArrayEquals(new String[] { remote.getName(), "" }, |
||||
execute("git remote")); |
||||
} |
||||
|
||||
@Test |
||||
public void testVerboseList() throws Exception { |
||||
assertArrayEquals( |
||||
new String[] { |
||||
String.format("%s\t%s (fetch)", remote.getName(), |
||||
remote.getURIs().get(0)), |
||||
String.format("%s\t%s (push)", remote.getName(), |
||||
remote.getURIs().get(0)), |
||||
"" }, |
||||
execute("git remote -v")); |
||||
} |
||||
|
||||
@Test |
||||
public void testAdd() throws Exception { |
||||
assertArrayEquals(new String[] { "" }, |
||||
execute("git remote add second git://test.com/second")); |
||||
|
||||
List<RemoteConfig> remotes = RemoteConfig.getAllRemoteConfigs(config); |
||||
assertEquals(2, remotes.size()); |
||||
assertEquals("second", remotes.get(0).getName()); |
||||
assertEquals("test", remotes.get(1).getName()); |
||||
} |
||||
|
||||
@Test |
||||
public void testRemove() throws Exception { |
||||
assertArrayEquals(new String[] { "" }, |
||||
execute("git remote remove test")); |
||||
|
||||
assertTrue(RemoteConfig.getAllRemoteConfigs(config).isEmpty()); |
||||
} |
||||
|
||||
@Test |
||||
public void testSetUrl() throws Exception { |
||||
assertArrayEquals(new String[] { "" }, |
||||
execute("git remote set-url test git://test.com/test")); |
||||
|
||||
RemoteConfig result = new RemoteConfig(config, "test"); |
||||
assertEquals("test", result.getName()); |
||||
assertArrayEquals(new URIish[] { new URIish("git://test.com/test") }, |
||||
result.getURIs().toArray()); |
||||
assertTrue(result.getPushURIs().isEmpty()); |
||||
} |
||||
|
||||
@Test |
||||
public void testSetUrlPush() throws Exception { |
||||
assertArrayEquals(new String[] { "" }, |
||||
execute("git remote set-url --push test git://test.com/test")); |
||||
|
||||
RemoteConfig result = new RemoteConfig(config, "test"); |
||||
assertEquals("test", result.getName()); |
||||
assertEquals(remote.getURIs(), result.getURIs()); |
||||
assertArrayEquals(new URIish[] { new URIish("git://test.com/test") }, |
||||
result.getPushURIs().toArray()); |
||||
} |
||||
|
||||
@Test |
||||
public void testUpdate() throws Exception { |
||||
assertArrayEquals(new String[] { |
||||
"From " + remote.getURIs().get(0).toString(), |
||||
" * [new branch] master -> test/master", "", "" }, |
||||
execute("git remote update test")); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,197 @@
|
||||
/* |
||||
* Copyright (C) 2015, Kaloyan Raev <kaloyan.r@zend.com> |
||||
* and other copyright owners as documented in the project's IP log. |
||||
* |
||||
* This program and the accompanying materials are made available |
||||
* under the terms of the Eclipse Distribution License v1.0 which |
||||
* accompanies this distribution, is reproduced below, and is |
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
* |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or |
||||
* without modification, are permitted provided that the following |
||||
* conditions are met: |
||||
* |
||||
* - Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* |
||||
* - Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following |
||||
* disclaimer in the documentation and/or other materials provided |
||||
* with the distribution. |
||||
* |
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the |
||||
* names of its contributors may be used to endorse or promote |
||||
* products derived from this software without specific prior |
||||
* written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND |
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
*/ |
||||
package org.eclipse.jgit.pgm; |
||||
|
||||
import java.io.IOException; |
||||
import java.io.StringWriter; |
||||
import java.text.MessageFormat; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
import org.eclipse.jgit.api.Git; |
||||
import org.eclipse.jgit.api.RemoteAddCommand; |
||||
import org.eclipse.jgit.api.RemoteListCommand; |
||||
import org.eclipse.jgit.api.RemoteRemoveCommand; |
||||
import org.eclipse.jgit.api.RemoteSetUrlCommand; |
||||
import org.eclipse.jgit.api.errors.JGitInternalException; |
||||
import org.eclipse.jgit.pgm.internal.CLIText; |
||||
import org.eclipse.jgit.pgm.opt.CmdLineParser; |
||||
import org.eclipse.jgit.transport.RemoteConfig; |
||||
import org.eclipse.jgit.transport.URIish; |
||||
import org.eclipse.jgit.util.io.ThrowingPrintWriter; |
||||
import org.kohsuke.args4j.Argument; |
||||
import org.kohsuke.args4j.Option; |
||||
|
||||
@Command(common = false, usage = "usage_Remote") |
||||
class Remote extends TextBuiltin { |
||||
|
||||
@Option(name = "--verbose", aliases = { "-v" }, usage = "usage_beVerbose") |
||||
private boolean verbose = false; |
||||
|
||||
@Option(name = "--prune", aliases = { |
||||
"-p" }, usage = "usage_pruneStaleTrackingRefs") |
||||
private boolean prune; |
||||
|
||||
@Option(name = "--push", usage = "usage_pushUrls") |
||||
private boolean push; |
||||
|
||||
@Argument(index = 0, metaVar = "metaVar_command") |
||||
private String command; |
||||
|
||||
@Argument(index = 1, metaVar = "metaVar_remoteName") |
||||
private String name; |
||||
|
||||
@Argument(index = 2, metaVar = "metaVar_uriish") |
||||
private String uri; |
||||
|
||||
@Override |
||||
protected void run() throws Exception { |
||||
try (Git git = new Git(db)) { |
||||
if (command == null) { |
||||
RemoteListCommand cmd = git.remoteList(); |
||||
List<RemoteConfig> remotes = cmd.call(); |
||||
print(remotes); |
||||
} else if ("add".equals(command)) { //$NON-NLS-1$
|
||||
RemoteAddCommand cmd = git.remoteAdd(); |
||||
cmd.setName(name); |
||||
cmd.setUri(new URIish(uri)); |
||||
cmd.call(); |
||||
} else if ("remove".equals(command) || "rm".equals(command)) { //$NON-NLS-1$ //$NON-NLS-2$
|
||||
RemoteRemoveCommand cmd = git.remoteRemove(); |
||||
cmd.setName(name); |
||||
cmd.call(); |
||||
} else if ("set-url".equals(command)) { //$NON-NLS-1$
|
||||
RemoteSetUrlCommand cmd = git.remoteSetUrl(); |
||||
cmd.setName(name); |
||||
cmd.setUri(new URIish(uri)); |
||||
cmd.setPush(push); |
||||
cmd.call(); |
||||
} else if ("update".equals(command)) { //$NON-NLS-1$
|
||||
// reuse fetch command for basic implementation of remote update
|
||||
Fetch fetch = new Fetch(); |
||||
fetch.init(db, gitdir); |
||||
|
||||
// redirect the output stream
|
||||
StringWriter osw = new StringWriter(); |
||||
fetch.outw = new ThrowingPrintWriter(osw); |
||||
// redirect the error stream
|
||||
StringWriter esw = new StringWriter(); |
||||
fetch.errw = new ThrowingPrintWriter(esw); |
||||
|
||||
List<String> fetchArgs = new ArrayList<>(); |
||||
if (verbose) { |
||||
fetchArgs.add("--verbose"); //$NON-NLS-1$
|
||||
} |
||||
if (prune) { |
||||
fetchArgs.add("--prune"); //$NON-NLS-1$
|
||||
} |
||||
if (name != null) { |
||||
fetchArgs.add(name); |
||||
} |
||||
|
||||
fetch.execute(fetchArgs.toArray(new String[fetchArgs.size()])); |
||||
|
||||
// flush the streams
|
||||
fetch.outw.flush(); |
||||
fetch.errw.flush(); |
||||
outw.println(osw.toString()); |
||||
errw.println(esw.toString()); |
||||
} else { |
||||
throw new JGitInternalException(MessageFormat |
||||
.format(CLIText.get().unknownSubcommand, command)); |
||||
} |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void printUsageAndExit(final String message, final CmdLineParser clp) |
||||
throws IOException { |
||||
errw.println(message); |
||||
errw.println("jgit remote [--verbose (-v)] [--help (-h)]"); //$NON-NLS-1$
|
||||
errw.println("jgit remote add name uri-ish [--help (-h)]"); //$NON-NLS-1$
|
||||
errw.println("jgit remote remove name [--help (-h)]"); //$NON-NLS-1$
|
||||
errw.println("jgit remote rm name [--help (-h)]"); //$NON-NLS-1$
|
||||
errw.println( |
||||
"jgit remote [--verbose (-v)] update [name] [--prune (-p)] [--help (-h)]"); //$NON-NLS-1$
|
||||
errw.println("jgit remote set-url name uri-ish [--push] [--help (-h)]"); //$NON-NLS-1$
|
||||
|
||||
errw.println(); |
||||
clp.printUsage(errw, getResourceBundle()); |
||||
errw.println(); |
||||
|
||||
errw.flush(); |
||||
throw die(true); |
||||
} |
||||
|
||||
private void print(List<RemoteConfig> remotes) throws IOException { |
||||
for (RemoteConfig remote : remotes) { |
||||
String remoteName = remote.getName(); |
||||
if (verbose) { |
||||
List<URIish> fetchURIs = remote.getURIs(); |
||||
List<URIish> pushURIs = remote.getPushURIs(); |
||||
|
||||
String fetchURI = ""; //$NON-NLS-1$
|
||||
if (!fetchURIs.isEmpty()) { |
||||
fetchURI = fetchURIs.get(0).toString(); |
||||
} else if (!pushURIs.isEmpty()) { |
||||
fetchURI = pushURIs.get(0).toString(); |
||||
} |
||||
|
||||
String pushURI = ""; //$NON-NLS-1$
|
||||
if (!pushURIs.isEmpty()) { |
||||
pushURI = pushURIs.get(0).toString(); |
||||
} else if (!fetchURIs.isEmpty()) { |
||||
pushURI = fetchURIs.get(0).toString(); |
||||
} |
||||
|
||||
outw.println( |
||||
String.format("%s\t%s (fetch)", remoteName, fetchURI)); //$NON-NLS-1$
|
||||
outw.println( |
||||
String.format("%s\t%s (push)", remoteName, pushURI)); //$NON-NLS-1$
|
||||
} else { |
||||
outw.println(remoteName); |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,96 @@
|
||||
/* |
||||
* Copyright (C) 2015, Kaloyan Raev <kaloyan.r@zend.com> |
||||
* and other copyright owners as documented in the project's IP log. |
||||
* |
||||
* This program and the accompanying materials are made available |
||||
* under the terms of the Eclipse Distribution License v1.0 which |
||||
* accompanies this distribution, is reproduced below, and is |
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
* |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or |
||||
* without modification, are permitted provided that the following |
||||
* conditions are met: |
||||
* |
||||
* - Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* |
||||
* - Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following |
||||
* disclaimer in the documentation and/or other materials provided |
||||
* with the distribution. |
||||
* |
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the |
||||
* names of its contributors may be used to endorse or promote |
||||
* products derived from this software without specific prior |
||||
* written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND |
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
*/ |
||||
package org.eclipse.jgit.api; |
||||
|
||||
import static org.junit.Assert.assertEquals; |
||||
|
||||
import java.io.IOException; |
||||
import java.net.URISyntaxException; |
||||
|
||||
import org.eclipse.jgit.junit.RepositoryTestCase; |
||||
import org.eclipse.jgit.lib.Constants; |
||||
import org.eclipse.jgit.lib.Repository; |
||||
import org.eclipse.jgit.lib.StoredConfig; |
||||
import org.eclipse.jgit.transport.RefSpec; |
||||
import org.eclipse.jgit.transport.RemoteConfig; |
||||
import org.eclipse.jgit.transport.URIish; |
||||
|
||||
public class AbstractRemoteCommandTest extends RepositoryTestCase { |
||||
|
||||
protected static final String REMOTE_NAME = "test"; |
||||
|
||||
protected RemoteConfig setupRemote() |
||||
throws IOException, URISyntaxException { |
||||
// create another repository
|
||||
Repository remoteRepository = createWorkRepository(); |
||||
|
||||
// set it up as a remote to this repository
|
||||
final StoredConfig config = db.getConfig(); |
||||
RemoteConfig remoteConfig = new RemoteConfig(config, REMOTE_NAME); |
||||
|
||||
RefSpec refSpec = new RefSpec(); |
||||
refSpec = refSpec.setForceUpdate(true); |
||||
refSpec = refSpec.setSourceDestination(Constants.R_HEADS + "*", |
||||
Constants.R_REMOTES + REMOTE_NAME + "/*"); |
||||
remoteConfig.addFetchRefSpec(refSpec); |
||||
|
||||
URIish uri = new URIish( |
||||
remoteRepository.getDirectory().toURI().toURL()); |
||||
remoteConfig.addURI(uri); |
||||
|
||||
remoteConfig.update(config); |
||||
config.save(); |
||||
|
||||
return remoteConfig; |
||||
} |
||||
|
||||
protected void assertRemoteConfigEquals(RemoteConfig expected, |
||||
RemoteConfig actual) { |
||||
assertEquals(expected.getName(), actual.getName()); |
||||
assertEquals(expected.getURIs(), actual.getURIs()); |
||||
assertEquals(expected.getPushURIs(), actual.getPushURIs()); |
||||
assertEquals(expected.getFetchRefSpecs(), actual.getFetchRefSpecs()); |
||||
assertEquals(expected.getPushRefSpecs(), actual.getPushRefSpecs()); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,81 @@
|
||||
/* |
||||
* Copyright (C) 2015, Kaloyan Raev <kaloyan.r@zend.com> |
||||
* and other copyright owners as documented in the project's IP log. |
||||
* |
||||
* This program and the accompanying materials are made available |
||||
* under the terms of the Eclipse Distribution License v1.0 which |
||||
* accompanies this distribution, is reproduced below, and is |
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
* |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or |
||||
* without modification, are permitted provided that the following |
||||
* conditions are met: |
||||
* |
||||
* - Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* |
||||
* - Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following |
||||
* disclaimer in the documentation and/or other materials provided |
||||
* with the distribution. |
||||
* |
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the |
||||
* names of its contributors may be used to endorse or promote |
||||
* products derived from this software without specific prior |
||||
* written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND |
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
*/ |
||||
package org.eclipse.jgit.api; |
||||
|
||||
import static org.junit.Assert.assertArrayEquals; |
||||
import static org.junit.Assert.assertEquals; |
||||
|
||||
import org.eclipse.jgit.lib.Repository; |
||||
import org.eclipse.jgit.transport.RemoteConfig; |
||||
import org.eclipse.jgit.transport.URIish; |
||||
import org.junit.Test; |
||||
|
||||
public class RemoteAddCommandTest extends AbstractRemoteCommandTest { |
||||
|
||||
@Test |
||||
public void testAdd() throws Exception { |
||||
// create another repository
|
||||
Repository remoteRepository = createWorkRepository(); |
||||
URIish uri = new URIish( |
||||
remoteRepository.getDirectory().toURI().toURL()); |
||||
|
||||
// execute the command to add a new remote
|
||||
RemoteAddCommand cmd = Git.wrap(db).remoteAdd(); |
||||
cmd.setName(REMOTE_NAME); |
||||
cmd.setUri(uri); |
||||
RemoteConfig remote = cmd.call(); |
||||
|
||||
// assert that the added remote represents the remote repository
|
||||
assertEquals(REMOTE_NAME, remote.getName()); |
||||
assertArrayEquals(new URIish[] { uri }, remote.getURIs().toArray()); |
||||
assertEquals(1, remote.getFetchRefSpecs().size()); |
||||
assertEquals( |
||||
String.format("+refs/heads/*:refs/remotes/%s/*", REMOTE_NAME), |
||||
remote.getFetchRefSpecs().get(0).toString()); |
||||
|
||||
// assert that the added remote is available in the git configuration
|
||||
assertRemoteConfigEquals(remote, |
||||
new RemoteConfig(db.getConfig(), REMOTE_NAME)); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,68 @@
|
||||
/* |
||||
* Copyright (C) 2015, Kaloyan Raev <kaloyan.r@zend.com> |
||||
* and other copyright owners as documented in the project's IP log. |
||||
* |
||||
* This program and the accompanying materials are made available |
||||
* under the terms of the Eclipse Distribution License v1.0 which |
||||
* accompanies this distribution, is reproduced below, and is |
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
* |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or |
||||
* without modification, are permitted provided that the following |
||||
* conditions are met: |
||||
* |
||||
* - Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* |
||||
* - Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following |
||||
* disclaimer in the documentation and/or other materials provided |
||||
* with the distribution. |
||||
* |
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the |
||||
* names of its contributors may be used to endorse or promote |
||||
* products derived from this software without specific prior |
||||
* written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND |
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
*/ |
||||
package org.eclipse.jgit.api; |
||||
|
||||
import static org.junit.Assert.assertTrue; |
||||
|
||||
import org.eclipse.jgit.transport.RemoteConfig; |
||||
import org.junit.Test; |
||||
|
||||
public class RemoteDeleteCommandTest extends AbstractRemoteCommandTest { |
||||
|
||||
@Test |
||||
public void testDelete() throws Exception { |
||||
// setup an initial remote
|
||||
RemoteConfig remoteConfig = setupRemote(); |
||||
|
||||
// execute the command to remove the remote
|
||||
RemoteRemoveCommand cmd = Git.wrap(db).remoteRemove(); |
||||
cmd.setName(REMOTE_NAME); |
||||
RemoteConfig remote = cmd.call(); |
||||
|
||||
// assert that the removed remote is the initial remote
|
||||
assertRemoteConfigEquals(remoteConfig, remote); |
||||
// assert that there are no remotes left
|
||||
assertTrue(RemoteConfig.getAllRemoteConfigs(db.getConfig()).isEmpty()); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,68 @@
|
||||
/* |
||||
* Copyright (C) 2015, Kaloyan Raev <kaloyan.r@zend.com> |
||||
* and other copyright owners as documented in the project's IP log. |
||||
* |
||||
* This program and the accompanying materials are made available |
||||
* under the terms of the Eclipse Distribution License v1.0 which |
||||
* accompanies this distribution, is reproduced below, and is |
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
* |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or |
||||
* without modification, are permitted provided that the following |
||||
* conditions are met: |
||||
* |
||||
* - Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* |
||||
* - Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following |
||||
* disclaimer in the documentation and/or other materials provided |
||||
* with the distribution. |
||||
* |
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the |
||||
* names of its contributors may be used to endorse or promote |
||||
* products derived from this software without specific prior |
||||
* written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND |
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
*/ |
||||
package org.eclipse.jgit.api; |
||||
|
||||
import static org.junit.Assert.assertEquals; |
||||
|
||||
import java.util.List; |
||||
|
||||
import org.eclipse.jgit.transport.RemoteConfig; |
||||
import org.junit.Test; |
||||
|
||||
public class RemoteListCommandTest extends AbstractRemoteCommandTest { |
||||
|
||||
@Test |
||||
public void testList() throws Exception { |
||||
// setup an initial remote
|
||||
RemoteConfig remoteConfig = setupRemote(); |
||||
|
||||
// execute the command to list the remotes
|
||||
List<RemoteConfig> remotes = Git.wrap(db).remoteList().call(); |
||||
|
||||
// assert that there is only one remote
|
||||
assertEquals(1, remotes.size()); |
||||
// assert that the available remote is the initial remote
|
||||
assertRemoteConfigEquals(remoteConfig, remotes.get(0)); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,100 @@
|
||||
/* |
||||
* Copyright (C) 2015, Kaloyan Raev <kaloyan.r@zend.com> |
||||
* and other copyright owners as documented in the project's IP log. |
||||
* |
||||
* This program and the accompanying materials are made available |
||||
* under the terms of the Eclipse Distribution License v1.0 which |
||||
* accompanies this distribution, is reproduced below, and is |
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
* |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or |
||||
* without modification, are permitted provided that the following |
||||
* conditions are met: |
||||
* |
||||
* - Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* |
||||
* - Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following |
||||
* disclaimer in the documentation and/or other materials provided |
||||
* with the distribution. |
||||
* |
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the |
||||
* names of its contributors may be used to endorse or promote |
||||
* products derived from this software without specific prior |
||||
* written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND |
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
*/ |
||||
package org.eclipse.jgit.api; |
||||
|
||||
import static org.junit.Assert.assertArrayEquals; |
||||
import static org.junit.Assert.assertEquals; |
||||
|
||||
import org.eclipse.jgit.transport.RemoteConfig; |
||||
import org.eclipse.jgit.transport.URIish; |
||||
import org.junit.Test; |
||||
|
||||
public class RemoteSetUrlCommandTest extends AbstractRemoteCommandTest { |
||||
|
||||
@Test |
||||
public void testSetUrl() throws Exception { |
||||
// setup an initial remote
|
||||
setupRemote(); |
||||
|
||||
// execute the command to change the fetch url
|
||||
RemoteSetUrlCommand cmd = Git.wrap(db).remoteSetUrl(); |
||||
cmd.setName(REMOTE_NAME); |
||||
URIish newUri = new URIish("git://test.com/test"); |
||||
cmd.setUri(newUri); |
||||
RemoteConfig remote = cmd.call(); |
||||
|
||||
// assert that the changed remote has the new fetch url
|
||||
assertEquals(REMOTE_NAME, remote.getName()); |
||||
assertArrayEquals(new URIish[] { newUri }, remote.getURIs().toArray()); |
||||
|
||||
// assert that the changed remote is available in the git configuration
|
||||
assertRemoteConfigEquals(remote, |
||||
new RemoteConfig(db.getConfig(), REMOTE_NAME)); |
||||
} |
||||
|
||||
@Test |
||||
public void testSetPushUrl() throws Exception { |
||||
// setup an initial remote
|
||||
RemoteConfig remoteConfig = setupRemote(); |
||||
|
||||
// execute the command to change the push url
|
||||
RemoteSetUrlCommand cmd = Git.wrap(db).remoteSetUrl(); |
||||
cmd.setName(REMOTE_NAME); |
||||
URIish newUri = new URIish("git://test.com/test"); |
||||
cmd.setUri(newUri); |
||||
cmd.setPush(true); |
||||
RemoteConfig remote = cmd.call(); |
||||
|
||||
// assert that the changed remote has the old fetch url and the new push
|
||||
// url
|
||||
assertEquals(REMOTE_NAME, remote.getName()); |
||||
assertEquals(remoteConfig.getURIs(), remote.getURIs()); |
||||
assertArrayEquals(new URIish[] { newUri }, |
||||
remote.getPushURIs().toArray()); |
||||
|
||||
// assert that the changed remote is available in the git configuration
|
||||
assertRemoteConfigEquals(remote, |
||||
new RemoteConfig(db.getConfig(), REMOTE_NAME)); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,200 @@
|
||||
/* |
||||
* Copyright (C) 2015, Google Inc. |
||||
* and other copyright owners as documented in the project's IP log. |
||||
* |
||||
* This program and the accompanying materials are made available |
||||
* under the terms of the Eclipse Distribution License v1.0 which |
||||
* accompanies this distribution, is reproduced below, and is |
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
* |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or |
||||
* without modification, are permitted provided that the following |
||||
* conditions are met: |
||||
* |
||||
* - Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* |
||||
* - Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following |
||||
* disclaimer in the documentation and/or other materials provided |
||||
* with the distribution. |
||||
* |
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the |
||||
* names of its contributors may be used to endorse or promote |
||||
* products derived from this software without specific prior |
||||
* written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND |
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
*/ |
||||
|
||||
package org.eclipse.jgit.transport; |
||||
|
||||
import static org.junit.Assert.assertEquals; |
||||
import static org.junit.Assert.assertSame; |
||||
import static org.junit.Assert.fail; |
||||
|
||||
import java.io.IOException; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
import org.eclipse.jgit.errors.TransportException; |
||||
import org.eclipse.jgit.internal.JGitText; |
||||
import org.eclipse.jgit.internal.storage.dfs.DfsRepositoryDescription; |
||||
import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository; |
||||
import org.eclipse.jgit.lib.Constants; |
||||
import org.eclipse.jgit.lib.NullProgressMonitor; |
||||
import org.eclipse.jgit.lib.ObjectId; |
||||
import org.eclipse.jgit.lib.ObjectInserter; |
||||
import org.eclipse.jgit.lib.Repository; |
||||
import org.eclipse.jgit.transport.resolver.ReceivePackFactory; |
||||
import org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException; |
||||
import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException; |
||||
import org.junit.After; |
||||
import org.junit.Before; |
||||
import org.junit.Test; |
||||
|
||||
public class AtomicPushTest { |
||||
private URIish uri; |
||||
private TestProtocol<Object> testProtocol; |
||||
private Object ctx = new Object(); |
||||
private InMemoryRepository server; |
||||
private InMemoryRepository client; |
||||
private ObjectId obj1; |
||||
private ObjectId obj2; |
||||
|
||||
@Before |
||||
public void setUp() throws Exception { |
||||
server = newRepo("server"); |
||||
client = newRepo("client"); |
||||
testProtocol = new TestProtocol<>( |
||||
null, |
||||
new ReceivePackFactory<Object>() { |
||||
@Override |
||||
public ReceivePack create(Object req, Repository db) |
||||
throws ServiceNotEnabledException, |
||||
ServiceNotAuthorizedException { |
||||
return new ReceivePack(db); |
||||
} |
||||
}); |
||||
uri = testProtocol.register(ctx, server); |
||||
|
||||
try (ObjectInserter ins = client.newObjectInserter()) { |
||||
obj1 = ins.insert(Constants.OBJ_BLOB, Constants.encode("test")); |
||||
obj2 = ins.insert(Constants.OBJ_BLOB, Constants.encode("file")); |
||||
ins.flush(); |
||||
} |
||||
} |
||||
|
||||
@After |
||||
public void tearDown() { |
||||
Transport.unregister(testProtocol); |
||||
} |
||||
|
||||
private static InMemoryRepository newRepo(String name) { |
||||
return new InMemoryRepository(new DfsRepositoryDescription(name)); |
||||
} |
||||
|
||||
@Test |
||||
public void pushNonAtomic() throws Exception { |
||||
PushResult r; |
||||
server.setPerformsAtomicTransactions(false); |
||||
Transport tn = testProtocol.open(uri, client, "server"); |
||||
try { |
||||
tn.setPushAtomic(false); |
||||
r = tn.push(NullProgressMonitor.INSTANCE, commands()); |
||||
} finally { |
||||
tn.close(); |
||||
} |
||||
|
||||
RemoteRefUpdate one = r.getRemoteUpdate("refs/heads/one"); |
||||
RemoteRefUpdate two = r.getRemoteUpdate("refs/heads/two"); |
||||
assertSame(RemoteRefUpdate.Status.OK, one.getStatus()); |
||||
assertSame( |
||||
RemoteRefUpdate.Status.REJECTED_REMOTE_CHANGED, |
||||
two.getStatus()); |
||||
} |
||||
|
||||
@Test |
||||
public void pushAtomicClientGivesUpEarly() throws Exception { |
||||
PushResult r; |
||||
Transport tn = testProtocol.open(uri, client, "server"); |
||||
try { |
||||
tn.setPushAtomic(true); |
||||
r = tn.push(NullProgressMonitor.INSTANCE, commands()); |
||||
} finally { |
||||
tn.close(); |
||||
} |
||||
|
||||
RemoteRefUpdate one = r.getRemoteUpdate("refs/heads/one"); |
||||
RemoteRefUpdate two = r.getRemoteUpdate("refs/heads/two"); |
||||
assertSame( |
||||
RemoteRefUpdate.Status.REJECTED_OTHER_REASON, |
||||
one.getStatus()); |
||||
assertSame( |
||||
RemoteRefUpdate.Status.REJECTED_REMOTE_CHANGED, |
||||
two.getStatus()); |
||||
assertEquals(JGitText.get().transactionAborted, one.getMessage()); |
||||
} |
||||
|
||||
@Test |
||||
public void pushAtomicDisabled() throws Exception { |
||||
List<RemoteRefUpdate> cmds = new ArrayList<>(); |
||||
cmds.add(new RemoteRefUpdate( |
||||
null, null, |
||||
obj1, "refs/heads/one", |
||||
true /* force update */, |
||||
null /* no local tracking ref */, |
||||
ObjectId.zeroId())); |
||||
cmds.add(new RemoteRefUpdate( |
||||
null, null, |
||||
obj2, "refs/heads/two", |
||||
true /* force update */, |
||||
null /* no local tracking ref */, |
||||
ObjectId.zeroId())); |
||||
|
||||
server.setPerformsAtomicTransactions(false); |
||||
Transport tn = testProtocol.open(uri, client, "server"); |
||||
try { |
||||
tn.setPushAtomic(true); |
||||
tn.push(NullProgressMonitor.INSTANCE, cmds); |
||||
fail("did not throw TransportException"); |
||||
} catch (TransportException e) { |
||||
assertEquals( |
||||
uri + ": " + JGitText.get().atomicPushNotSupported, |
||||
e.getMessage()); |
||||
} finally { |
||||
tn.close(); |
||||
} |
||||
} |
||||
|
||||
private List<RemoteRefUpdate> commands() throws IOException { |
||||
List<RemoteRefUpdate> cmds = new ArrayList<>(); |
||||
cmds.add(new RemoteRefUpdate( |
||||
null, null, |
||||
obj1, "refs/heads/one", |
||||
true /* force update */, |
||||
null /* no local tracking ref */, |
||||
ObjectId.zeroId())); |
||||
cmds.add(new RemoteRefUpdate( |
||||
null, null, |
||||
obj2, "refs/heads/two", |
||||
true /* force update */, |
||||
null /* no local tracking ref */, |
||||
obj1)); |
||||
return cmds; |
||||
} |
||||
} |
@ -0,0 +1,143 @@
|
||||
/* |
||||
* Copyright (C) 2015, Google Inc. |
||||
* and other copyright owners as documented in the project's IP log. |
||||
* |
||||
* This program and the accompanying materials are made available |
||||
* under the terms of the Eclipse Distribution License v1.0 which |
||||
* accompanies this distribution, is reproduced below, and is |
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
* |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or |
||||
* without modification, are permitted provided that the following |
||||
* conditions are met: |
||||
* |
||||
* - Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* |
||||
* - Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following |
||||
* disclaimer in the documentation and/or other materials provided |
||||
* with the distribution. |
||||
* |
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the |
||||
* names of its contributors may be used to endorse or promote |
||||
* products derived from this software without specific prior |
||||
* written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND |
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
*/ |
||||
|
||||
package org.eclipse.jgit.transport; |
||||
|
||||
import static org.eclipse.jgit.transport.RemoteRefUpdate.Status.REJECTED_OTHER_REASON; |
||||
import static org.junit.Assert.assertEquals; |
||||
|
||||
import java.io.IOException; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
import org.eclipse.jgit.internal.storage.dfs.DfsRepositoryDescription; |
||||
import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository; |
||||
import org.eclipse.jgit.lib.Constants; |
||||
import org.eclipse.jgit.lib.NullProgressMonitor; |
||||
import org.eclipse.jgit.lib.ObjectId; |
||||
import org.eclipse.jgit.lib.ObjectInserter; |
||||
import org.eclipse.jgit.lib.RefUpdate; |
||||
import org.eclipse.jgit.lib.Repository; |
||||
import org.eclipse.jgit.transport.resolver.ReceivePackFactory; |
||||
import org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException; |
||||
import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException; |
||||
import org.junit.After; |
||||
import org.junit.Before; |
||||
import org.junit.Test; |
||||
|
||||
public class PushConnectionTest { |
||||
private URIish uri; |
||||
private TestProtocol<Object> testProtocol; |
||||
private Object ctx = new Object(); |
||||
private InMemoryRepository server; |
||||
private InMemoryRepository client; |
||||
private ObjectId obj1; |
||||
private ObjectId obj2; |
||||
private ObjectId obj3; |
||||
private String refName = "refs/tags/blob"; |
||||
|
||||
@Before |
||||
public void setUp() throws Exception { |
||||
server = newRepo("server"); |
||||
client = newRepo("client"); |
||||
testProtocol = new TestProtocol<>( |
||||
null, |
||||
new ReceivePackFactory<Object>() { |
||||
@Override |
||||
public ReceivePack create(Object req, Repository db) |
||||
throws ServiceNotEnabledException, |
||||
ServiceNotAuthorizedException { |
||||
return new ReceivePack(db); |
||||
} |
||||
}); |
||||
uri = testProtocol.register(ctx, server); |
||||
|
||||
try (ObjectInserter ins = server.newObjectInserter()) { |
||||
obj1 = ins.insert(Constants.OBJ_BLOB, Constants.encode("test")); |
||||
obj3 = ins.insert(Constants.OBJ_BLOB, Constants.encode("not")); |
||||
ins.flush(); |
||||
|
||||
RefUpdate u = server.updateRef(refName); |
||||
u.setNewObjectId(obj1); |
||||
assertEquals(RefUpdate.Result.NEW, u.update()); |
||||
} |
||||
|
||||
try (ObjectInserter ins = client.newObjectInserter()) { |
||||
obj2 = ins.insert(Constants.OBJ_BLOB, Constants.encode("file")); |
||||
ins.flush(); |
||||
} |
||||
} |
||||
|
||||
@After |
||||
public void tearDown() { |
||||
Transport.unregister(testProtocol); |
||||
} |
||||
|
||||
private static InMemoryRepository newRepo(String name) { |
||||
return new InMemoryRepository(new DfsRepositoryDescription(name)); |
||||
} |
||||
|
||||
@Test |
||||
public void testWrongOldIdDoesNotReplace() throws IOException { |
||||
RemoteRefUpdate rru = new RemoteRefUpdate(null, null, obj2, refName, |
||||
false, null, obj3); |
||||
|
||||
Map<String, RemoteRefUpdate> updates = new HashMap<>(); |
||||
updates.put(rru.getRemoteName(), rru); |
||||
|
||||
Transport tn = testProtocol.open(uri, client, "server"); |
||||
try { |
||||
PushConnection connection = tn.openPush(); |
||||
try { |
||||
connection.push(NullProgressMonitor.INSTANCE, updates); |
||||
} finally { |
||||
connection.close(); |
||||
} |
||||
} finally { |
||||
tn.close(); |
||||
} |
||||
|
||||
assertEquals(REJECTED_OTHER_REASON, rru.getStatus()); |
||||
assertEquals("invalid old id sent", rru.getMessage()); |
||||
} |
||||
} |
@ -0,0 +1,69 @@
|
||||
/* |
||||
* Copyright (C) 2015, Andrey Loskutov <loskutov@gmx.de> |
||||
* and other copyright owners as documented in the project's IP log. |
||||
* |
||||
* This program and the accompanying materials are made available |
||||
* under the terms of the Eclipse Distribution License v1.0 which |
||||
* accompanies this distribution, is reproduced below, and is |
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
* |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or |
||||
* without modification, are permitted provided that the following |
||||
* conditions are met: |
||||
* |
||||
* - Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* |
||||
* - Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following |
||||
* disclaimer in the documentation and/or other materials provided |
||||
* with the distribution. |
||||
* |
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the |
||||
* names of its contributors may be used to endorse or promote |
||||
* products derived from this software without specific prior |
||||
* written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND |
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
*/ |
||||
|
||||
package org.eclipse.jgit.annotations; |
||||
|
||||
import static java.lang.annotation.ElementType.FIELD; |
||||
import static java.lang.annotation.ElementType.LOCAL_VARIABLE; |
||||
import static java.lang.annotation.ElementType.METHOD; |
||||
import static java.lang.annotation.ElementType.PARAMETER; |
||||
|
||||
import java.lang.annotation.Documented; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
/** |
||||
* JGit's replacement for the {@code javax.annotation.Nonnull}. |
||||
* <p> |
||||
* Denotes that a local variable, parameter, field, method return value expected |
||||
* to be non {@code null}. |
||||
* |
||||
* @since 4.2 |
||||
*/ |
||||
@Documented |
||||
@Retention(RetentionPolicy.CLASS) |
||||
@Target({ FIELD, METHOD, PARAMETER, LOCAL_VARIABLE }) |
||||
public @interface NonNull { |
||||
// marker annotation with no members
|
||||
} |
@ -0,0 +1,133 @@
|
||||
/* |
||||
* Copyright (C) 2015, Kaloyan Raev <kaloyan.r@zend.com> |
||||
* and other copyright owners as documented in the project's IP log. |
||||
* |
||||
* This program and the accompanying materials are made available |
||||
* under the terms of the Eclipse Distribution License v1.0 which |
||||
* accompanies this distribution, is reproduced below, and is |
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
* |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or |
||||
* without modification, are permitted provided that the following |
||||
* conditions are met: |
||||
* |
||||
* - Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* |
||||
* - Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following |
||||
* disclaimer in the documentation and/or other materials provided |
||||
* with the distribution. |
||||
* |
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the |
||||
* names of its contributors may be used to endorse or promote |
||||
* products derived from this software without specific prior |
||||
* written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND |
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
*/ |
||||
package org.eclipse.jgit.api; |
||||
|
||||
import java.io.IOException; |
||||
import java.net.URISyntaxException; |
||||
|
||||
import org.eclipse.jgit.api.errors.GitAPIException; |
||||
import org.eclipse.jgit.api.errors.JGitInternalException; |
||||
import org.eclipse.jgit.lib.Constants; |
||||
import org.eclipse.jgit.lib.Repository; |
||||
import org.eclipse.jgit.lib.StoredConfig; |
||||
import org.eclipse.jgit.transport.RefSpec; |
||||
import org.eclipse.jgit.transport.RemoteConfig; |
||||
import org.eclipse.jgit.transport.URIish; |
||||
|
||||
/** |
||||
* Used to add a new remote. |
||||
* |
||||
* This class has setters for all supported options and arguments of this |
||||
* command and a {@link #call()} method to finally execute the command. |
||||
* |
||||
* @see <a href= |
||||
* "http://www.kernel.org/pub/software/scm/git/docs/git-remote.html" > Git |
||||
* documentation about Remote</a> |
||||
* |
||||
* @since 4.2 |
||||
*/ |
||||
public class RemoteAddCommand extends GitCommand<RemoteConfig> { |
||||
|
||||
private String name; |
||||
|
||||
private URIish uri; |
||||
|
||||
/** |
||||
* @param repo |
||||
*/ |
||||
protected RemoteAddCommand(Repository repo) { |
||||
super(repo); |
||||
} |
||||
|
||||
/** |
||||
* The name of the remote to add. |
||||
* |
||||
* @param name |
||||
* a remote name |
||||
*/ |
||||
public void setName(String name) { |
||||
this.name = name; |
||||
} |
||||
|
||||
/** |
||||
* The URL of the repository for the new remote. |
||||
* |
||||
* @param uri |
||||
* an URL for the remote |
||||
*/ |
||||
public void setUri(URIish uri) { |
||||
this.uri = uri; |
||||
} |
||||
|
||||
/** |
||||
* Executes the {@code remote add} command with all the options and |
||||
* parameters collected by the setter methods of this class. |
||||
* |
||||
* @return the {@link RemoteConfig} object of the added remote |
||||
*/ |
||||
@Override |
||||
public RemoteConfig call() throws GitAPIException { |
||||
checkCallable(); |
||||
|
||||
try { |
||||
StoredConfig config = repo.getConfig(); |
||||
RemoteConfig remote = new RemoteConfig(config, name); |
||||
|
||||
RefSpec refSpec = new RefSpec(); |
||||
refSpec = refSpec.setForceUpdate(true); |
||||
refSpec = refSpec.setSourceDestination(Constants.R_HEADS + "*", //$NON-NLS-1$
|
||||
Constants.R_REMOTES + name + "/*"); //$NON-NLS-1$
|
||||
remote.addFetchRefSpec(refSpec); |
||||
|
||||
remote.addURI(uri); |
||||
|
||||
remote.update(config); |
||||
config.save(); |
||||
return remote; |
||||
} catch (IOException | URISyntaxException e) { |
||||
throw new JGitInternalException(e.getMessage(), e); |
||||
} |
||||
|
||||
} |
||||
|
||||
} |
@ -0,0 +1,91 @@
|
||||
/* |
||||
* Copyright (C) 2015, Kaloyan Raev <kaloyan.r@zend.com> |
||||
* and other copyright owners as documented in the project's IP log. |
||||
* |
||||
* This program and the accompanying materials are made available |
||||
* under the terms of the Eclipse Distribution License v1.0 which |
||||
* accompanies this distribution, is reproduced below, and is |
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
* |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or |
||||
* without modification, are permitted provided that the following |
||||
* conditions are met: |
||||
* |
||||
* - Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* |
||||
* - Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following |
||||
* disclaimer in the documentation and/or other materials provided |
||||
* with the distribution. |
||||
* |
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the |
||||
* names of its contributors may be used to endorse or promote |
||||
* products derived from this software without specific prior |
||||
* written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND |
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
*/ |
||||
package org.eclipse.jgit.api; |
||||
|
||||
import java.net.URISyntaxException; |
||||
import java.util.List; |
||||
|
||||
import org.eclipse.jgit.api.errors.GitAPIException; |
||||
import org.eclipse.jgit.api.errors.JGitInternalException; |
||||
import org.eclipse.jgit.lib.Repository; |
||||
import org.eclipse.jgit.transport.RemoteConfig; |
||||
|
||||
/** |
||||
* Used to obtain the list of remotes. |
||||
* |
||||
* This class has setters for all supported options and arguments of this |
||||
* command and a {@link #call()} method to finally execute the command. |
||||
* |
||||
* @see <a href= |
||||
* "http://www.kernel.org/pub/software/scm/git/docs/git-remote.html" > Git |
||||
* documentation about Remote</a> |
||||
* |
||||
* @since 4.2 |
||||
*/ |
||||
public class RemoteListCommand extends GitCommand<List<RemoteConfig>> { |
||||
|
||||
/** |
||||
* @param repo |
||||
*/ |
||||
protected RemoteListCommand(Repository repo) { |
||||
super(repo); |
||||
} |
||||
|
||||
/** |
||||
* Executes the {@code remote} command with all the options and parameters |
||||
* collected by the setter methods of this class. |
||||
* |
||||
* @return a list of {@link RemoteConfig} objects. |
||||
*/ |
||||
@Override |
||||
public List<RemoteConfig> call() throws GitAPIException { |
||||
checkCallable(); |
||||
|
||||
try { |
||||
return RemoteConfig.getAllRemoteConfigs(repo.getConfig()); |
||||
} catch (URISyntaxException e) { |
||||
throw new JGitInternalException(e.getMessage(), e); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,110 @@
|
||||
/* |
||||
* Copyright (C) 2015, Kaloyan Raev <kaloyan.r@zend.com> |
||||
* and other copyright owners as documented in the project's IP log. |
||||
* |
||||
* This program and the accompanying materials are made available |
||||
* under the terms of the Eclipse Distribution License v1.0 which |
||||
* accompanies this distribution, is reproduced below, and is |
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
* |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or |
||||
* without modification, are permitted provided that the following |
||||
* conditions are met: |
||||
* |
||||
* - Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* |
||||
* - Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following |
||||
* disclaimer in the documentation and/or other materials provided |
||||
* with the distribution. |
||||
* |
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the |
||||
* names of its contributors may be used to endorse or promote |
||||
* products derived from this software without specific prior |
||||
* written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND |
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
*/ |
||||
package org.eclipse.jgit.api; |
||||
|
||||
import java.io.IOException; |
||||
import java.net.URISyntaxException; |
||||
|
||||
import org.eclipse.jgit.api.errors.GitAPIException; |
||||
import org.eclipse.jgit.api.errors.JGitInternalException; |
||||
import org.eclipse.jgit.lib.ConfigConstants; |
||||
import org.eclipse.jgit.lib.Repository; |
||||
import org.eclipse.jgit.lib.StoredConfig; |
||||
import org.eclipse.jgit.transport.RemoteConfig; |
||||
|
||||
/** |
||||
* Used to remove an existing remote. |
||||
* |
||||
* This class has setters for all supported options and arguments of this |
||||
* command and a {@link #call()} method to finally execute the command. |
||||
* |
||||
* @see <a href= |
||||
* "http://www.kernel.org/pub/software/scm/git/docs/git-remote.html" > Git |
||||
* documentation about Remote</a> |
||||
* |
||||
* @since 4.2 |
||||
*/ |
||||
public class RemoteRemoveCommand extends GitCommand<RemoteConfig> { |
||||
|
||||
private String name; |
||||
|
||||
/** |
||||
* @param repo |
||||
*/ |
||||
protected RemoteRemoveCommand(Repository repo) { |
||||
super(repo); |
||||
} |
||||
|
||||
/** |
||||
* The name of the remote to remove. |
||||
* |
||||
* @param name |
||||
* a remote name |
||||
*/ |
||||
public void setName(String name) { |
||||
this.name = name; |
||||
} |
||||
|
||||
/** |
||||
* Executes the {@code remote} command with all the options and parameters |
||||
* collected by the setter methods of this class. |
||||
* |
||||
* @return the {@link RemoteConfig} object of the removed remote |
||||
*/ |
||||
@Override |
||||
public RemoteConfig call() throws GitAPIException { |
||||
checkCallable(); |
||||
|
||||
try { |
||||
StoredConfig config = repo.getConfig(); |
||||
RemoteConfig remote = new RemoteConfig(config, name); |
||||
config.unsetSection(ConfigConstants.CONFIG_KEY_REMOTE, name); |
||||
config.save(); |
||||
return remote; |
||||
} catch (IOException | URISyntaxException e) { |
||||
throw new JGitInternalException(e.getMessage(), e); |
||||
} |
||||
|
||||
} |
||||
|
||||
} |
@ -0,0 +1,155 @@
|
||||
/* |
||||
* Copyright (C) 2015, Kaloyan Raev <kaloyan.r@zend.com> |
||||
* and other copyright owners as documented in the project's IP log. |
||||
* |
||||
* This program and the accompanying materials are made available |
||||
* under the terms of the Eclipse Distribution License v1.0 which |
||||
* accompanies this distribution, is reproduced below, and is |
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
* |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or |
||||
* without modification, are permitted provided that the following |
||||
* conditions are met: |
||||
* |
||||
* - Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* |
||||
* - Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following |
||||
* disclaimer in the documentation and/or other materials provided |
||||
* with the distribution. |
||||
* |
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the |
||||
* names of its contributors may be used to endorse or promote |
||||
* products derived from this software without specific prior |
||||
* written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND |
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
*/ |
||||
package org.eclipse.jgit.api; |
||||
|
||||
import java.io.IOException; |
||||
import java.net.URISyntaxException; |
||||
import java.util.List; |
||||
|
||||
import org.eclipse.jgit.api.errors.GitAPIException; |
||||
import org.eclipse.jgit.api.errors.JGitInternalException; |
||||
import org.eclipse.jgit.lib.Repository; |
||||
import org.eclipse.jgit.lib.StoredConfig; |
||||
import org.eclipse.jgit.transport.RemoteConfig; |
||||
import org.eclipse.jgit.transport.URIish; |
||||
|
||||
/** |
||||
* Used to to change the URL of a remote. |
||||
* |
||||
* This class has setters for all supported options and arguments of this |
||||
* command and a {@link #call()} method to finally execute the command. |
||||
* |
||||
* @see <a href= |
||||
* "http://www.kernel.org/pub/software/scm/git/docs/git-remote.html" > Git |
||||
* documentation about Remote</a> |
||||
* |
||||
* @since 4.2 |
||||
*/ |
||||
public class RemoteSetUrlCommand extends GitCommand<RemoteConfig> { |
||||
|
||||
private String name; |
||||
|
||||
private URIish uri; |
||||
|
||||
private boolean push; |
||||
|
||||
/** |
||||
* @param repo |
||||
*/ |
||||
protected RemoteSetUrlCommand(Repository repo) { |
||||
super(repo); |
||||
} |
||||
|
||||
/** |
||||
* The name of the remote to change the URL for. |
||||
* |
||||
* @param name |
||||
* a remote name |
||||
*/ |
||||
public void setName(String name) { |
||||
this.name = name; |
||||
} |
||||
|
||||
/** |
||||
* The new URL for the remote. |
||||
* |
||||
* @param uri |
||||
* an URL for the remote |
||||
*/ |
||||
public void setUri(URIish uri) { |
||||
this.uri = uri; |
||||
} |
||||
|
||||
/** |
||||
* Whether to change the push URL of the remote instead of the fetch URL. |
||||
* |
||||
* @param push |
||||
* <code>true</code> to set the push url, <code>false</code> to |
||||
* set the fetch url |
||||
*/ |
||||
public void setPush(boolean push) { |
||||
this.push = push; |
||||
} |
||||
|
||||
/** |
||||
* Executes the {@code remote} command with all the options and parameters |
||||
* collected by the setter methods of this class. |
||||
* |
||||
* @return the {@link RemoteConfig} object of the modified remote |
||||
*/ |
||||
@Override |
||||
public RemoteConfig call() throws GitAPIException { |
||||
checkCallable(); |
||||
|
||||
try { |
||||
StoredConfig config = repo.getConfig(); |
||||
RemoteConfig remote = new RemoteConfig(config, name); |
||||
if (push) { |
||||
List<URIish> uris = remote.getPushURIs(); |
||||
if (uris.size() > 1) { |
||||
throw new JGitInternalException( |
||||
"remote.newtest.pushurl has multiple values"); //$NON-NLS-1$
|
||||
} else if (uris.size() == 1) { |
||||
remote.removePushURI(uris.get(0)); |
||||
} |
||||
remote.addPushURI(uri); |
||||
} else { |
||||
List<URIish> uris = remote.getURIs(); |
||||
if (uris.size() > 1) { |
||||
throw new JGitInternalException( |
||||
"remote.newtest.url has multiple values"); //$NON-NLS-1$
|
||||
} else if (uris.size() == 1) { |
||||
remote.removeURI(uris.get(0)); |
||||
} |
||||
remote.addURI(uri); |
||||
} |
||||
|
||||
remote.update(config); |
||||
config.save(); |
||||
return remote; |
||||
} catch (IOException | URISyntaxException e) { |
||||
throw new JGitInternalException(e.getMessage(), e); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,144 @@
|
||||
/* |
||||
* Copyright (C) 2015, Christian Halstrick <christian.halstrick@sap.com> and |
||||
* other copyright owners as documented in the project's IP log. |
||||
* |
||||
* This program and the accompanying materials are made available under the |
||||
* terms of the Eclipse Distribution License v1.0 which accompanies this |
||||
* distribution, is reproduced below, and is available at |
||||
* http://www.eclipse.org/org/documents/edl-v10.php
|
||||
* |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* - Redistributions of source code must retain the above copyright notice, this |
||||
* list of conditions and the following disclaimer. |
||||
* |
||||
* - Redistributions in binary form must reproduce the above copyright notice, |
||||
* this list of conditions and the following disclaimer in the documentation |
||||
* and/or other materials provided with the distribution. |
||||
* |
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the names of its |
||||
* contributors may be used to endorse or promote products derived from this |
||||
* software without specific prior written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
||||
* POSSIBILITY OF SUCH DAMAGE. |
||||
*/ |
||||
|
||||
package org.eclipse.jgit.api.errors; |
||||
|
||||
import java.text.MessageFormat; |
||||
|
||||
import org.eclipse.jgit.internal.JGitText; |
||||
|
||||
/** |
||||
* Exception thrown when the execution of a filter command failed |
||||
* |
||||
* @since 4.2 |
||||
*/ |
||||
public class FilterFailedException extends GitAPIException { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
private String filterCommand; |
||||
|
||||
private String path; |
||||
|
||||
private byte[] stdout; |
||||
|
||||
private String stderr; |
||||
|
||||
private int rc; |
||||
|
||||
/** |
||||
* Thrown if during execution of filter command an exception occurred |
||||
* |
||||
* @param cause |
||||
* the exception |
||||
* @param filterCommand |
||||
* the command which failed |
||||
* @param path |
||||
* the path processed by the filter |
||||
*/ |
||||
public FilterFailedException(Exception cause, String filterCommand, |
||||
String path) { |
||||
super(MessageFormat.format(JGitText.get().filterExecutionFailed, |
||||
filterCommand, path), cause); |
||||
this.filterCommand = filterCommand; |
||||
this.path = path; |
||||
} |
||||
|
||||
/** |
||||
* Thrown if a filter command returns a non-zero return code |
||||
* |
||||
* @param rc |
||||
* the return code |
||||
* @param filterCommand |
||||
* the command which failed |
||||
* @param path |
||||
* the path processed by the filter |
||||
* @param stdout |
||||
* the output the filter generated so far. This should be limited |
||||
* to reasonable size. |
||||
* @param stderr |
||||
* the stderr output of the filter |
||||
*/ |
||||
@SuppressWarnings("boxing") |
||||
public FilterFailedException(int rc, String filterCommand, String path, |
||||
byte[] stdout, String stderr) { |
||||
super(MessageFormat.format(JGitText.get().filterExecutionFailedRc, |
||||
filterCommand, path, rc, stderr)); |
||||
this.rc = rc; |
||||
this.filterCommand = filterCommand; |
||||
this.path = path; |
||||
this.stdout = stdout; |
||||
this.stderr = stderr; |
||||
} |
||||
|
||||
/** |
||||
* @return the filterCommand |
||||
*/ |
||||
public String getFilterCommand() { |
||||
return filterCommand; |
||||
} |
||||
|
||||
/** |
||||
* @return the path of the file processed by the filter command |
||||
*/ |
||||
public String getPath() { |
||||
return path; |
||||
} |
||||
|
||||
/** |
||||
* @return the output generated by the filter command. Might be truncated to |
||||
* limit memory consumption. |
||||
*/ |
||||
public byte[] getOutput() { |
||||
return stdout; |
||||
} |
||||
|
||||
/** |
||||
* @return the error output returned by the filter command |
||||
*/ |
||||
public String getError() { |
||||
return stderr; |
||||
} |
||||
|
||||
/** |
||||
* @return the return code returned by the filter command |
||||
*/ |
||||
public int getReturnCode() { |
||||
return rc; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,202 @@
|
||||
/* |
||||
* Copyright (C) 2015, Ivan Motsch <ivan.motsch@bsiag.com> |
||||
* |
||||
* This program and the accompanying materials are made available |
||||
* under the terms of the Eclipse Distribution License v1.0 which |
||||
* accompanies this distribution, is reproduced below, and is |
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
* |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or |
||||
* without modification, are permitted provided that the following |
||||
* conditions are met: |
||||
* |
||||
* - Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* |
||||
* - Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following |
||||
* disclaimer in the documentation and/or other materials provided |
||||
* with the distribution. |
||||
* |
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the |
||||
* names of its contributors may be used to endorse or promote |
||||
* products derived from this software without specific prior |
||||
* written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND |
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
*/ |
||||
|
||||
package org.eclipse.jgit.attributes; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.Collection; |
||||
import java.util.LinkedHashMap; |
||||
import java.util.Map; |
||||
|
||||
import org.eclipse.jgit.attributes.Attribute.State; |
||||
|
||||
/** |
||||
* Represents a set of attributes for a path |
||||
* <p> |
||||
* |
||||
* @since 4.2 |
||||
*/ |
||||
public final class Attributes { |
||||
private final Map<String, Attribute> map = new LinkedHashMap<>(); |
||||
|
||||
/** |
||||
* Creates a new instance |
||||
* |
||||
* @param attributes |
||||
*/ |
||||
public Attributes(Attribute... attributes) { |
||||
if (attributes != null) { |
||||
for (Attribute a : attributes) { |
||||
put(a); |
||||
} |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* @return true if the set does not contain any attributes |
||||
*/ |
||||
public boolean isEmpty() { |
||||
return map.isEmpty(); |
||||
} |
||||
|
||||
/** |
||||
* @param key |
||||
* @return the attribute or null |
||||
*/ |
||||
public Attribute get(String key) { |
||||
return map.get(key); |
||||
} |
||||
|
||||
/** |
||||
* @return all attributes |
||||
*/ |
||||
public Collection<Attribute> getAll() { |
||||
return new ArrayList<>(map.values()); |
||||
} |
||||
|
||||
/** |
||||
* @param a |
||||
*/ |
||||
public void put(Attribute a) { |
||||
map.put(a.getKey(), a); |
||||
} |
||||
|
||||
/** |
||||
* @param key |
||||
*/ |
||||
public void remove(String key) { |
||||
map.remove(key); |
||||
} |
||||
|
||||
/** |
||||
* @param key |
||||
* @return true if the {@link Attributes} contains this key |
||||
*/ |
||||
public boolean containsKey(String key) { |
||||
return map.containsKey(key); |
||||
} |
||||
|
||||
/** |
||||
* Returns the state. |
||||
* |
||||
* @param key |
||||
* |
||||
* @return the state (never returns <code>null</code>) |
||||
*/ |
||||
public Attribute.State getState(String key) { |
||||
Attribute a = map.get(key); |
||||
return a != null ? a.getState() : Attribute.State.UNSPECIFIED; |
||||
} |
||||
|
||||
/** |
||||
* @param key |
||||
* @return true if the key is {@link State#SET}, false in all other cases |
||||
*/ |
||||
public boolean isSet(String key) { |
||||
return (getState(key) == State.SET); |
||||
} |
||||
|
||||
/** |
||||
* @param key |
||||
* @return true if the key is {@link State#UNSET}, false in all other cases |
||||
*/ |
||||
public boolean isUnset(String key) { |
||||
return (getState(key) == State.UNSET); |
||||
} |
||||
|
||||
/** |
||||
* @param key |
||||
* @return true if the key is {@link State#UNSPECIFIED}, false in all other |
||||
* cases |
||||
*/ |
||||
public boolean isUnspecified(String key) { |
||||
return (getState(key) == State.UNSPECIFIED); |
||||
} |
||||
|
||||
/** |
||||
* @param key |
||||
* @return true if the key is {@link State#CUSTOM}, false in all other cases |
||||
* see {@link #getValue(String)} for the value of the key |
||||
*/ |
||||
public boolean isCustom(String key) { |
||||
return (getState(key) == State.CUSTOM); |
||||
} |
||||
|
||||
/** |
||||
* @param key |
||||
* @return the attribute value (may be <code>null</code>) |
||||
*/ |
||||
public String getValue(String key) { |
||||
Attribute a = map.get(key); |
||||
return a != null ? a.getValue() : null; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
StringBuilder buf = new StringBuilder(); |
||||
buf.append(getClass().getSimpleName()); |
||||
buf.append("["); //$NON-NLS-1$
|
||||
buf.append(" "); //$NON-NLS-1$
|
||||
for (Attribute a : map.values()) { |
||||
buf.append(a.toString()); |
||||
buf.append(" "); //$NON-NLS-1$
|
||||
} |
||||
buf.append("]"); //$NON-NLS-1$
|
||||
return buf.toString(); |
||||
} |
||||
|
||||
@Override |
||||
public int hashCode() { |
||||
return map.hashCode(); |
||||
} |
||||
|
||||
@Override |
||||
public boolean equals(Object obj) { |
||||
if (this == obj) |
||||
return true; |
||||
if (!(obj instanceof Attributes)) |
||||
return false; |
||||
Attributes other = (Attributes) obj; |
||||
return this.map.equals(other.map); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,81 @@
|
||||
/* |
||||
* Copyright (C) 2014, Arthur Daussy <arthur.daussy@obeo.fr> |
||||
* and other copyright owners as documented in the project's IP log. |
||||
* |
||||
* This program and the accompanying materials are made available |
||||
* under the terms of the Eclipse Distribution License v1.0 which |
||||
* accompanies this distribution, is reproduced below, and is |
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
* |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or |
||||
* without modification, are permitted provided that the following |
||||
* conditions are met: |
||||
* |
||||
* - Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* |
||||
* - Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following |
||||
* disclaimer in the documentation and/or other materials provided |
||||
* with the distribution. |
||||
* |
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the |
||||
* names of its contributors may be used to endorse or promote |
||||
* products derived from this software without specific prior |
||||
* written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND |
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
*/ |
||||
package org.eclipse.jgit.attributes; |
||||
|
||||
import java.io.IOException; |
||||
|
||||
import org.eclipse.jgit.lib.CoreConfig; |
||||
|
||||
/** |
||||
* An interface used to retrieve the global and info {@link AttributesNode}s. |
||||
* |
||||
* @since 4.2 |
||||
* |
||||
*/ |
||||
public interface AttributesNodeProvider { |
||||
|
||||
/** |
||||
* Retrieve the {@link AttributesNode} that holds the information located |
||||
* in $GIT_DIR/info/attributes file. |
||||
* |
||||
* @return the {@link AttributesNode} that holds the information located in |
||||
* $GIT_DIR/info/attributes file. |
||||
* @throws IOException |
||||
* if an error is raised while parsing the attributes file |
||||
*/ |
||||
public AttributesNode getInfoAttributesNode() throws IOException; |
||||
|
||||
/** |
||||
* Retrieve the {@link AttributesNode} that holds the information located |
||||
* in the global gitattributes file. |
||||
* |
||||
* @return the {@link AttributesNode} that holds the information located in |
||||
* the global gitattributes file. |
||||
* @throws IOException |
||||
* IOException if an error is raised while parsing the |
||||
* attributes file |
||||
* @see CoreConfig#getAttributesFile() |
||||
*/ |
||||
public AttributesNode getGlobalAttributesNode() throws IOException; |
||||
|
||||
} |
@ -0,0 +1,55 @@
|
||||
/* |
||||
* Copyright (C) 2015, Christian Halstrick <christian.halstrick@sap.com> |
||||
* and other copyright owners as documented in the project's IP log. |
||||
* |
||||
* This program and the accompanying materials are made available |
||||
* under the terms of the Eclipse Distribution License v1.0 which |
||||
* accompanies this distribution, is reproduced below, and is |
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
* |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or |
||||
* without modification, are permitted provided that the following |
||||
* conditions are met: |
||||
* |
||||
* - Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* |
||||
* - Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following |
||||
* disclaimer in the documentation and/or other materials provided |
||||
* with the distribution. |
||||
* |
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the |
||||
* names of its contributors may be used to endorse or promote |
||||
* products derived from this software without specific prior |
||||
* written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND |
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
*/ |
||||
package org.eclipse.jgit.attributes; |
||||
|
||||
/** |
||||
* Interface for classes which provide git attributes |
||||
* |
||||
* @since 4.2 |
||||
*/ |
||||
public interface AttributesProvider { |
||||
/** |
||||
* @return the currently active attributes |
||||
*/ |
||||
public Attributes getAttributes(); |
||||
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue