選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

LsFilesTest.java 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Copyright (C) 2017, Matthias Sohn <matthias.sohn@sap.com> and others
  3. *
  4. * This program and the accompanying materials are made available under the
  5. * terms of the Eclipse Distribution License v. 1.0 which is available at
  6. * https://www.eclipse.org/org/documents/edl-v10.php.
  7. *
  8. * SPDX-License-Identifier: BSD-3-Clause
  9. */
  10. package org.eclipse.jgit.pgm;
  11. import static org.junit.Assert.assertArrayEquals;
  12. import static org.junit.Assert.assertTrue;
  13. import java.io.File;
  14. import org.eclipse.jgit.api.Git;
  15. import org.eclipse.jgit.junit.JGitTestUtil;
  16. import org.eclipse.jgit.lib.CLIRepositoryTestCase;
  17. import org.eclipse.jgit.util.FileUtils;
  18. import org.junit.Before;
  19. import org.junit.Test;
  20. public class LsFilesTest extends CLIRepositoryTestCase {
  21. @Before
  22. @Override
  23. public void setUp() throws Exception {
  24. super.setUp();
  25. try (Git git = new Git(db)) {
  26. JGitTestUtil.writeTrashFile(db, "hello", "hello");
  27. JGitTestUtil.writeTrashFile(db, "dir", "world", "world");
  28. git.add().addFilepattern("dir").call();
  29. git.commit().setMessage("Initial commit").call();
  30. JGitTestUtil.writeTrashFile(db, "hello2", "hello");
  31. git.add().addFilepattern("hello2").call();
  32. FileUtils.createSymLink(new File(db.getWorkTree(), "link"),
  33. "target");
  34. FileUtils.mkdir(new File(db.getWorkTree(), "target"));
  35. writeTrashFile("target/file", "someData");
  36. git.add().addFilepattern("target").addFilepattern("link").call();
  37. git.commit().setMessage("hello2").call();
  38. JGitTestUtil.writeTrashFile(db, "staged", "x");
  39. JGitTestUtil.deleteTrashFile(db, "hello2");
  40. git.add().addFilepattern("staged").call();
  41. JGitTestUtil.writeTrashFile(db, "untracked", "untracked");
  42. }
  43. }
  44. @Test
  45. public void testHelp() throws Exception {
  46. String[] result = execute("git ls-files -h");
  47. assertTrue(result[1].startsWith("jgit ls-files"));
  48. }
  49. @Test
  50. public void testLsFiles() throws Exception {
  51. assertArrayEquals(new String[] { "dir/world", "hello2", "link",
  52. "staged", "target/file", "" }, execute("git ls-files"));
  53. }
  54. }