mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[vcs-log] check that commit message margins are actually enabled
This commit is contained in:
committed by
Julia Beliaeva
parent
7587afb39e
commit
3b27fff9af
@@ -77,7 +77,7 @@ public class CommitMessageInspectionProfile extends InspectionProfileImpl
|
||||
return getTool(SubjectLimitInspection.class).RIGHT_MARGIN;
|
||||
}
|
||||
|
||||
private <T extends LocalInspectionTool> T getTool(Class<T> aClass) {
|
||||
public <T extends LocalInspectionTool> T getTool(Class<T> aClass) {
|
||||
InspectionToolWrapper tool = getInspectionTool(InspectionProfileEntry.getShortName(aClass.getSimpleName()), myProject);
|
||||
//noinspection unchecked
|
||||
return (T)ObjectUtils.notNull(tool).getTool();
|
||||
|
||||
+22
-5
@@ -1,6 +1,7 @@
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.vcs.log.ui.frame;
|
||||
|
||||
import com.intellij.codeInspection.ex.Tools;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vcs.ui.FontUtil;
|
||||
@@ -11,7 +12,9 @@ import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.Convertor;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import com.intellij.util.text.DateFormatUtil;
|
||||
import com.intellij.vcs.commit.BaseCommitMessageInspection;
|
||||
import com.intellij.vcs.commit.CommitMessageInspectionProfile;
|
||||
import com.intellij.vcs.commit.SubjectLimitInspection;
|
||||
import com.intellij.vcs.log.CommitId;
|
||||
import com.intellij.vcs.log.VcsFullCommitDetails;
|
||||
import com.intellij.vcs.log.VcsUser;
|
||||
@@ -112,11 +115,13 @@ public class CommitPresentationUtil {
|
||||
return formatText(project, fullMessage, font, font.getStyle(), convertor);
|
||||
}
|
||||
|
||||
int margin = CommitMessageInspectionProfile.getSubjectRightMargin(project);
|
||||
if (subject.length() > margin) {
|
||||
String tail = subject.substring(margin - ELLIPSIS.length());
|
||||
subject = subject.substring(0, margin - ELLIPSIS.length()) + ELLIPSIS;
|
||||
description = "\n\n" + ELLIPSIS + tail + description;
|
||||
if (isSubjectMarginEnabled(project)) {
|
||||
int margin = CommitMessageInspectionProfile.getSubjectRightMargin(project);
|
||||
if (subject.length() > margin) {
|
||||
String tail = subject.substring(margin - ELLIPSIS.length());
|
||||
subject = subject.substring(0, margin - ELLIPSIS.length()) + ELLIPSIS;
|
||||
description = "\n\n" + ELLIPSIS + tail + description;
|
||||
}
|
||||
}
|
||||
|
||||
return "<b>" +
|
||||
@@ -125,6 +130,18 @@ public class CommitPresentationUtil {
|
||||
formatText(project, description, font, font.getStyle(), convertor);
|
||||
}
|
||||
|
||||
public static boolean isSubjectMarginEnabled(@NotNull Project project) {
|
||||
return isInspectionEnabled(project, SubjectLimitInspection.class);
|
||||
}
|
||||
|
||||
private static <T extends BaseCommitMessageInspection> boolean isInspectionEnabled(@NotNull Project project,
|
||||
@NotNull Class<T> inspectionClass) {
|
||||
CommitMessageInspectionProfile inspectionProfile = CommitMessageInspectionProfile.getInstance(project);
|
||||
List<Tools> tools = inspectionProfile.getAllEnabledInspectionTools(project);
|
||||
T inspection = inspectionProfile.getTool(inspectionClass);
|
||||
return ContainerUtil.find(tools, tool -> tool.getTool().getTool().equals(inspection)) != null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String formatText(@NotNull Project project,
|
||||
@NotNull String text,
|
||||
|
||||
Reference in New Issue
Block a user