use of org.gradle.vcs.internal.VersionRef in project gradle by gradle.
the class GitVersionControlSystem method getBranch.
@Nullable
@Override
public VersionRef getBranch(VersionControlSpec spec, String branch) {
GitVersionControlSpec gitSpec = cast(spec);
Collection<Ref> refs;
try {
refs = Git.lsRemoteRepository().setRemote(normalizeUri(gitSpec.getUrl())).setHeads(true).setTags(false).call();
} catch (URISyntaxException e) {
throw wrapGitCommandException("ls-remote", gitSpec.getUrl(), null, e);
} catch (GitAPIException e) {
throw wrapGitCommandException("ls-remote", gitSpec.getUrl(), null, e);
}
String refName = "refs/heads/" + branch;
for (Ref ref : refs) {
if (ref.getName().equals(refName)) {
return GitVersionRef.from(ref);
}
}
return null;
}
Aggregations