Skip to content

Commit

Permalink
Fixed immutable arraylist problems
Browse files Browse the repository at this point in the history
  • Loading branch information
lptr committed Jun 17, 2014
1 parent 438000a commit 1002f4d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.prezi.gradle.pride.vcs.git;

import com.google.common.collect.Lists;
import com.prezi.gradle.pride.ProcessUtils;
import com.prezi.gradle.pride.vcs.VcsSupport;
import org.apache.commons.configuration.Configuration;
Expand All @@ -9,7 +10,6 @@

import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand All @@ -30,7 +30,7 @@ public void checkout(String repositoryUrl, File targetDirectory, boolean mirrore
FileUtils.deleteDirectory(targetDirectory);

log.debug("Cloning {} into {}", repositoryUrl, targetDirectory);
List<String> commandLine = Arrays.asList("git", "clone", repositoryUrl, targetDirectory.toString());
List<String> commandLine = Lists.newArrayList("git", "clone", repositoryUrl, targetDirectory.toString());
if (mirrored) {
commandLine.add("--mirror");
}
Expand All @@ -39,7 +39,7 @@ public void checkout(String repositoryUrl, File targetDirectory, boolean mirrore

@Override
public void update(File targetDirectory, boolean mirrored) throws IOException {
List<String> fetchCommand = Arrays.asList("git", "fetch");
List<String> fetchCommand = Lists.newArrayList("git", "fetch");

// Cached repositories need to update all branches
if (mirrored) {
Expand All @@ -50,13 +50,13 @@ public void update(File targetDirectory, boolean mirrored) throws IOException {
// Update working copy unless this is a cached clone
if (!mirrored) {
String updateCommand = configuration.getString(GIT_UPDATE, "git rebase --autostash");
ProcessUtils.executeIn(targetDirectory, Arrays.asList(updateCommand.split(" ")));
ProcessUtils.executeIn(targetDirectory, Lists.newArrayList(updateCommand.split(" ")));
}
}

@Override
public void activate(String repositoryUrl, File targetDirectory) throws IOException {
ProcessUtils.executeIn(targetDirectory, Arrays.asList("git", "remote", "set-url", "origin", repositoryUrl));
ProcessUtils.executeIn(targetDirectory, Lists.newArrayList("git", "remote", "set-url", "origin", repositoryUrl));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.prezi.gradle.pride.cli.commands;

import com.google.common.collect.Lists;
import com.prezi.gradle.pride.PrideException;
import com.prezi.gradle.pride.cli.CliConfiguration;
import com.prezi.gradle.pride.vcs.RepoCache;
Expand All @@ -14,8 +15,6 @@

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;

public abstract class AbstractCommand implements Runnable {
protected static final Logger logger = LoggerFactory.getLogger(AbstractCommand.class);
Expand Down Expand Up @@ -58,7 +57,7 @@ private static PropertiesConfiguration loadConfiguration() {

protected final Configuration getConfiguration() {
if (processedConfiguration == null) {
processedConfiguration = new CompositeConfiguration(new ArrayList<Configuration>(Arrays.asList(fileConfiguration, new CliConfiguration.Defaults())));
processedConfiguration = new CompositeConfiguration(Lists.newArrayList(fileConfiguration, new CliConfiguration.Defaults()));
overrideConfiguration(processedConfiguration);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.google.common.base.Predicate;
import com.google.common.collect.Collections2;
import com.google.common.collect.Lists;
import com.prezi.gradle.pride.Pride;
import com.prezi.gradle.pride.PrideException;
import com.prezi.gradle.pride.ProcessUtils;
Expand All @@ -14,8 +15,6 @@

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;

Expand Down Expand Up @@ -49,7 +48,7 @@ public boolean apply(String it) {
public boolean apply(String moduleName) {
File moduleDir = pride.getModuleDirectory(moduleName);
try {
Process process = ProcessUtils.executeIn(moduleDir, new ArrayList<String>(Arrays.asList("git", "status", "--porcelain")), false);
Process process = ProcessUtils.executeIn(moduleDir, Lists.newArrayList("git", "status", "--porcelain"), false);
return !IOUtils.toString(process.getInputStream()).trim().isEmpty();
} catch (IOException e) {
throw new RuntimeException(e);
Expand Down

0 comments on commit 1002f4d

Please sign in to comment.