Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: throw error if no translations were found #824

Merged
merged 1 commit into from
Jul 18, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -281,14 +281,6 @@ public void act(Outputter out, PropertiesWithFiles pb, ProjectClient client) {
omittedFilesNoSources.add(allOmittedFilesNoSources);
}

if (!anyFileDownloaded.get()) {
if (project.getSkipUntranslatedFiles() || skipUntranslatedFiles.get()) {
out.println(WARNING.withIcon(RESOURCE_BUNDLE.getString("message.warning.no_file_to_download_skipuntranslated")));
} else {
out.println(WARNING.withIcon(RESOURCE_BUNDLE.getString("message.warning.no_file_to_download")));
}
}

if (!ignoreMatch && !plainView) {
totalOmittedFiles = totalOmittedFiles.entrySet().stream()
.filter(entry -> !entry.getValue().isEmpty())
Expand Down Expand Up @@ -322,6 +314,14 @@ public void act(Outputter out, PropertiesWithFiles pb, ProjectClient client) {
out.println(EMPTY.withIcon(RESOURCE_BUNDLE.getString("message.faq_link")));
}
}

if (!anyFileDownloaded.get()) {
if (project.getSkipUntranslatedFiles() || skipUntranslatedFiles.get()) {
throw new ExitCodeExceptionMapper.ValidationException(RESOURCE_BUNDLE.getString("message.warning.no_file_to_download_skipuntranslated"));
} else {
throw new ExitCodeExceptionMapper.ValidationException(WARNING.withIcon(RESOURCE_BUNDLE.getString("message.warning.no_file_to_download")));
}
}
} catch (ProjectBuildFailedException e) {
out.println(WARNING.withIcon(RESOURCE_BUNDLE.getString("message.translations_build_unsuccessful")));
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.crowdin.cli.commands.NewAction;
import com.crowdin.cli.commands.Outputter;
import com.crowdin.cli.commands.functionality.FilesInterface;
import com.crowdin.cli.commands.picocli.ExitCodeExceptionMapper;
import com.crowdin.cli.properties.PropertiesWithFiles;
import com.crowdin.cli.properties.NewPropertiesWithFilesUtilBuilder;
import com.crowdin.cli.properties.helper.FileHelperTest;
Expand Down Expand Up @@ -87,7 +88,8 @@ public void testEmptyProject() throws IOException, ResponseException {

NewAction<PropertiesWithFiles, ProjectClient> action =
new DownloadAction(files, false, null, null, false, null, false, false, false, false, false);
action.act(Outputter.getDefault(), pb, client);

assertThrows(ExitCodeExceptionMapper.ValidationException.class, () -> action.act(Outputter.getDefault(), pb, client));

verify(client).downloadFullProject(null);
verify(client).startBuildingTranslation(eq(buildProjectTranslationRequest));
Expand Down
Loading