Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions common/src/main/java/net/pcal/fastback/repo/PushUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ static void doPush(SnapshotId sid, RepoImpl repo, UserLogger ulog) throws IOExce
final Collection<String> remoteBranchRefs;
final String remoteName = conf.getString(REMOTE_NAME);
if (conf.getBoolean(IS_NATIVE_GIT_ENABLED)) {
remoteBranchRefs = native_lsRemote(repo.getWorkTree().toPath(), remoteName, true, false);
remoteBranchRefs = native_lsRemote(repo.getWorkTree().toPath(), remoteName);
} else {
remoteBranchRefs = jgit_lsRemote(repo.getJGit(), remoteName, true, false);
remoteBranchRefs = jgit_lsRemote(repo.getJGit(), remoteName);
}
final ListMultimap<WorldId, SnapshotId> snapshotsPerWorld =
SnapshotIdUtils.getSnapshotsPerWorld(remoteBranchRefs, repo.getSidCodec());
Expand Down Expand Up @@ -153,12 +153,9 @@ private static void jgit_doPush(final Git jgit, final String branchNameToPush, f
setRefSpecs(new RefSpec(branchNameToPush + ":" + branchNameToPush)).call();
}

static Collection<String> native_lsRemote(final Path worktree, final String remote, final boolean heads, final boolean tags) throws ProcessException {
final List<String> command = new ArrayList<>(asList("git", "-C", worktree.toAbsolutePath().toString(), "ls-remote"));
if (heads) command.add("--branches");
if (tags) command.add("--tags");
command.add(remote);

static Collection<String> native_lsRemote(final Path worktree, final String remoteName) throws ProcessException {
final List<String> command = new ArrayList<>(asList("git", "-C",
worktree.toAbsolutePath().toString(), "ls-remote", "--heads", remoteName));
final List<String> result = new ArrayList<>();
ProcessUtils.doExec(
command.toArray(String[]::new),
Expand All @@ -175,8 +172,8 @@ static Collection<String> native_lsRemote(final Path worktree, final String remo
return result;
}

static Collection<String> jgit_lsRemote(final Git jgit, final String remote, final boolean heads, final boolean tags) throws GitAPIException {
return jgit.lsRemote().setHeads(heads).setTags(tags).setRemote(remote).call()
static Collection<String> jgit_lsRemote(final Git jgit, final String remoteName) throws GitAPIException {
return jgit.lsRemote().setHeads(true).setTags(false).setRemote(remoteName).call()
.stream().map(Ref::getName).toList();
}

Expand Down
4 changes: 2 additions & 2 deletions common/src/main/java/net/pcal/fastback/repo/RepoImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,9 @@ public Set<SnapshotId> getRemoteSnapshots() throws IOException {
final JGitSupplier<Collection<String>> refProvider = () -> {
try {
if (conf.getBoolean(IS_NATIVE_GIT_ENABLED)) {
return native_lsRemote(this.getWorkTree().toPath(), remoteName, true, false);
return native_lsRemote(this.getWorkTree().toPath(), remoteName);
} else {
return jgit_lsRemote(this.jgit, remoteName, true, false);
return jgit_lsRemote(this.jgit, remoteName);
}
} catch (GitAPIException | ProcessException e) {
throw new IOException(e);
Expand Down