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.

CommitCommandTest.java 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  1. /*
  2. * Copyright (C) 2011-2012, GitHub Inc.
  3. * and other copyright owners as documented in the project's IP log.
  4. *
  5. * This program and the accompanying materials are made available
  6. * under the terms of the Eclipse Distribution License v1.0 which
  7. * accompanies this distribution, is reproduced below, and is
  8. * available at http://www.eclipse.org/org/documents/edl-v10.php
  9. *
  10. * All rights reserved.
  11. *
  12. * Redistribution and use in source and binary forms, with or
  13. * without modification, are permitted provided that the following
  14. * conditions are met:
  15. *
  16. * - Redistributions of source code must retain the above copyright
  17. * notice, this list of conditions and the following disclaimer.
  18. *
  19. * - Redistributions in binary form must reproduce the above
  20. * copyright notice, this list of conditions and the following
  21. * disclaimer in the documentation and/or other materials provided
  22. * with the distribution.
  23. *
  24. * - Neither the name of the Eclipse Foundation, Inc. nor the
  25. * names of its contributors may be used to endorse or promote
  26. * products derived from this software without specific prior
  27. * written permission.
  28. *
  29. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
  30. * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
  31. * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  32. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  33. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  34. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  35. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  36. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  37. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  38. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  39. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  40. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  41. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  42. */
  43. package org.eclipse.jgit.api;
  44. import static org.junit.Assert.assertEquals;
  45. import static org.junit.Assert.assertNotNull;
  46. import static org.junit.Assert.assertNull;
  47. import static org.junit.Assert.assertTrue;
  48. import java.io.File;
  49. import java.util.Date;
  50. import java.util.List;
  51. import java.util.TimeZone;
  52. import org.eclipse.jgit.api.errors.WrongRepositoryStateException;
  53. import org.eclipse.jgit.diff.DiffEntry;
  54. import org.eclipse.jgit.dircache.DirCache;
  55. import org.eclipse.jgit.dircache.DirCacheBuilder;
  56. import org.eclipse.jgit.dircache.DirCacheEntry;
  57. import org.eclipse.jgit.junit.RepositoryTestCase;
  58. import org.eclipse.jgit.lib.ConfigConstants;
  59. import org.eclipse.jgit.lib.Constants;
  60. import org.eclipse.jgit.lib.FileMode;
  61. import org.eclipse.jgit.lib.ObjectId;
  62. import org.eclipse.jgit.lib.PersonIdent;
  63. import org.eclipse.jgit.lib.RefUpdate;
  64. import org.eclipse.jgit.lib.RefUpdate.Result;
  65. import org.eclipse.jgit.lib.Repository;
  66. import org.eclipse.jgit.lib.StoredConfig;
  67. import org.eclipse.jgit.revwalk.RevCommit;
  68. import org.eclipse.jgit.submodule.SubmoduleWalk;
  69. import org.eclipse.jgit.treewalk.TreeWalk;
  70. import org.eclipse.jgit.treewalk.filter.TreeFilter;
  71. import org.eclipse.jgit.util.FS;
  72. import org.junit.Test;
  73. /**
  74. * Unit tests of {@link CommitCommand}.
  75. */
  76. public class CommitCommandTest extends RepositoryTestCase {
  77. @Test
  78. public void testExecutableRetention() throws Exception {
  79. StoredConfig config = db.getConfig();
  80. config.setBoolean(ConfigConstants.CONFIG_CORE_SECTION, null,
  81. ConfigConstants.CONFIG_KEY_FILEMODE, true);
  82. config.save();
  83. FS executableFs = new FS() {
  84. public boolean supportsExecute() {
  85. return true;
  86. }
  87. public boolean setExecute(File f, boolean canExec) {
  88. return true;
  89. }
  90. public ProcessBuilder runInShell(String cmd, String[] args) {
  91. return null;
  92. }
  93. public boolean retryFailedLockFileCommit() {
  94. return false;
  95. }
  96. public FS newInstance() {
  97. return this;
  98. }
  99. protected File discoverGitExe() {
  100. return null;
  101. }
  102. public boolean canExecute(File f) {
  103. return true;
  104. }
  105. @Override
  106. public boolean isCaseSensitive() {
  107. return true;
  108. }
  109. };
  110. Git git = Git.open(db.getDirectory(), executableFs);
  111. String path = "a.txt";
  112. writeTrashFile(path, "content");
  113. git.add().addFilepattern(path).call();
  114. RevCommit commit1 = git.commit().setMessage("commit").call();
  115. TreeWalk walk = TreeWalk.forPath(db, path, commit1.getTree());
  116. assertNotNull(walk);
  117. assertEquals(FileMode.EXECUTABLE_FILE, walk.getFileMode(0));
  118. FS nonExecutableFs = new FS() {
  119. public boolean supportsExecute() {
  120. return false;
  121. }
  122. public boolean setExecute(File f, boolean canExec) {
  123. return false;
  124. }
  125. public ProcessBuilder runInShell(String cmd, String[] args) {
  126. return null;
  127. }
  128. public boolean retryFailedLockFileCommit() {
  129. return false;
  130. }
  131. public FS newInstance() {
  132. return this;
  133. }
  134. protected File discoverGitExe() {
  135. return null;
  136. }
  137. public boolean canExecute(File f) {
  138. return false;
  139. }
  140. @Override
  141. public boolean isCaseSensitive() {
  142. return true;
  143. }
  144. };
  145. config = db.getConfig();
  146. config.setBoolean(ConfigConstants.CONFIG_CORE_SECTION, null,
  147. ConfigConstants.CONFIG_KEY_FILEMODE, false);
  148. config.save();
  149. Git git2 = Git.open(db.getDirectory(), nonExecutableFs);
  150. writeTrashFile(path, "content2");
  151. RevCommit commit2 = git2.commit().setOnly(path).setMessage("commit2")
  152. .call();
  153. walk = TreeWalk.forPath(db, path, commit2.getTree());
  154. assertNotNull(walk);
  155. assertEquals(FileMode.EXECUTABLE_FILE, walk.getFileMode(0));
  156. }
  157. @Test
  158. public void commitNewSubmodule() throws Exception {
  159. Git git = new Git(db);
  160. writeTrashFile("file.txt", "content");
  161. git.add().addFilepattern("file.txt").call();
  162. RevCommit commit = git.commit().setMessage("create file").call();
  163. SubmoduleAddCommand command = new SubmoduleAddCommand(db);
  164. String path = "sub";
  165. command.setPath(path);
  166. String uri = db.getDirectory().toURI().toString();
  167. command.setURI(uri);
  168. Repository repo = command.call();
  169. assertNotNull(repo);
  170. addRepoToClose(repo);
  171. SubmoduleWalk generator = SubmoduleWalk.forIndex(db);
  172. assertTrue(generator.next());
  173. assertEquals(path, generator.getPath());
  174. assertEquals(commit, generator.getObjectId());
  175. assertEquals(uri, generator.getModulesUrl());
  176. assertEquals(path, generator.getModulesPath());
  177. assertEquals(uri, generator.getConfigUrl());
  178. Repository subModRepo = generator.getRepository();
  179. assertNotNull(subModRepo);
  180. subModRepo.close();
  181. assertEquals(commit, repo.resolve(Constants.HEAD));
  182. RevCommit submoduleCommit = git.commit().setMessage("submodule add")
  183. .setOnly(path).call();
  184. assertNotNull(submoduleCommit);
  185. TreeWalk walk = new TreeWalk(db);
  186. walk.addTree(commit.getTree());
  187. walk.addTree(submoduleCommit.getTree());
  188. walk.setFilter(TreeFilter.ANY_DIFF);
  189. List<DiffEntry> diffs = DiffEntry.scan(walk);
  190. assertEquals(1, diffs.size());
  191. DiffEntry subDiff = diffs.get(0);
  192. assertEquals(FileMode.MISSING, subDiff.getOldMode());
  193. assertEquals(FileMode.GITLINK, subDiff.getNewMode());
  194. assertEquals(ObjectId.zeroId(), subDiff.getOldId().toObjectId());
  195. assertEquals(commit, subDiff.getNewId().toObjectId());
  196. assertEquals(path, subDiff.getNewPath());
  197. }
  198. @Test
  199. public void commitSubmoduleUpdate() throws Exception {
  200. Git git = new Git(db);
  201. writeTrashFile("file.txt", "content");
  202. git.add().addFilepattern("file.txt").call();
  203. RevCommit commit = git.commit().setMessage("create file").call();
  204. writeTrashFile("file.txt", "content2");
  205. git.add().addFilepattern("file.txt").call();
  206. RevCommit commit2 = git.commit().setMessage("edit file").call();
  207. SubmoduleAddCommand command = new SubmoduleAddCommand(db);
  208. String path = "sub";
  209. command.setPath(path);
  210. String uri = db.getDirectory().toURI().toString();
  211. command.setURI(uri);
  212. Repository repo = command.call();
  213. assertNotNull(repo);
  214. addRepoToClose(repo);
  215. SubmoduleWalk generator = SubmoduleWalk.forIndex(db);
  216. assertTrue(generator.next());
  217. assertEquals(path, generator.getPath());
  218. assertEquals(commit2, generator.getObjectId());
  219. assertEquals(uri, generator.getModulesUrl());
  220. assertEquals(path, generator.getModulesPath());
  221. assertEquals(uri, generator.getConfigUrl());
  222. Repository subModRepo = generator.getRepository();
  223. assertNotNull(subModRepo);
  224. subModRepo.close();
  225. assertEquals(commit2, repo.resolve(Constants.HEAD));
  226. RevCommit submoduleAddCommit = git.commit().setMessage("submodule add")
  227. .setOnly(path).call();
  228. assertNotNull(submoduleAddCommit);
  229. RefUpdate update = repo.updateRef(Constants.HEAD);
  230. update.setNewObjectId(commit);
  231. assertEquals(Result.FORCED, update.forceUpdate());
  232. RevCommit submoduleEditCommit = git.commit()
  233. .setMessage("submodule add").setOnly(path).call();
  234. assertNotNull(submoduleEditCommit);
  235. TreeWalk walk = new TreeWalk(db);
  236. walk.addTree(submoduleAddCommit.getTree());
  237. walk.addTree(submoduleEditCommit.getTree());
  238. walk.setFilter(TreeFilter.ANY_DIFF);
  239. List<DiffEntry> diffs = DiffEntry.scan(walk);
  240. assertEquals(1, diffs.size());
  241. DiffEntry subDiff = diffs.get(0);
  242. assertEquals(FileMode.GITLINK, subDiff.getOldMode());
  243. assertEquals(FileMode.GITLINK, subDiff.getNewMode());
  244. assertEquals(commit2, subDiff.getOldId().toObjectId());
  245. assertEquals(commit, subDiff.getNewId().toObjectId());
  246. assertEquals(path, subDiff.getNewPath());
  247. assertEquals(path, subDiff.getOldPath());
  248. }
  249. @Test
  250. public void commitUpdatesSmudgedEntries() throws Exception {
  251. Git git = new Git(db);
  252. File file1 = writeTrashFile("file1.txt", "content1");
  253. assertTrue(file1.setLastModified(file1.lastModified() - 5000));
  254. File file2 = writeTrashFile("file2.txt", "content2");
  255. assertTrue(file2.setLastModified(file2.lastModified() - 5000));
  256. File file3 = writeTrashFile("file3.txt", "content3");
  257. assertTrue(file3.setLastModified(file3.lastModified() - 5000));
  258. assertNotNull(git.add().addFilepattern("file1.txt")
  259. .addFilepattern("file2.txt").addFilepattern("file3.txt").call());
  260. RevCommit commit = git.commit().setMessage("add files").call();
  261. assertNotNull(commit);
  262. DirCache cache = DirCache.read(db.getIndexFile(), db.getFS());
  263. int file1Size = cache.getEntry("file1.txt").getLength();
  264. int file2Size = cache.getEntry("file2.txt").getLength();
  265. int file3Size = cache.getEntry("file3.txt").getLength();
  266. ObjectId file2Id = cache.getEntry("file2.txt").getObjectId();
  267. ObjectId file3Id = cache.getEntry("file3.txt").getObjectId();
  268. assertTrue(file1Size > 0);
  269. assertTrue(file2Size > 0);
  270. assertTrue(file3Size > 0);
  271. // Smudge entries
  272. cache = DirCache.lock(db.getIndexFile(), db.getFS());
  273. cache.getEntry("file1.txt").setLength(0);
  274. cache.getEntry("file2.txt").setLength(0);
  275. cache.getEntry("file3.txt").setLength(0);
  276. cache.write();
  277. assertTrue(cache.commit());
  278. // Verify entries smudged
  279. cache = DirCache.read(db.getIndexFile(), db.getFS());
  280. assertEquals(0, cache.getEntry("file1.txt").getLength());
  281. assertEquals(0, cache.getEntry("file2.txt").getLength());
  282. assertEquals(0, cache.getEntry("file3.txt").getLength());
  283. long indexTime = db.getIndexFile().lastModified();
  284. db.getIndexFile().setLastModified(indexTime - 5000);
  285. write(file1, "content4");
  286. assertTrue(file1.setLastModified(file1.lastModified() + 2500));
  287. assertNotNull(git.commit().setMessage("edit file").setOnly("file1.txt")
  288. .call());
  289. cache = db.readDirCache();
  290. assertEquals(file1Size, cache.getEntry("file1.txt").getLength());
  291. assertEquals(file2Size, cache.getEntry("file2.txt").getLength());
  292. assertEquals(file3Size, cache.getEntry("file3.txt").getLength());
  293. assertEquals(file2Id, cache.getEntry("file2.txt").getObjectId());
  294. assertEquals(file3Id, cache.getEntry("file3.txt").getObjectId());
  295. }
  296. @Test
  297. public void commitIgnoresSmudgedEntryWithDifferentId() throws Exception {
  298. Git git = new Git(db);
  299. File file1 = writeTrashFile("file1.txt", "content1");
  300. assertTrue(file1.setLastModified(file1.lastModified() - 5000));
  301. File file2 = writeTrashFile("file2.txt", "content2");
  302. assertTrue(file2.setLastModified(file2.lastModified() - 5000));
  303. assertNotNull(git.add().addFilepattern("file1.txt")
  304. .addFilepattern("file2.txt").call());
  305. RevCommit commit = git.commit().setMessage("add files").call();
  306. assertNotNull(commit);
  307. DirCache cache = DirCache.read(db.getIndexFile(), db.getFS());
  308. int file1Size = cache.getEntry("file1.txt").getLength();
  309. int file2Size = cache.getEntry("file2.txt").getLength();
  310. assertTrue(file1Size > 0);
  311. assertTrue(file2Size > 0);
  312. writeTrashFile("file2.txt", "content3");
  313. assertNotNull(git.add().addFilepattern("file2.txt").call());
  314. writeTrashFile("file2.txt", "content4");
  315. // Smudge entries
  316. cache = DirCache.lock(db.getIndexFile(), db.getFS());
  317. cache.getEntry("file1.txt").setLength(0);
  318. cache.getEntry("file2.txt").setLength(0);
  319. cache.write();
  320. assertTrue(cache.commit());
  321. // Verify entries smudged
  322. cache = db.readDirCache();
  323. assertEquals(0, cache.getEntry("file1.txt").getLength());
  324. assertEquals(0, cache.getEntry("file2.txt").getLength());
  325. long indexTime = db.getIndexFile().lastModified();
  326. db.getIndexFile().setLastModified(indexTime - 5000);
  327. write(file1, "content5");
  328. assertTrue(file1.setLastModified(file1.lastModified() + 1000));
  329. assertNotNull(git.commit().setMessage("edit file").setOnly("file1.txt")
  330. .call());
  331. cache = db.readDirCache();
  332. assertEquals(file1Size, cache.getEntry("file1.txt").getLength());
  333. assertEquals(0, cache.getEntry("file2.txt").getLength());
  334. }
  335. @Test
  336. public void commitAfterSquashMerge() throws Exception {
  337. Git git = new Git(db);
  338. writeTrashFile("file1", "file1");
  339. git.add().addFilepattern("file1").call();
  340. RevCommit first = git.commit().setMessage("initial commit").call();
  341. assertTrue(new File(db.getWorkTree(), "file1").exists());
  342. createBranch(first, "refs/heads/branch1");
  343. checkoutBranch("refs/heads/branch1");
  344. writeTrashFile("file2", "file2");
  345. git.add().addFilepattern("file2").call();
  346. git.commit().setMessage("second commit").call();
  347. assertTrue(new File(db.getWorkTree(), "file2").exists());
  348. checkoutBranch("refs/heads/master");
  349. MergeResult result = git.merge()
  350. .include(db.exactRef("refs/heads/branch1"))
  351. .setSquash(true)
  352. .call();
  353. assertTrue(new File(db.getWorkTree(), "file1").exists());
  354. assertTrue(new File(db.getWorkTree(), "file2").exists());
  355. assertEquals(MergeResult.MergeStatus.FAST_FORWARD_SQUASHED,
  356. result.getMergeStatus());
  357. // comment not set, should be inferred from SQUASH_MSG
  358. RevCommit squashedCommit = git.commit().call();
  359. assertEquals(1, squashedCommit.getParentCount());
  360. assertNull(db.readSquashCommitMsg());
  361. assertEquals("commit: Squashed commit of the following:", db
  362. .getReflogReader(Constants.HEAD).getLastEntry().getComment());
  363. assertEquals("commit: Squashed commit of the following:", db
  364. .getReflogReader(db.getBranch()).getLastEntry().getComment());
  365. }
  366. @Test(expected = WrongRepositoryStateException.class)
  367. public void commitAmendOnInitialShouldFail() throws Exception {
  368. Git git = new Git(db);
  369. git.commit().setAmend(true).setMessage("initial commit").call();
  370. }
  371. @Test
  372. public void commitAmendWithoutAuthorShouldSetOriginalAuthorAndAuthorTime()
  373. throws Exception {
  374. Git git = new Git(db);
  375. writeTrashFile("file1", "file1");
  376. git.add().addFilepattern("file1").call();
  377. final String authorName = "First Author";
  378. final String authorEmail = "author@example.org";
  379. final Date authorDate = new Date(1349621117000L);
  380. PersonIdent firstAuthor = new PersonIdent(authorName, authorEmail,
  381. authorDate, TimeZone.getTimeZone("UTC"));
  382. git.commit().setMessage("initial commit").setAuthor(firstAuthor).call();
  383. RevCommit amended = git.commit().setAmend(true)
  384. .setMessage("amend commit").call();
  385. PersonIdent amendedAuthor = amended.getAuthorIdent();
  386. assertEquals(authorName, amendedAuthor.getName());
  387. assertEquals(authorEmail, amendedAuthor.getEmailAddress());
  388. assertEquals(authorDate.getTime(), amendedAuthor.getWhen().getTime());
  389. }
  390. @Test
  391. public void commitAmendWithAuthorShouldUseIt() throws Exception {
  392. Git git = new Git(db);
  393. writeTrashFile("file1", "file1");
  394. git.add().addFilepattern("file1").call();
  395. git.commit().setMessage("initial commit").call();
  396. RevCommit amended = git.commit().setAmend(true)
  397. .setAuthor("New Author", "newauthor@example.org")
  398. .setMessage("amend commit").call();
  399. PersonIdent amendedAuthor = amended.getAuthorIdent();
  400. assertEquals("New Author", amendedAuthor.getName());
  401. assertEquals("newauthor@example.org", amendedAuthor.getEmailAddress());
  402. }
  403. @Test
  404. public void commitOnlyShouldCommitUnmergedPathAndNotAffectOthers()
  405. throws Exception {
  406. DirCache index = db.lockDirCache();
  407. DirCacheBuilder builder = index.builder();
  408. addUnmergedEntry("unmerged1", builder);
  409. addUnmergedEntry("unmerged2", builder);
  410. DirCacheEntry other = new DirCacheEntry("other");
  411. other.setFileMode(FileMode.REGULAR_FILE);
  412. builder.add(other);
  413. builder.commit();
  414. writeTrashFile("unmerged1", "unmerged1 data");
  415. writeTrashFile("unmerged2", "unmerged2 data");
  416. writeTrashFile("other", "other data");
  417. assertEquals("[other, mode:100644]"
  418. + "[unmerged1, mode:100644, stage:1]"
  419. + "[unmerged1, mode:100644, stage:2]"
  420. + "[unmerged1, mode:100644, stage:3]"
  421. + "[unmerged2, mode:100644, stage:1]"
  422. + "[unmerged2, mode:100644, stage:2]"
  423. + "[unmerged2, mode:100644, stage:3]",
  424. indexState(0));
  425. Git git = new Git(db);
  426. RevCommit commit = git.commit().setOnly("unmerged1")
  427. .setMessage("Only one file").call();
  428. assertEquals("[other, mode:100644]" + "[unmerged1, mode:100644]"
  429. + "[unmerged2, mode:100644, stage:1]"
  430. + "[unmerged2, mode:100644, stage:2]"
  431. + "[unmerged2, mode:100644, stage:3]",
  432. indexState(0));
  433. try (TreeWalk walk = TreeWalk.forPath(db, "unmerged1", commit.getTree())) {
  434. assertEquals(FileMode.REGULAR_FILE, walk.getFileMode(0));
  435. }
  436. }
  437. @Test
  438. public void commitOnlyShouldHandleIgnored() throws Exception {
  439. try (Git git = new Git(db)) {
  440. writeTrashFile("subdir/foo", "Hello World");
  441. writeTrashFile("subdir/bar", "Hello World");
  442. writeTrashFile(".gitignore", "bar");
  443. git.add().addFilepattern("subdir").call();
  444. git.commit().setOnly("subdir").setMessage("first commit").call();
  445. }
  446. }
  447. private static void addUnmergedEntry(String file, DirCacheBuilder builder) {
  448. DirCacheEntry stage1 = new DirCacheEntry(file, DirCacheEntry.STAGE_1);
  449. DirCacheEntry stage2 = new DirCacheEntry(file, DirCacheEntry.STAGE_2);
  450. DirCacheEntry stage3 = new DirCacheEntry(file, DirCacheEntry.STAGE_3);
  451. stage1.setFileMode(FileMode.REGULAR_FILE);
  452. stage2.setFileMode(FileMode.REGULAR_FILE);
  453. stage3.setFileMode(FileMode.REGULAR_FILE);
  454. builder.add(stage1);
  455. builder.add(stage2);
  456. builder.add(stage3);
  457. }
  458. }