public static @NlsSafe @NotNull String truncateBranchName(@NotNull Project project, @NotNull @NlsSafe String branchName,
                                                            int maxBranchNameLength, int suffixLength, int delta) {
    int branchNameLength = branchName.length();

    if (branchNameLength <= maxBranchNameLength + delta) {
      return branchName;
    }

    IssueNavigationConfiguration issueNavigationConfiguration = IssueNavigationConfiguration.getInstance(project);
    List<IssueNavigationConfiguration.LinkMatch> issueMatches = issueNavigationConfiguration.findIssueLinks(branchName);
    int affectedMaxBranchNameLength = maxBranchNameLength - StringUtil.ELLIPSIS.length();
    if (!issueMatches.isEmpty()) {
      // never truncate the first occurrence of the issue id
      IssueNavigationConfiguration.LinkMatch firstMatch = issueMatches.get(0);
      TextRange firstMatchRange = firstMatch.getRange();
      return truncateAndSaveIssueId(firstMatchRange, branchName, affectedMaxBranchNameLength, suffixLength, delta);
    }

    if (affectedMaxBranchNameLength - suffixLength - StringUtil.ELLIPSIS.length() < 0) {
      return branchName;
    }

    return StringUtil.shortenTextWithEllipsis(branchName, affectedMaxBranchNameLength, suffixLength, true);
  }
public static @NlsSafe @NotNull String truncateBranchName(@NotNull Project project, @NotNull @NlsSafe String branchName,
                                                            int maxBranchNameLength, int suffixLength, int delta)