Search in sources :

Example 1 with Release

use of org.jreleaser.model.Release in project jreleaser by jreleaser.

the class ChangelogGeneratorUnitTest method doNecessaryMock.

private LogCommand doNecessaryMock(String effectiveTagName, String configuredTagName, ObjectId headId, boolean isSnapshot, List<Ref> tagRefs) throws GitAPIException, IOException {
    ListTagCommand listTagCommand = mock(ListTagCommand.class);
    JReleaserModel model = mock(JReleaserModel.class);
    when(context.getModel()).thenReturn(model);
    Project project = mock(Project.class);
    when(model.getProject()).thenReturn(project);
    Release release = mock(Release.class);
    when(model.getRelease()).thenReturn(release);
    VersionPattern versionPattern = mock(VersionPattern.class);
    when(versionPattern.getType()).thenReturn(VersionPattern.Type.SEMVER);
    when(project.versionPattern()).thenReturn(versionPattern);
    LogCommand logCommand = mock(LogCommand.class, RETURNS_DEEP_STUBS);
    when(git.log()).thenReturn(logCommand);
    when(listTagCommand.call()).thenReturn(tagRefs);
    when(git.tagList()).thenReturn(listTagCommand);
    GitService gitService = mock(GitService.class, RETURNS_DEEP_STUBS);
    when(release.getGitService()).thenReturn(gitService);
    when(gitService.getEffectiveTagName(any())).thenReturn(effectiveTagName);
    when(gitService.getConfiguredTagName()).thenReturn(configuredTagName);
    when(git.getRepository().resolve(Constants.HEAD)).thenReturn(headId);
    doReturn(SemVer.of(effectiveTagName)).when(project).version();
    when(context.getModel().getProject().isSnapshot()).thenReturn(isSnapshot);
    return logCommand;
}
Also used : Project(org.jreleaser.model.Project) VersionPattern(org.jreleaser.model.VersionPattern) LogCommand(org.eclipse.jgit.api.LogCommand) JReleaserModel(org.jreleaser.model.JReleaserModel) GitService(org.jreleaser.model.GitService) ListTagCommand(org.eclipse.jgit.api.ListTagCommand) Release(org.jreleaser.model.Release)

Example 2 with Release

use of org.jreleaser.model.Release in project jreleaser by jreleaser.

the class ReleaseValidator method validateRelease.

public static void validateRelease(JReleaserContext context, JReleaserContext.Mode mode, Errors errors) {
    context.getLogger().debug("release");
    Release release = context.getModel().getRelease();
    int count = 0;
    if (validateGithub(context, mode, release.getGithub(), errors))
        count++;
    if (validateGitlab(context, mode, release.getGitlab(), errors))
        count++;
    if (validateGitea(context, mode, release.getGitea(), errors))
        count++;
    if (validateCodeberg(context, mode, release.getCodeberg(), errors))
        count++;
    if (validateGeneric(context, mode, release.getGeneric(), errors))
        count++;
    if (mode != JReleaserContext.Mode.ASSEMBLE) {
        if (0 == count) {
            errors.configuration(RB.$("validation_release_no_providers"));
            return;
        }
        if (count > 1) {
            errors.configuration(RB.$("validation_release_requirement", "release.[github|gitlab|gitea|codeberg|generic]"));
        }
    }
}
Also used : Release(org.jreleaser.model.Release)

Aggregations

Release (org.jreleaser.model.Release)2 ListTagCommand (org.eclipse.jgit.api.ListTagCommand)1 LogCommand (org.eclipse.jgit.api.LogCommand)1 GitService (org.jreleaser.model.GitService)1 JReleaserModel (org.jreleaser.model.JReleaserModel)1 Project (org.jreleaser.model.Project)1 VersionPattern (org.jreleaser.model.VersionPattern)1