Skip to content
Snippets Groups Projects
Commit 202b5b5d authored by Georg Seibt's avatar Georg Seibt :nerd:
Browse files

Merge branch 'master' into 'master'

Make clone actually fallback to import instead of just importing.

See merge request !3
parents 69a7a56b cba7ba06
No related branches found
No related tags found
1 merge request!3Make clone actually fallback to import instead of just importing.
package de.uni_passau.fim.gitwrapper;
import de.uni_passau.fim.processexecutor.ProcessExecutor;
import de.uni_passau.fim.processexecutor.ToolNotWorkingException;
import de.uni_passau.fim.processexecutor.ToolWrapper;
import java.io.File;
import java.io.IOException;
import java.io.StringReader;
......@@ -7,24 +11,13 @@ import java.io.StringWriter;
import java.nio.file.InvalidPathException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Scanner;
import java.util.*;
import java.util.function.Function;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import de.uni_passau.fim.processexecutor.ProcessExecutor;
import de.uni_passau.fim.processexecutor.ToolNotWorkingException;
import de.uni_passau.fim.processexecutor.ToolWrapper;
import static java.util.Collections.singletonList;
/**
......@@ -91,7 +84,7 @@ public class GitWrapper extends ToolWrapper {
/**
* Attempts to clone the git repository at the given <code>url</code> into a directory under <code>parentDir</code>.
* If <code>parentDir</code> already contains a git repository with the name that would be produced when cloning
* <code>url</code> it is assumed to be a clone of <code>url</code> and returned as a {@link Repository}.
* <code>url</code> it is assumed to be a clone of <code>url</code> and {@link #importRepository(File) imported} as a {@link Repository}.
*
* @param parentDir
* the directory in which to place the clone of <code>url</code>
......@@ -143,7 +136,17 @@ public class GitWrapper extends ToolWrapper {
}
LOG.fine(() -> String.format("'%s' is a git repository. Assuming it is a clone of '%s'.", repoPath, url));
Repository repo = new Repository(this, url, repoDir);
Optional<Repository> maybeRepo = importRepository(repoDir);
if (!maybeRepo.isPresent()) {
LOG.warning("Could not import repo from " + repoDir);
return null;
}
Repository repo = maybeRepo.get();
if (!repo.getUrl().equals(url)) {
LOG.warning("URL of imported repository (" + repo.getUrl() + ") does not match given URL (" + url + "). Proceeding anyway.");
}
if (fetch && !repo.fetch()) {
LOG.warning("Could not fetch " + repo + ". It may be out of date.");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment