Skip to content
Snippets Groups Projects
Commit f03b16c8 authored by Jack MacLauchlan CS2015's avatar Jack MacLauchlan CS2015
Browse files

Extracted fetch method

parent 1451461f
No related branches found
No related tags found
No related merge requests found
......@@ -110,14 +110,7 @@ class GitCommands {
private void mergeOnClone(String clone, String remote) throws IOException, GitAPIException {
try (Git git = Git.open(new File(clone))) {
StoredConfig config = git.getRepository().getConfig();
config.setString("remote", "remIssues", "url", remote);
config.save();
git.fetch()
.setRemote("remIssues")
.setRefSpecs(new RefSpec("refs/heads/issues:refs/remotes/remIssues"))
.call();
fetchRemote(remote, git);
ObjectId mergeBase = git.getRepository().resolve("remIssues");
......@@ -188,16 +181,21 @@ class GitCommands {
}
}
private void fetchRemote(String remote, Git git) throws IOException, GitAPIException {
StoredConfig config = git.getRepository().getConfig();
config.setString("remote", "remIssues", "url", remote);
config.save();
git.fetch()
.setRemote("remIssues")
.setRefSpecs(new RefSpec("refs/heads/issues:refs/remotes/remIssues"))
.call();
}
private void pullClone(String clone) throws IOException, GitAPIException {
try (Git git = new Git(repo)) {
StoredConfig config = git.getRepository().getConfig();
config.setString("remote", "remIssues", "url", clone);
config.save();
git.fetch().setRemote("remIssues")
.setRefSpecs(new RefSpec("refs/heads/issues:refs/remotes/remIssues"))
.call();
fetchRemote(clone, git);
Ref localRef = repo.findRef("refs/heads/issues");
Ref remoteRef = repo.findRef("refs/remotes/remIssues");
......
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