The Unified and Autonomous Development Platform
Support submodule and symbolic link when listing Git tree.
robin shinec2d133b076e0
diff --git a/commons.git/src/main/java/com/pmease/commons/git/DirNode.java b/commons.git/src/main/java/com/pmease/commons/git/DirNode.javadeleted file mode 100644index 4352007ec2..0000000000--- a/commons.git/src/main/java/com/pmease/commons/git/DirNode.java+++ /dev/null@@ -1,23 +0,0 @@-package com.pmease.commons.git;--import java.io.File;-import java.util.List;--import com.pmease.commons.git.command.ListTreeCommand;--@SuppressWarnings("serial")-public class DirNode extends TreeNode {-- public DirNode(File gitDir, String path, String revision, String hash, String mode) {- super(gitDir, path, revision, hash, mode);- }-- public List<TreeNode> listChildren() {- List<TreeNode> children = new ListTreeCommand(gitDir).revision(getRevision()).path(getPath() + "/").call();- for (TreeNode each: children) {- each.setParent(this);- }- return children;- }--}diff --git a/commons.git/src/main/java/com/pmease/commons/git/FileNode.java b/commons.git/src/main/java/com/pmease/commons/git/FileNode.javadeleted file mode 100644index 0c315f7ef2..0000000000--- a/commons.git/src/main/java/com/pmease/commons/git/FileNode.java+++ /dev/null@@ -1,25 +0,0 @@-package com.pmease.commons.git;--import java.io.File;--import com.pmease.commons.git.command.ReadFileCommand;--@SuppressWarnings("serial")-public class FileNode extends TreeNode {-- private final long size;-- public FileNode(File gitDir, String path, String revision, String hash, String mode, long size) {- super(gitDir, path, revision, hash, mode);- this.size = size;- }-- public long getSize() {- return size;- }-- public byte[] read() {- return new ReadFileCommand(gitDir).revision(getRevision()).path(getPath()).call();- }--}diff --git a/commons.git/src/main/java/com/pmease/commons/git/Git.java b/commons.git/src/main/java/com/pmease/commons/git/Git.javaindex ddf18d38e8..a4360f3c63 100644--- a/commons.git/src/main/java/com/pmease/commons/git/Git.java+++ b/commons.git/src/main/java/com/pmease/commons/git/Git.java@@ -4,12 +4,14 @@ import java.io.File;import java.io.Serializable;import java.util.Collection;import java.util.List;+import java.util.Map;import javax.annotation.Nullable;import com.google.common.base.Preconditions;import com.pmease.commons.git.command.AddCommand;import com.pmease.commons.git.command.AddNoteCommand;+import com.pmease.commons.git.command.AddSubModuleCommand;import com.pmease.commons.git.command.BlameCommand;import com.pmease.commons.git.command.CalcMergeBaseCommand;import com.pmease.commons.git.command.CheckAncestorCommand;@@ -19,14 +21,16 @@ import com.pmease.commons.git.command.CommitCommand;import com.pmease.commons.git.command.DeleteRefCommand;import com.pmease.commons.git.command.DiffCommand;import com.pmease.commons.git.command.InitCommand;+import com.pmease.commons.git.command.IsBinaryCommand;import com.pmease.commons.git.command.ListBranchesCommand;import com.pmease.commons.git.command.ListChangedFilesCommand;+import com.pmease.commons.git.command.ListSubModulesCommand;import com.pmease.commons.git.command.ListTagsCommand;import com.pmease.commons.git.command.ListTreeCommand;import com.pmease.commons.git.command.LogCommand;import com.pmease.commons.git.command.MergeCommand;-import com.pmease.commons.git.command.ReadFileCommand;import com.pmease.commons.git.command.RemoveCommand;+import com.pmease.commons.git.command.ShowCommand;import com.pmease.commons.git.command.UpdateRefCommand;import com.pmease.commons.util.FileUtils;import com.pmease.commons.util.GeneralException;@@ -152,8 +156,8 @@ public class Git implements Serializable {return new ListTagsCommand(repoDir).call();}- public byte[] readFile(String revision, String path) {- return new ReadFileCommand(repoDir).revision(revision).path(path).call();+ public byte[] show(String revision, String path) {+ return new ShowCommand(repoDir).revision(revision).path(path).call();}public List<Commit> log(@Nullable String fromRev, @Nullable String toRev,@@ -178,5 +182,18 @@ public class Git implements Serializable {public List<Blame> blame(String file, String revision) {return new BlameCommand(repoDir).file(file).revision(revision).call();}++ public boolean isBinary(String file, String revision) {+ return new IsBinaryCommand(repoDir).file(file).revision(revision).call();+ }++ public Git addSubModule(String url, String path) {+ new AddSubModuleCommand(repoDir).url(url).path(path).call();+ return this;+ }++ public Map<String, String> listSubModules(String revision) {+ return new ListSubModulesCommand(repoDir).revision(revision).call();+ }}diff --git a/commons.git/src/main/java/com/pmease/commons/git/TreeNode.java b/commons.git/src/main/java/com/pmease/commons/git/TreeNode.javaindex bc4374b69e..2597a1084a 100644--- a/commons.git/src/main/java/com/pmease/commons/git/TreeNode.java+++ b/commons.git/src/main/java/com/pmease/commons/git/TreeNode.java@@ -11,13 +11,30 @@ import org.apache.commons.lang3.StringUtils;import com.google.common.base.Optional;import com.google.common.base.Preconditions;import com.pmease.commons.git.command.ListTreeCommand;+import com.pmease.commons.git.command.ShowCommand;@SuppressWarnings("serial")public class TreeNode implements Serializable {++ public enum Type {+ DIRECTORY, FILE, SUBMODULE, SYMBOLLINK;++ public static Type fromMode(String mode) {+ if (mode.startsWith("040"))+ return DIRECTORY;+ else if (mode.startsWith("160"))+ return SUBMODULE;+ else if (mode.startsWith("120"))+ return SYMBOLLINK;+ else+ return FILE;+ }++ }protected final File gitDir;- private final String mode;+ private final Type type;private final String path;@@ -25,14 +42,17 @@ public class TreeNode implements Serializable {private final String revision;- private Optional<DirNode> parentNode;+ private final int size;++ private Optional<TreeNode> parentNode;- public TreeNode(File gitDir, String path, String revision, String hash, String mode) {+ public TreeNode(File gitDir, Type type, String path, String revision, String hash, int size) {this.gitDir = gitDir;this.path = path;this.revision = revision;this.hash = hash;- this.mode = mode;+ this.type = type;+ this.size = size;}public String getPath() {@@ -54,8 +74,12 @@ public class TreeNode implements Serializable {return hash;}- public String getMode() {- return mode;+ public Type getType() {+ return type;+ }++ public int getSize() {+ return size;}public @Nullable TreeNode getParent() {@@ -64,7 +88,7 @@ public class TreeNode implements Serializable {String parentPath = StringUtils.substringBeforeLast(path, "/");List<TreeNode> result = new ListTreeCommand(gitDir).revision(getRevision()).path(parentPath).call();Preconditions.checkArgument(result.size() == 1);- parentNode = Optional.of((DirNode)result.get(0));+ parentNode = Optional.of(result.get(0));} else {parentNode = Optional.fromNullable(null);}@@ -72,7 +96,7 @@ public class TreeNode implements Serializable {return parentNode.orNull();}- public void setParent(@Nullable DirNode parent) {+ public void setParent(@Nullable TreeNode parent) {this.parentNode = Optional.fromNullable(parent);}@@ -81,4 +105,24 @@ public class TreeNode implements Serializable {return getPath();}+ public @Nullable List<TreeNode> listChildren() {+ if (type == Type.DIRECTORY) {+ List<TreeNode> children = new ListTreeCommand(gitDir).revision(getRevision()).path(getPath() + "/").call();+ for (TreeNode each: children) {+ each.setParent(this);+ }+ return children;+ } else {+ return null;+ }+ }++ public byte[] show() {+ if (type == Type.SUBMODULE) {+ return new Git(gitDir).listSubModules(revision).get(path).getBytes();+ } else {+ return new ShowCommand(gitDir).revision(getRevision()).path(getPath()).call();+ }+ }+}diff --git a/commons.git/src/main/java/com/pmease/commons/git/command/AddSubModuleCommand.java b/commons.git/src/main/java/com/pmease/commons/git/command/AddSubModuleCommand.javanew file mode 100644index 0000000000..3cdb842de0--- /dev/null+++ b/commons.git/src/main/java/com/pmease/commons/git/command/AddSubModuleCommand.java@@ -0,0 +1,39 @@+package com.pmease.commons.git.command;++import java.io.File;++import com.google.common.base.Preconditions;+import com.pmease.commons.util.execution.Commandline;++public class AddSubModuleCommand extends GitCommand<Void> {++ private String url;++ private String path;++ public AddSubModuleCommand(File repoDir) {+ super(repoDir);+ }++ public AddSubModuleCommand url(String url) {+ this.url = url;+ return this;+ }++ public AddSubModuleCommand path(String path) {+ this.path = path;+ return this;+ }++ @Override+ public Void call() {+ Preconditions.checkNotNull(url, "url should be specified.");+ Preconditions.checkNotNull(path, "path should be specified.");++ Commandline cmd = cmd().addArgs("submodule", "add", url, path);+ cmd.execute(debugLogger(), errorLogger()).checkReturnCode();++ return null;+ }++}diff --git a/commons.git/src/main/java/com/pmease/commons/git/command/IsBinaryCommand.java b/commons.git/src/main/java/com/pmease/commons/git/command/IsBinaryCommand.javanew file mode 100644index 0000000000..bc9729320b--- /dev/null+++ b/commons.git/src/main/java/com/pmease/commons/git/command/IsBinaryCommand.java@@ -0,0 +1,52 @@+package com.pmease.commons.git.command;++import java.io.File;++import com.google.common.base.Preconditions;+import com.pmease.commons.util.execution.Commandline;+import com.pmease.commons.util.execution.LineConsumer;++public class IsBinaryCommand extends GitCommand<Boolean> {++ private String revision;++ private String file;++ public IsBinaryCommand revision(String revision) {+ this.revision = revision;+ return this;+ }++ public IsBinaryCommand file(String file) {+ this.file = file;+ return this;+ }++ public IsBinaryCommand(File repoDir) {+ super(repoDir);+ }++ @Override+ public Boolean call() {+ Preconditions.checkNotNull(revision, "revision has to be specified.");+ Preconditions.checkNotNull(file, "file has to be specified.");++ Commandline cmd = cmd();+ cmd.addArgs("diff-tree", "-p", "4b825dc642cb6eb9a060e54bf8d69288fbee4904", revision, "--", file);++ final boolean[] isBinary = new boolean[]{false};++ cmd.execute(new LineConsumer() {++ @Override+ public void consume(String line) {+ if (line.startsWith("Binary files"))+ isBinary[0] = true;+ }++ }, errorLogger()).checkReturnCode();++ return isBinary[0];+ }++}diff --git a/commons.git/src/main/java/com/pmease/commons/git/command/ListSubModulesCommand.java b/commons.git/src/main/java/com/pmease/commons/git/command/ListSubModulesCommand.javanew file mode 100644index 0000000000..a4afbb794b--- /dev/null+++ b/commons.git/src/main/java/com/pmease/commons/git/command/ListSubModulesCommand.java@@ -0,0 +1,51 @@+package com.pmease.commons.git.command;++import java.io.File;+import java.util.HashMap;+import java.util.Map;++import com.pmease.commons.git.Git;+import com.pmease.commons.util.StringUtils;++public class ListSubModulesCommand extends GitCommand<Map<String, String>> {++ private String revision;++ public ListSubModulesCommand(File repoDir) {+ super(repoDir);+ }++ public ListSubModulesCommand revision(String revision) {+ this.revision = revision;+ return this;+ }++ @Override+ public Map<String, String> call() {+ Map<String, String> modules = new HashMap<>();++ String content = new String(new Git(repoDir).show(revision, ".gitmodules"));++ String path = null;+ String url = null;++ for (String line: StringUtils.splitAndTrim(content, "\r\n")) {+ if (line.startsWith("[") && line.endsWith("]")) {+ if (path != null && url != null)+ modules.put(path, url);++ path = url = null;+ } else if (line.startsWith("path")) {+ path = StringUtils.substringAfter(line, "=").trim();+ } else if (line.startsWith("url")) {+ url = StringUtils.substringAfter(line, "=").trim();+ }+ }++ if (path != null && url != null)+ modules.put(path, url);++ return modules;+ }++}diff --git a/commons.git/src/main/java/com/pmease/commons/git/command/ListTreeCommand.java b/commons.git/src/main/java/com/pmease/commons/git/command/ListTreeCommand.javaindex aaac895d21..45d8b39a02 100644--- a/commons.git/src/main/java/com/pmease/commons/git/command/ListTreeCommand.java+++ b/commons.git/src/main/java/com/pmease/commons/git/command/ListTreeCommand.java@@ -5,10 +5,9 @@ import java.util.ArrayList;import java.util.List;import org.apache.commons.lang3.StringUtils;+import org.apache.commons.lang3.math.NumberUtils;import com.google.common.base.Preconditions;-import com.pmease.commons.git.DirNode;-import com.pmease.commons.git.FileNode;import com.pmease.commons.git.TreeNode;import com.pmease.commons.util.execution.Commandline;import com.pmease.commons.util.execution.LineConsumer;@@ -59,21 +58,16 @@ public class ListTreeCommand extends GitCommand<List<TreeNode>> {public void consume(String line) {String mode = StringUtils.substringBefore(line, " ");line = StringUtils.substringAfter(line, " ");- String type = StringUtils.substringBefore(line, " ");line = StringUtils.substringAfter(line, " ");String hash = StringUtils.substringBefore(line, " ");line = StringUtils.substringAfter(line, " ");- String size = StringUtils.substringBefore(line.trim(), "\t");+ int size = 0;+ String sizeStr = StringUtils.substringBefore(line.trim(), "\t");+ if (NumberUtils.isNumber(sizeStr))+ size = Integer.parseInt(sizeStr);String path = StringUtils.substringAfter(line.trim(), "\t");- TreeNode treeNode;- if (type.equals("tree")) {- treeNode = new DirNode(repoDir, path, revision, hash, mode);- } else {- treeNode = new FileNode(repoDir, path, revision, hash, mode, Long.parseLong(size));- }-- treeNodes.add(treeNode);+ treeNodes.add(new TreeNode(repoDir, TreeNode.Type.fromMode(mode), path, revision, hash, size));}}, errorLogger()).checkReturnCode();diff --git a/commons.git/src/main/java/com/pmease/commons/git/command/ReadFileCommand.java b/commons.git/src/main/java/com/pmease/commons/git/command/ShowCommand.javasimilarity index 79%rename from commons.git/src/main/java/com/pmease/commons/git/command/ReadFileCommand.javarename to commons.git/src/main/java/com/pmease/commons/git/command/ShowCommand.javaindex 441bac772e..0afc59d25a 100644--- a/commons.git/src/main/java/com/pmease/commons/git/command/ReadFileCommand.java+++ b/commons.git/src/main/java/com/pmease/commons/git/command/ShowCommand.java@@ -7,22 +7,22 @@ import org.apache.commons.io.output.ByteArrayOutputStream;import com.google.common.base.Preconditions;import com.pmease.commons.util.execution.Commandline;-public class ReadFileCommand extends GitCommand<byte[]> {+public class ShowCommand extends GitCommand<byte[]> {private String revision;private String path;- public ReadFileCommand(final File repoDir) {+ public ShowCommand(final File repoDir) {super(repoDir);}- public ReadFileCommand revision(String revision) {+ public ShowCommand revision(String revision) {this.revision = revision;return this;}- public ReadFileCommand path(String path) {+ public ShowCommand path(String path) {this.path = path;return this;}diff --git a/commons.git/src/test/java/com/pmease/commons/git/command/BlameCommandTest.java b/commons.git/src/test/java/com/pmease/commons/git/command/BlameCommandTest.javaindex b83be6e0ff..d7b189db0e 100644--- a/commons.git/src/test/java/com/pmease/commons/git/command/BlameCommandTest.java+++ b/commons.git/src/test/java/com/pmease/commons/git/command/BlameCommandTest.java@@ -3,7 +3,9 @@ package com.pmease.commons.git.command;import java.io.File;import java.util.List;+import org.junit.Assert;import org.junit.Test;+import static org.junit.Assert.*;import com.pmease.commons.git.Blame;@@ -14,7 +16,9 @@ public class BlameCommandTest {@Testpublic void test() {- File tempDir = FileUtils.createTempDir();+ Assert.assertTrue(GitCommand.checkError() == null);++ File tempDir = FileUtils.createTempDir();try {Git workGit = new Git(new File(tempDir, "work"));diff --git a/commons.git/src/test/java/com/pmease/commons/git/command/DiffCommandTest.java b/commons.git/src/test/java/com/pmease/commons/git/command/DiffCommandTest.javaindex 2c8a315bdf..86e6690ef0 100644--- a/commons.git/src/test/java/com/pmease/commons/git/command/DiffCommandTest.java+++ b/commons.git/src/test/java/com/pmease/commons/git/command/DiffCommandTest.java@@ -17,6 +17,7 @@ public class DiffCommandTest {@Testpublic void shouldGenerateDiffCorrectly() {assertTrue(GitCommand.checkError() == null);+File tempDir = FileUtils.createTempDir();try {diff --git a/commons.git/src/test/java/com/pmease/commons/git/command/IsBinaryCommandTest.java b/commons.git/src/test/java/com/pmease/commons/git/command/IsBinaryCommandTest.javanew file mode 100644index 0000000000..945920fab3--- /dev/null+++ b/commons.git/src/test/java/com/pmease/commons/git/command/IsBinaryCommandTest.java@@ -0,0 +1,45 @@+package com.pmease.commons.git.command;++import static org.junit.Assert.assertFalse;+import static org.junit.Assert.assertTrue;++import java.io.File;+import java.io.FileOutputStream;+import java.io.IOException;+import java.io.OutputStream;++import org.junit.Assert;+import org.junit.Test;++import com.pmease.commons.git.Git;+import com.pmease.commons.util.FileUtils;++public class IsBinaryCommandTest {++ @Test+ public void test() throws IOException {+ Assert.assertTrue(GitCommand.checkError() == null);++ Git git = new Git(FileUtils.createTempDir());+ try {+ git.init(false);+ File file = new File(git.repoDir(), "file");+ FileUtils.writeFile(file, "hello world");+ git.add("file").commit("initial commit", false);++ byte[] bytes = new byte[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};+ OutputStream os = new FileOutputStream(file);+ os.write(bytes);+ os.close();++ git.add("file").commit("second commit", false);++ assertFalse(git.isBinary("file", "master~1"));+ assertTrue(git.isBinary("file", "master"));++ } finally {+ FileUtils.deleteDir(git.repoDir());+ }+ }++}diff --git a/commons.git/src/test/java/com/pmease/commons/git/command/ListSubModulesCommandTest.java b/commons.git/src/test/java/com/pmease/commons/git/command/ListSubModulesCommandTest.javanew file mode 100644index 0000000000..c47586d9dc--- /dev/null+++ b/commons.git/src/test/java/com/pmease/commons/git/command/ListSubModulesCommandTest.java@@ -0,0 +1,60 @@+package com.pmease.commons.git.command;++import static org.junit.Assert.assertEquals;++import java.io.File;+import java.io.IOException;+import java.util.Map;++import org.junit.Assert;+import org.junit.Test;++import com.pmease.commons.git.Git;+import com.pmease.commons.util.FileUtils;++public class ListSubModulesCommandTest {++ @Test+ public void test() throws IOException {+ Assert.assertTrue(GitCommand.checkError() == null);+ File tempDir = FileUtils.createTempDir();+ try {+ Git work = new Git(new File(tempDir, "work"));+ Git module1 = new Git(new File(tempDir, "module1"));+ Git module2 = new Git(new File(tempDir, "module2"));++ work.init(false);+ module1.init(false);+ module2.init(false);++ FileUtils.writeFile(new File(work.repoDir(), "readme"), "readme");+ work.add("readme").commit("initial commit", false);+ FileUtils.writeFile(new File(module1.repoDir(), "readme"), "readme");+ module1.add("readme").commit("initial commit", false);+ FileUtils.writeFile(new File(module2.repoDir(), "readme"), "readme");+ module2.add("readme").commit("initial commit", false);++ work.addSubModule(module1.repoDir().getAbsolutePath(), "module1");+ work.commit("add submodule1", false);++ Map<String, String> subModules = work.listSubModules("master");+ assertEquals(module1.repoDir().getCanonicalPath(),+ new File(subModules.get("module1")).getCanonicalPath());++ File dir = new File(work.repoDir(), "dir");+ FileUtils.createDir(dir);++ work.addSubModule(module2.repoDir().getAbsolutePath(), "dir/module2");+ work.commit("add submodule2", false);+ subModules = work.listSubModules("master");+ assertEquals(module1.repoDir().getCanonicalPath(),+ new File(subModules.get("module1")).getCanonicalPath());+ assertEquals(module2.repoDir().getCanonicalPath(),+ new File(subModules.get("dir/module2")).getCanonicalPath());++ } finally {+ FileUtils.deleteDir(tempDir);+ }+ }++}diff --git a/commons.git/src/test/java/com/pmease/commons/git/command/ListTreeCommandTest.java b/commons.git/src/test/java/com/pmease/commons/git/command/ListTreeCommandTest.javaindex 966ce07329..77034210ed 100644--- a/commons.git/src/test/java/com/pmease/commons/git/command/ListTreeCommandTest.java+++ b/commons.git/src/test/java/com/pmease/commons/git/command/ListTreeCommandTest.java@@ -1,16 +1,14 @@package com.pmease.commons.git.command;import static org.junit.Assert.assertEquals;-import static org.junit.Assert.assertTrue;import java.io.File;+import java.io.IOException;import java.util.List;import org.junit.Assert;import org.junit.Test;-import com.pmease.commons.git.DirNode;-import com.pmease.commons.git.FileNode;import com.pmease.commons.git.Git;import com.pmease.commons.git.TreeNode;import com.pmease.commons.util.FileUtils;@@ -18,14 +16,14 @@ import com.pmease.commons.util.FileUtils;public class ListTreeCommandTest {@Test- public void shouldListTreeAndReadFileCorrectly() {+ public void shouldListTreeAndReadFileCorrectly() throws IOException {Assert.assertTrue(GitCommand.checkError() == null);File tempDir = FileUtils.createTempDir();- Git workGit = new Git(new File(tempDir, "work"));- workGit.init(false);-try {+ Git workGit = new Git(new File(tempDir, "work"));+ workGit.init(false);+FileUtils.touchFile(new File(workGit.repoDir(), "a"));workGit.add("a");workGit.commit("commit", false);@@ -51,30 +49,40 @@ public class ListTreeCommandTest {workGit.add("dir/file");workGit.commit("commit", false);+ Git moduleGit = new Git(new File(tempDir, "module"));+ moduleGit.init(false);+ FileUtils.writeFile(new File(moduleGit.repoDir(), "readme"), "readme");+ moduleGit.add("readme").commit("commit", false);++ workGit.addSubModule(moduleGit.repoDir().getAbsolutePath(), "module");+ workGit.commit("commit", false);+workGit.checkout("dev", true);workGit.remove("dir/file");workGit.commit("commit", false);- Git bareGit = new Git(new File(tempDir, "bare"));+ Git bareGit = new Git(new File(tempDir, "bare"));bareGit.clone(workGit.repoDir().getAbsolutePath(), true);List<TreeNode> treeNodes = bareGit.listTree("master", null, false);- assertEquals(treeNodes.size(), 5);- assertEquals(treeNodes.get(4).getPath(), "dir");- assertEquals(treeNodes.get(4).getName(), "dir");- assertTrue(treeNodes.get(4) instanceof DirNode);+ assertEquals(7, treeNodes.size());+ assertEquals("dir", treeNodes.get(5).getPath());+ assertEquals("dir", treeNodes.get(5).getName());+ assertEquals(TreeNode.Type.DIRECTORY, treeNodes.get(5).getType());+ assertEquals(moduleGit.repoDir().getAbsolutePath(),+ new File(new String(treeNodes.get(6).show())).getCanonicalPath());- DirNode dirNode = (DirNode) treeNodes.get(4);+ TreeNode dirNode = treeNodes.get(5);treeNodes = dirNode.listChildren();- assertEquals(treeNodes.size(), 1);- assertEquals(treeNodes.get(0).getPath(), "dir/file");- assertEquals(treeNodes.get(0).getName(), "file");+ assertEquals(1, treeNodes.size());+ assertEquals("dir/file", treeNodes.get(0).getPath());+ assertEquals("file", treeNodes.get(0).getName());- FileNode fileNode = (FileNode) treeNodes.get(0);- assertEquals(new String(fileNode.read()), "hello world");- assertEquals(fileNode.getParent().getName(), "dir");+ TreeNode fileNode = treeNodes.get(0);+ assertEquals("hello world", new String(fileNode.show()));+ assertEquals("dir", fileNode.getParent().getName());} finally {FileUtils.deleteDir(tempDir);diff --git a/gitop.core/src/main/java/com/pmease/gitop/core/gatekeeper/TouchSpecifiedFiles.java b/gitop.core/src/main/java/com/pmease/gitop/core/gatekeeper/TouchSpecifiedFiles.javaindex 57385f4feb..e1cd0728e3 100644--- a/gitop.core/src/main/java/com/pmease/gitop/core/gatekeeper/TouchSpecifiedFiles.java+++ b/gitop.core/src/main/java/com/pmease/gitop/core/gatekeeper/TouchSpecifiedFiles.java@@ -7,7 +7,6 @@ import java.util.Collection;import org.hibernate.validator.constraints.NotEmpty;import com.pmease.commons.editable.annotation.Editable;-import com.pmease.commons.git.FileNode;import com.pmease.commons.git.Git;import com.pmease.commons.git.TreeNode;import com.pmease.commons.loader.AppLoader;@@ -45,7 +44,7 @@ public class TouchSpecifiedFiles extends AbstractGateKeeper {if (request.getMergeBase() == null) {touchedFiles = new ArrayList<>();for (TreeNode each: new Git(repoDir).listTree(update.getRefName(), null, true)) {- if (each instanceof FileNode)+ if (each.getType() == TreeNode.Type.FILE)touchedFiles.add(each.getPath());}} else {