Преглед на файлове

Add the ability to pull new changes when code is already cloned.

HorridoJoho преди 3 години
родител
ревизия
0cdc1a24af
променени са 1 файла, в които са добавени 12 реда и са изтрити 7 реда
  1. 12 7
      src/main/java/com/l2jserver/cli/command/CodeCommand.java

+ 12 - 7
src/main/java/com/l2jserver/cli/command/CodeCommand.java

@@ -19,6 +19,7 @@
 package com.l2jserver.cli.command;
 
 import java.io.File;
+import java.nio.file.Files;
 
 import org.eclipse.jgit.api.Git;
 import org.slf4j.Logger;
@@ -104,14 +105,18 @@ public class CodeCommand extends AbstractCommand {
 	}
 	
 	private void cloneRepository(String repository, File directory) {
-		try {
-			Git.cloneRepository() //
-				.setURI(repository) //
-				.setDirectory(directory) //
-				.setProgressMonitor(LOGGER_PROGRESS_MONITOR) //
-				.call();
+	    try {
+	        if (directory.exists()) {
+	            Git.open(directory).pull();
+	        } else {
+	            Git.cloneRepository() //
+	                .setURI(repository) //
+	                .setDirectory(directory) //
+	                .setProgressMonitor(LOGGER_PROGRESS_MONITOR) //
+	                .call();
+	        }
 		} catch (Exception ex) {
-			LOG.error("Unable to get the code!", ex);
+		    LOG.error("Unable to get the code!", ex);
 		}
 	}
 }