Skip to content

Commit

Permalink
refactor(github): Query for a single ref instead of listing all tags.…
Browse files Browse the repository at this point in the history
… Relates to #879
  • Loading branch information
aalmiray committed Aug 8, 2022
1 parent 24589af commit cf86c81
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,8 @@ git.releaser.release.not.found = release {} does not exist
git.releaser.user.not.found = Could not find user matching {}
git.releaser.repository.tag = tagging local repository with {}
github.generate.release.notes = Generating release notes on {}/{} for {}..{}
ERROR_git_repository_not_exists = Repository '{}' does not exist
ERROR_git_tag_not_exists = Tag '{}' does not exist
ERROR_git_release_branch_not_exists = Unrecognized branch '{}'. Available branches are: {}
ERROR_git_releaser_cannot_release = {} release failed because release {} already exists. overwrite = false; update = false
git.releaser.link.discussion = linking release {} with discussion {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
import org.kohsuke.github.GHRelease;
import org.kohsuke.github.GHReleaseUpdater;
import org.kohsuke.github.GHRepository;
import org.kohsuke.github.GHTag;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.file.Files;
import java.util.List;
Expand Down Expand Up @@ -115,19 +115,17 @@ protected boolean isTagInRemote(JReleaserContext context, String tagName) {
GHRepository repository = api.findRepository(github.getOwner(), github.getName());
if (null == repository) {
// remote does not exist!
throw new NullPointerException("BOOM!");
}
for (GHTag tag : repository.listTags()) {
if (tag.getName().equals(tagName)) {
return true;
}
throw new IllegalStateException(RB.$("ERROR_git_repository_not_exists", github.getCanonicalRepoName()));
}

return null != repository.getRef("tags/" + tagName);
} catch (FileNotFoundException e) {
// OK, it means tag does not exist
return false;
} catch (IOException e) {
context.getLogger().trace(e);
throw new JReleaserException(e);
}

return false;
}

@Override
Expand Down

0 comments on commit cf86c81

Please sign in to comment.