Aldrin Leal avatar Aldrin Leal committed 9fe0a2f

Interim Commit

Comments (0)

Files changed (2)

beanstalk-maven-plugin/src/main/java/br/com/ingenieux/mojo/beanstalk/bundle/FastDeployMojo.java

 import java.io.File;
 import java.util.Date;
 
+import org.apache.commons.io.FileUtils;
 import org.eclipse.jgit.api.Git;
 import org.eclipse.jgit.api.PushCommand;
-import org.eclipse.jgit.api.RmCommand;
-import org.eclipse.jgit.api.Status;
 import org.eclipse.jgit.lib.ObjectId;
 import org.eclipse.jgit.lib.TextProgressMonitor;
 import org.eclipse.jgit.transport.RefSpec;
 	protected Object executeInternal() throws Exception {
 		File gitRepo = new File(sourceDirectory, ".git");
 
-		Git git = null;
+		if (gitRepo.exists())
+			FileUtils.cleanDirectory(gitRepo);
 
-		if (gitRepo.exists()) {
-			git = Git.open(sourceDirectory);
-		} else {
-			git = Git.init().setDirectory(sourceDirectory).call();
-		}
-		
-		Status status = git.status().call();
-		
-		if (status.isClean()) {
-			getLog().info("No Changes");
-			
-			return null;
-		}
-		
-		if (!status.getMissing().isEmpty()) {
-			RmCommand rmCommand = git.rm();
+		Git git = Git.init().setDirectory(sourceDirectory).call();
 
-			for (String path : status.getMissing()) {
-				rmCommand.addFilepattern(path);
-			}
+		git.add().addFilepattern(".").call();
 
-			rmCommand.call();
-		}
-		
-		git.add().addFilepattern(".").call();
-		
 		git.commit().setMessage("Update from fast-deploy").call();
 
 		String commitId = ObjectId.toString(git.getRepository()
 
 		PushCommand cmd = git.//
 				push();
-		
+
 		cmd.setProgressMonitor(new TextProgressMonitor());
 
-		cmd.setRefSpecs(new RefSpec("HEAD:refs/heads/master")).//
-				setForce(true).//
-				setRemote(remote).//
-				call();
-		
+		try {
+			cmd.setRefSpecs(new RefSpec("HEAD:refs/heads/master")).//
+					setForce(true).//
+					setRemote(remote).//
+					call();
+		} catch (Exception exc) {
+			// Ignore
+		}
+
 		String gitVersion = "git-" + commitId;
 
 		getLog().info("Deployed version " + gitVersion);

beanstalk-maven-plugin/src/main/java/br/com/ingenieux/mojo/beanstalk/env/CreateEnvironmentMojo.java

 @MojoGoal("create-environment")
 @MojoSince("0.1.0")
 public class CreateEnvironmentMojo extends AbstractNeedsEnvironmentMojo {
-	@MojoParameter(expression="${beanstalk.environmentName}", description="Environment Name", defaultValue="${project.artifactId}")
+	@MojoParameter(expression="${beanstalk.environmentName}", description="Environment Name", defaultValue="${project.artifactId}-env")
 	protected String environmentName;
         
 	/**
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.