You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

RemoteConfigTest.java 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  1. /*
  2. * Copyright (C) 2008, Robin Rosenberg <robin.rosenberg@dewire.com>
  3. * Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
  4. * and other copyright owners as documented in the project's IP log.
  5. *
  6. * This program and the accompanying materials are made available
  7. * under the terms of the Eclipse Distribution License v1.0 which
  8. * accompanies this distribution, is reproduced below, and is
  9. * available at http://www.eclipse.org/org/documents/edl-v10.php
  10. *
  11. * All rights reserved.
  12. *
  13. * Redistribution and use in source and binary forms, with or
  14. * without modification, are permitted provided that the following
  15. * conditions are met:
  16. *
  17. * - Redistributions of source code must retain the above copyright
  18. * notice, this list of conditions and the following disclaimer.
  19. *
  20. * - Redistributions in binary form must reproduce the above
  21. * copyright notice, this list of conditions and the following
  22. * disclaimer in the documentation and/or other materials provided
  23. * with the distribution.
  24. *
  25. * - Neither the name of the Eclipse Foundation, Inc. nor the
  26. * names of its contributors may be used to endorse or promote
  27. * products derived from this software without specific prior
  28. * written permission.
  29. *
  30. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
  31. * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
  32. * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  33. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  34. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  35. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  36. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  37. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  38. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  39. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  40. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  41. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  42. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  43. */
  44. package org.eclipse.jgit.transport;
  45. import static org.junit.Assert.assertEquals;
  46. import static org.junit.Assert.assertFalse;
  47. import static org.junit.Assert.assertNotNull;
  48. import static org.junit.Assert.assertSame;
  49. import static org.junit.Assert.assertTrue;
  50. import java.util.Arrays;
  51. import java.util.Collections;
  52. import java.util.List;
  53. import org.eclipse.jgit.errors.ConfigInvalidException;
  54. import org.eclipse.jgit.lib.Config;
  55. import org.junit.Before;
  56. import org.junit.Test;
  57. public class RemoteConfigTest {
  58. private Config config;
  59. @Before
  60. public void setUp() throws Exception {
  61. config = new Config();
  62. }
  63. private void readConfig(String dat) throws ConfigInvalidException {
  64. config = new Config();
  65. config.fromText(dat);
  66. }
  67. private void checkConfig(String exp) {
  68. assertEquals(exp, config.toText());
  69. }
  70. @Test
  71. public void testSimple() throws Exception {
  72. readConfig("[remote \"spearce\"]\n"
  73. + "url = http://www.spearce.org/egit.git\n"
  74. + "fetch = +refs/heads/*:refs/remotes/spearce/*\n");
  75. final RemoteConfig rc = new RemoteConfig(config, "spearce");
  76. final List<URIish> allURIs = rc.getURIs();
  77. RefSpec spec;
  78. assertEquals("spearce", rc.getName());
  79. assertNotNull(allURIs);
  80. assertNotNull(rc.getFetchRefSpecs());
  81. assertNotNull(rc.getPushRefSpecs());
  82. assertNotNull(rc.getTagOpt());
  83. assertEquals(0, rc.getTimeout());
  84. assertSame(TagOpt.AUTO_FOLLOW, rc.getTagOpt());
  85. assertEquals(1, allURIs.size());
  86. assertEquals("http://www.spearce.org/egit.git", allURIs.get(0)
  87. .toString());
  88. assertEquals(1, rc.getFetchRefSpecs().size());
  89. spec = rc.getFetchRefSpecs().get(0);
  90. assertTrue(spec.isForceUpdate());
  91. assertTrue(spec.isWildcard());
  92. assertEquals("refs/heads/*", spec.getSource());
  93. assertEquals("refs/remotes/spearce/*", spec.getDestination());
  94. assertEquals(0, rc.getPushRefSpecs().size());
  95. }
  96. @Test
  97. public void testSimpleNoTags() throws Exception {
  98. readConfig("[remote \"spearce\"]\n"
  99. + "url = http://www.spearce.org/egit.git\n"
  100. + "fetch = +refs/heads/*:refs/remotes/spearce/*\n"
  101. + "tagopt = --no-tags\n");
  102. final RemoteConfig rc = new RemoteConfig(config, "spearce");
  103. assertSame(TagOpt.NO_TAGS, rc.getTagOpt());
  104. }
  105. @Test
  106. public void testSimpleAlwaysTags() throws Exception {
  107. readConfig("[remote \"spearce\"]\n"
  108. + "url = http://www.spearce.org/egit.git\n"
  109. + "fetch = +refs/heads/*:refs/remotes/spearce/*\n"
  110. + "tagopt = --tags\n");
  111. final RemoteConfig rc = new RemoteConfig(config, "spearce");
  112. assertSame(TagOpt.FETCH_TAGS, rc.getTagOpt());
  113. }
  114. @Test
  115. public void testMirror() throws Exception {
  116. readConfig("[remote \"spearce\"]\n"
  117. + "url = http://www.spearce.org/egit.git\n"
  118. + "fetch = +refs/heads/*:refs/heads/*\n"
  119. + "fetch = refs/tags/*:refs/tags/*\n");
  120. final RemoteConfig rc = new RemoteConfig(config, "spearce");
  121. final List<URIish> allURIs = rc.getURIs();
  122. RefSpec spec;
  123. assertEquals("spearce", rc.getName());
  124. assertNotNull(allURIs);
  125. assertNotNull(rc.getFetchRefSpecs());
  126. assertNotNull(rc.getPushRefSpecs());
  127. assertEquals(1, allURIs.size());
  128. assertEquals("http://www.spearce.org/egit.git", allURIs.get(0)
  129. .toString());
  130. assertEquals(2, rc.getFetchRefSpecs().size());
  131. spec = rc.getFetchRefSpecs().get(0);
  132. assertTrue(spec.isForceUpdate());
  133. assertTrue(spec.isWildcard());
  134. assertEquals("refs/heads/*", spec.getSource());
  135. assertEquals("refs/heads/*", spec.getDestination());
  136. spec = rc.getFetchRefSpecs().get(1);
  137. assertFalse(spec.isForceUpdate());
  138. assertTrue(spec.isWildcard());
  139. assertEquals("refs/tags/*", spec.getSource());
  140. assertEquals("refs/tags/*", spec.getDestination());
  141. assertEquals(0, rc.getPushRefSpecs().size());
  142. }
  143. @Test
  144. public void testBackup() throws Exception {
  145. readConfig("[remote \"backup\"]\n"
  146. + "url = http://www.spearce.org/egit.git\n"
  147. + "url = user@repo.or.cz:/srv/git/egit.git\n"
  148. + "push = +refs/heads/*:refs/heads/*\n"
  149. + "push = refs/tags/*:refs/tags/*\n");
  150. final RemoteConfig rc = new RemoteConfig(config, "backup");
  151. final List<URIish> allURIs = rc.getURIs();
  152. RefSpec spec;
  153. assertEquals("backup", rc.getName());
  154. assertNotNull(allURIs);
  155. assertNotNull(rc.getFetchRefSpecs());
  156. assertNotNull(rc.getPushRefSpecs());
  157. assertEquals(2, allURIs.size());
  158. assertEquals("http://www.spearce.org/egit.git", allURIs.get(0)
  159. .toString());
  160. assertEquals("user@repo.or.cz:/srv/git/egit.git", allURIs.get(1)
  161. .toString());
  162. assertEquals(0, rc.getFetchRefSpecs().size());
  163. assertEquals(2, rc.getPushRefSpecs().size());
  164. spec = rc.getPushRefSpecs().get(0);
  165. assertTrue(spec.isForceUpdate());
  166. assertTrue(spec.isWildcard());
  167. assertEquals("refs/heads/*", spec.getSource());
  168. assertEquals("refs/heads/*", spec.getDestination());
  169. spec = rc.getPushRefSpecs().get(1);
  170. assertFalse(spec.isForceUpdate());
  171. assertTrue(spec.isWildcard());
  172. assertEquals("refs/tags/*", spec.getSource());
  173. assertEquals("refs/tags/*", spec.getDestination());
  174. }
  175. @Test
  176. public void testUploadPack() throws Exception {
  177. readConfig("[remote \"example\"]\n"
  178. + "url = user@example.com:egit.git\n"
  179. + "fetch = +refs/heads/*:refs/remotes/example/*\n"
  180. + "uploadpack = /path/to/git/git-upload-pack\n"
  181. + "receivepack = /path/to/git/git-receive-pack\n");
  182. final RemoteConfig rc = new RemoteConfig(config, "example");
  183. final List<URIish> allURIs = rc.getURIs();
  184. RefSpec spec;
  185. assertEquals("example", rc.getName());
  186. assertNotNull(allURIs);
  187. assertNotNull(rc.getFetchRefSpecs());
  188. assertNotNull(rc.getPushRefSpecs());
  189. assertEquals(1, allURIs.size());
  190. assertEquals("user@example.com:egit.git", allURIs.get(0).toString());
  191. assertEquals(1, rc.getFetchRefSpecs().size());
  192. spec = rc.getFetchRefSpecs().get(0);
  193. assertTrue(spec.isForceUpdate());
  194. assertTrue(spec.isWildcard());
  195. assertEquals("refs/heads/*", spec.getSource());
  196. assertEquals("refs/remotes/example/*", spec.getDestination());
  197. assertEquals(0, rc.getPushRefSpecs().size());
  198. assertEquals("/path/to/git/git-upload-pack", rc.getUploadPack());
  199. assertEquals("/path/to/git/git-receive-pack", rc.getReceivePack());
  200. }
  201. @Test
  202. public void testUnknown() throws Exception {
  203. readConfig("");
  204. final RemoteConfig rc = new RemoteConfig(config, "backup");
  205. assertEquals(0, rc.getURIs().size());
  206. assertEquals(0, rc.getFetchRefSpecs().size());
  207. assertEquals(0, rc.getPushRefSpecs().size());
  208. assertEquals("git-upload-pack", rc.getUploadPack());
  209. assertEquals("git-receive-pack", rc.getReceivePack());
  210. }
  211. @Test
  212. public void testAddURI() throws Exception {
  213. readConfig("");
  214. final URIish uri = new URIish("/some/dir");
  215. final RemoteConfig rc = new RemoteConfig(config, "backup");
  216. assertEquals(0, rc.getURIs().size());
  217. assertTrue(rc.addURI(uri));
  218. assertEquals(1, rc.getURIs().size());
  219. assertSame(uri, rc.getURIs().get(0));
  220. assertFalse(rc.addURI(new URIish(uri.toString())));
  221. assertEquals(1, rc.getURIs().size());
  222. }
  223. @Test
  224. public void testRemoveFirstURI() throws Exception {
  225. readConfig("");
  226. final URIish a = new URIish("/some/dir");
  227. final URIish b = new URIish("/another/dir");
  228. final URIish c = new URIish("/more/dirs");
  229. final RemoteConfig rc = new RemoteConfig(config, "backup");
  230. assertTrue(rc.addURI(a));
  231. assertTrue(rc.addURI(b));
  232. assertTrue(rc.addURI(c));
  233. assertEquals(3, rc.getURIs().size());
  234. assertSame(a, rc.getURIs().get(0));
  235. assertSame(b, rc.getURIs().get(1));
  236. assertSame(c, rc.getURIs().get(2));
  237. assertTrue(rc.removeURI(a));
  238. assertEquals(2, rc.getURIs().size());
  239. assertSame(b, rc.getURIs().get(0));
  240. assertSame(c, rc.getURIs().get(1));
  241. }
  242. @Test
  243. public void testRemoveMiddleURI() throws Exception {
  244. readConfig("");
  245. final URIish a = new URIish("/some/dir");
  246. final URIish b = new URIish("/another/dir");
  247. final URIish c = new URIish("/more/dirs");
  248. final RemoteConfig rc = new RemoteConfig(config, "backup");
  249. assertTrue(rc.addURI(a));
  250. assertTrue(rc.addURI(b));
  251. assertTrue(rc.addURI(c));
  252. assertEquals(3, rc.getURIs().size());
  253. assertSame(a, rc.getURIs().get(0));
  254. assertSame(b, rc.getURIs().get(1));
  255. assertSame(c, rc.getURIs().get(2));
  256. assertTrue(rc.removeURI(b));
  257. assertEquals(2, rc.getURIs().size());
  258. assertSame(a, rc.getURIs().get(0));
  259. assertSame(c, rc.getURIs().get(1));
  260. }
  261. @Test
  262. public void testRemoveLastURI() throws Exception {
  263. readConfig("");
  264. final URIish a = new URIish("/some/dir");
  265. final URIish b = new URIish("/another/dir");
  266. final URIish c = new URIish("/more/dirs");
  267. final RemoteConfig rc = new RemoteConfig(config, "backup");
  268. assertTrue(rc.addURI(a));
  269. assertTrue(rc.addURI(b));
  270. assertTrue(rc.addURI(c));
  271. assertEquals(3, rc.getURIs().size());
  272. assertSame(a, rc.getURIs().get(0));
  273. assertSame(b, rc.getURIs().get(1));
  274. assertSame(c, rc.getURIs().get(2));
  275. assertTrue(rc.removeURI(c));
  276. assertEquals(2, rc.getURIs().size());
  277. assertSame(a, rc.getURIs().get(0));
  278. assertSame(b, rc.getURIs().get(1));
  279. }
  280. @Test
  281. public void testRemoveOnlyURI() throws Exception {
  282. readConfig("");
  283. final URIish a = new URIish("/some/dir");
  284. final RemoteConfig rc = new RemoteConfig(config, "backup");
  285. assertTrue(rc.addURI(a));
  286. assertEquals(1, rc.getURIs().size());
  287. assertSame(a, rc.getURIs().get(0));
  288. assertTrue(rc.removeURI(a));
  289. assertEquals(0, rc.getURIs().size());
  290. }
  291. @Test
  292. public void testCreateOrigin() throws Exception {
  293. final RemoteConfig rc = new RemoteConfig(config, "origin");
  294. rc.addURI(new URIish("/some/dir"));
  295. rc.addFetchRefSpec(new RefSpec("+refs/heads/*:refs/remotes/"
  296. + rc.getName() + "/*"));
  297. rc.update(config);
  298. checkConfig("[remote \"origin\"]\n" + "\turl = /some/dir\n"
  299. + "\tfetch = +refs/heads/*:refs/remotes/origin/*\n");
  300. }
  301. @Test
  302. public void testSaveAddURI() throws Exception {
  303. readConfig("[remote \"spearce\"]\n"
  304. + "url = http://www.spearce.org/egit.git\n"
  305. + "fetch = +refs/heads/*:refs/remotes/spearce/*\n");
  306. final RemoteConfig rc = new RemoteConfig(config, "spearce");
  307. rc.addURI(new URIish("/some/dir"));
  308. assertEquals(2, rc.getURIs().size());
  309. rc.update(config);
  310. checkConfig("[remote \"spearce\"]\n"
  311. + "\turl = http://www.spearce.org/egit.git\n"
  312. + "\turl = /some/dir\n"
  313. + "\tfetch = +refs/heads/*:refs/remotes/spearce/*\n");
  314. }
  315. @Test
  316. public void testSaveRemoveLastURI() throws Exception {
  317. readConfig("[remote \"spearce\"]\n"
  318. + "url = http://www.spearce.org/egit.git\n"
  319. + "url = /some/dir\n"
  320. + "fetch = +refs/heads/*:refs/remotes/spearce/*\n");
  321. final RemoteConfig rc = new RemoteConfig(config, "spearce");
  322. assertEquals(2, rc.getURIs().size());
  323. rc.removeURI(new URIish("/some/dir"));
  324. assertEquals(1, rc.getURIs().size());
  325. rc.update(config);
  326. checkConfig("[remote \"spearce\"]\n"
  327. + "\turl = http://www.spearce.org/egit.git\n"
  328. + "\tfetch = +refs/heads/*:refs/remotes/spearce/*\n");
  329. }
  330. @Test
  331. public void testSaveRemoveFirstURI() throws Exception {
  332. readConfig("[remote \"spearce\"]\n"
  333. + "url = http://www.spearce.org/egit.git\n"
  334. + "url = /some/dir\n"
  335. + "fetch = +refs/heads/*:refs/remotes/spearce/*\n");
  336. final RemoteConfig rc = new RemoteConfig(config, "spearce");
  337. assertEquals(2, rc.getURIs().size());
  338. rc.removeURI(new URIish("http://www.spearce.org/egit.git"));
  339. assertEquals(1, rc.getURIs().size());
  340. rc.update(config);
  341. checkConfig("[remote \"spearce\"]\n" + "\turl = /some/dir\n"
  342. + "\tfetch = +refs/heads/*:refs/remotes/spearce/*\n");
  343. }
  344. @Test
  345. public void testSaveNoTags() throws Exception {
  346. final RemoteConfig rc = new RemoteConfig(config, "origin");
  347. rc.addURI(new URIish("/some/dir"));
  348. rc.addFetchRefSpec(new RefSpec("+refs/heads/*:refs/remotes/"
  349. + rc.getName() + "/*"));
  350. rc.setTagOpt(TagOpt.NO_TAGS);
  351. rc.update(config);
  352. checkConfig("[remote \"origin\"]\n" + "\turl = /some/dir\n"
  353. + "\tfetch = +refs/heads/*:refs/remotes/origin/*\n"
  354. + "\ttagopt = --no-tags\n");
  355. }
  356. @Test
  357. public void testSaveAllTags() throws Exception {
  358. final RemoteConfig rc = new RemoteConfig(config, "origin");
  359. rc.addURI(new URIish("/some/dir"));
  360. rc.addFetchRefSpec(new RefSpec("+refs/heads/*:refs/remotes/"
  361. + rc.getName() + "/*"));
  362. rc.setTagOpt(TagOpt.FETCH_TAGS);
  363. rc.update(config);
  364. checkConfig("[remote \"origin\"]\n" + "\turl = /some/dir\n"
  365. + "\tfetch = +refs/heads/*:refs/remotes/origin/*\n"
  366. + "\ttagopt = --tags\n");
  367. }
  368. @Test
  369. public void testSimpleTimeout() throws Exception {
  370. readConfig("[remote \"spearce\"]\n"
  371. + "url = http://www.spearce.org/egit.git\n"
  372. + "fetch = +refs/heads/*:refs/remotes/spearce/*\n"
  373. + "timeout = 12\n");
  374. final RemoteConfig rc = new RemoteConfig(config, "spearce");
  375. assertEquals(12, rc.getTimeout());
  376. }
  377. @Test
  378. public void testSaveTimeout() throws Exception {
  379. final RemoteConfig rc = new RemoteConfig(config, "origin");
  380. rc.addURI(new URIish("/some/dir"));
  381. rc.addFetchRefSpec(new RefSpec("+refs/heads/*:refs/remotes/"
  382. + rc.getName() + "/*"));
  383. rc.setTimeout(60);
  384. rc.update(config);
  385. checkConfig("[remote \"origin\"]\n" + "\turl = /some/dir\n"
  386. + "\tfetch = +refs/heads/*:refs/remotes/origin/*\n"
  387. + "\ttimeout = 60\n");
  388. }
  389. @Test
  390. public void noInsteadOf() throws Exception {
  391. config.setString("remote", "origin", "url", "short:project.git");
  392. config.setString("url", "https://server/repos/", "name", "short:");
  393. RemoteConfig rc = new RemoteConfig(config, "origin");
  394. assertFalse(rc.getURIs().isEmpty());
  395. assertEquals("short:project.git", rc.getURIs().get(0).toASCIIString());
  396. }
  397. @Test
  398. public void singleInsteadOf() throws Exception {
  399. config.setString("remote", "origin", "url", "short:project.git");
  400. config.setString("url", "https://server/repos/", "insteadOf", "short:");
  401. RemoteConfig rc = new RemoteConfig(config, "origin");
  402. assertFalse(rc.getURIs().isEmpty());
  403. assertEquals("https://server/repos/project.git", rc.getURIs().get(0)
  404. .toASCIIString());
  405. }
  406. @Test
  407. public void multipleInsteadOf() throws Exception {
  408. config.setString("remote", "origin", "url", "prefixproject.git");
  409. config.setStringList("url", "https://server/repos/", "insteadOf",
  410. Arrays.asList("pre", "prefix", "pref", "perf"));
  411. RemoteConfig rc = new RemoteConfig(config, "origin");
  412. assertFalse(rc.getURIs().isEmpty());
  413. assertEquals("https://server/repos/project.git", rc.getURIs().get(0)
  414. .toASCIIString());
  415. }
  416. @Test
  417. public void noPushInsteadOf() throws Exception {
  418. config.setString("remote", "origin", "pushurl", "short:project.git");
  419. config.setString("url", "https://server/repos/", "name", "short:");
  420. RemoteConfig rc = new RemoteConfig(config, "origin");
  421. assertFalse(rc.getPushURIs().isEmpty());
  422. assertEquals("short:project.git", rc.getPushURIs().get(0)
  423. .toASCIIString());
  424. }
  425. @Test
  426. public void pushInsteadOfNotAppliedToPushUri() throws Exception {
  427. config.setString("remote", "origin", "pushurl", "short:project.git");
  428. config.setString("url", "https://server/repos/", "pushInsteadOf",
  429. "short:");
  430. RemoteConfig rc = new RemoteConfig(config, "origin");
  431. assertFalse(rc.getPushURIs().isEmpty());
  432. assertEquals("short:project.git",
  433. rc.getPushURIs().get(0).toASCIIString());
  434. }
  435. @Test
  436. public void pushInsteadOfAppliedToUri() throws Exception {
  437. config.setString("remote", "origin", "url", "short:project.git");
  438. config.setString("url", "https://server/repos/", "pushInsteadOf",
  439. "short:");
  440. RemoteConfig rc = new RemoteConfig(config, "origin");
  441. assertFalse(rc.getPushURIs().isEmpty());
  442. assertEquals("https://server/repos/project.git",
  443. rc.getPushURIs().get(0).toASCIIString());
  444. }
  445. @Test
  446. public void multiplePushInsteadOf() throws Exception {
  447. config.setString("remote", "origin", "url", "prefixproject.git");
  448. config.setStringList("url", "https://server/repos/", "pushInsteadOf",
  449. Arrays.asList("pre", "prefix", "pref", "perf"));
  450. RemoteConfig rc = new RemoteConfig(config, "origin");
  451. assertFalse(rc.getPushURIs().isEmpty());
  452. assertEquals("https://server/repos/project.git", rc.getPushURIs()
  453. .get(0).toASCIIString());
  454. }
  455. @Test
  456. public void pushInsteadOfNoPushUrl() throws Exception {
  457. config.setString("remote", "origin", "url",
  458. "http://git.eclipse.org/gitroot/jgit/jgit");
  459. config.setStringList("url", "ssh://someone@git.eclipse.org:29418/",
  460. "pushInsteadOf",
  461. Collections.singletonList("http://git.eclipse.org/gitroot/"));
  462. RemoteConfig rc = new RemoteConfig(config, "origin");
  463. assertFalse(rc.getPushURIs().isEmpty());
  464. assertEquals("ssh://someone@git.eclipse.org:29418/jgit/jgit",
  465. rc.getPushURIs().get(0).toASCIIString());
  466. }
  467. }