From: Viktor Vorona Date: Tue, 23 Apr 2024 12:47:22 +0000 (+0200) Subject: SONAR-22049 Align branch-like helper X-Git-Tag: 10.6.0.92116~172 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a5599ff112362c822a669d965c6a9fc85d633e37;p=sonarqube.git SONAR-22049 Align branch-like helper --- diff --git a/server/sonar-web/src/main/js/app/components/nav/component/Menu.tsx b/server/sonar-web/src/main/js/app/components/nav/component/Menu.tsx index a7148dd7c22..8718aea3a99 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/Menu.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/Menu.tsx @@ -28,10 +28,11 @@ import { import * as React from 'react'; import { useLocation } from '../../../../components/hoc/withRouter'; import { DEFAULT_ISSUES_QUERY } from '../../../../components/shared/utils'; -import { getBranchLikeQuery, isPullRequest } from '../../../../helpers/branch-like'; +import { isPullRequest } from '../../../../helpers/branch-like'; import { hasMessage, translate, translateWithParameters } from '../../../../helpers/l10n'; import { getPortfolioUrl, getProjectQueryUrl } from '../../../../helpers/urls'; import { useBranchesQuery } from '../../../../queries/branch'; +import { getBranchLikeQuery } from '../../../../sonar-aligned/helpers/branch-like'; import { BranchParameters } from '../../../../types/branch-like'; import { ComponentQualifier, diff --git a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/Menu.tsx b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/Menu.tsx index 60de85aa38e..9748cb935d6 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/Menu.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/Menu.tsx @@ -22,13 +22,13 @@ import * as React from 'react'; import { Router, withRouter } from '../../../../../components/hoc/withRouter'; import { getBrancheLikesAsTree, - isBranch, isPullRequest, isSameBranchLike, } from '../../../../../helpers/branch-like'; import { KeyboardKeys } from '../../../../../helpers/keycodes'; import { translate } from '../../../../../helpers/l10n'; import { getBranchLikeUrl, queryToSearch } from '../../../../../helpers/urls'; +import { isBranch } from '../../../../../sonar-aligned/helpers/branch-like'; import { BranchLike, BranchLikeTree } from '../../../../../types/branch-like'; import { ComponentQualifier } from '../../../../../types/component'; import { Component } from '../../../../../types/types'; diff --git a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/MenuItem.tsx b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/MenuItem.tsx index 057a7f41d08..d3ce663a6e9 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/MenuItem.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/MenuItem.tsx @@ -21,8 +21,9 @@ import classNames from 'classnames'; import { Badge, ItemButton, TextBold, TextMuted } from 'design-system'; import * as React from 'react'; import BranchLikeIcon from '../../../../../components/icon-mappers/BranchLikeIcon'; -import { getBranchLikeDisplayName, isMainBranch } from '../../../../../helpers/branch-like'; +import { getBranchLikeDisplayName } from '../../../../../helpers/branch-like'; import { translate } from '../../../../../helpers/l10n'; +import { isMainBranch } from '../../../../../sonar-aligned/helpers/branch-like'; import { BranchLike } from '../../../../../types/branch-like'; import QualityGateStatus from './QualityGateStatus'; diff --git a/server/sonar-web/src/main/js/app/components/nav/component/utils.ts b/server/sonar-web/src/main/js/app/components/nav/component/utils.ts index abbb2e6acd9..730abbc8c4d 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/utils.ts +++ b/server/sonar-web/src/main/js/app/components/nav/component/utils.ts @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { isBranch } from '../../../../helpers/branch-like'; +import { isBranch } from '../../../../sonar-aligned/helpers/branch-like'; import { BranchLike } from '../../../../types/branch-like'; import { ComponentQualifier } from '../../../../types/component'; import { Component } from '../../../../types/types'; diff --git a/server/sonar-web/src/main/js/apps/code/components/ComponentName.tsx b/server/sonar-web/src/main/js/apps/code/components/ComponentName.tsx index 5680c74944d..ddf29edee55 100644 --- a/server/sonar-web/src/main/js/apps/code/components/ComponentName.tsx +++ b/server/sonar-web/src/main/js/apps/code/components/ComponentName.tsx @@ -21,10 +21,10 @@ import { LinkHighlight, LinkStandalone } from '@sonarsource/echoes-react'; import { Badge, BranchIcon, LightLabel, Note, QualifierIcon } from 'design-system'; import * as React from 'react'; -import { getBranchLikeQuery } from '../../../helpers/branch-like'; import { translate } from '../../../helpers/l10n'; import { isDefined } from '../../../helpers/types'; import { CodeScope, getComponentOverviewUrl, queryToSearch } from '../../../helpers/urls'; +import { getBranchLikeQuery } from '../../../sonar-aligned/helpers/branch-like'; import { BranchLike } from '../../../types/branch-like'; import { ComponentQualifier, diff --git a/server/sonar-web/src/main/js/apps/code/components/Search.tsx b/server/sonar-web/src/main/js/apps/code/components/Search.tsx index 242e8bf0a80..18586350462 100644 --- a/server/sonar-web/src/main/js/apps/code/components/Search.tsx +++ b/server/sonar-web/src/main/js/apps/code/components/Search.tsx @@ -23,9 +23,9 @@ import { isEmpty, omit } from 'lodash'; import * as React from 'react'; import { getTree } from '../../../api/components'; import { Location, Router, withRouter } from '../../../components/hoc/withRouter'; -import { getBranchLikeQuery } from '../../../helpers/branch-like'; import { KeyboardKeys } from '../../../helpers/keycodes'; import { translate } from '../../../helpers/l10n'; +import { getBranchLikeQuery } from '../../../sonar-aligned/helpers/branch-like'; import { BranchLike } from '../../../types/branch-like'; import { ComponentQualifier, isPortfolioLike, isView } from '../../../types/component'; import { ComponentMeasure } from '../../../types/types'; diff --git a/server/sonar-web/src/main/js/apps/code/utils.ts b/server/sonar-web/src/main/js/apps/code/utils.ts index 207b1f87200..b9518349bb7 100644 --- a/server/sonar-web/src/main/js/apps/code/utils.ts +++ b/server/sonar-web/src/main/js/apps/code/utils.ts @@ -18,8 +18,9 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { getBreadcrumbs, getChildren, getComponent, getComponentData } from '../../api/components'; -import { getBranchLikeQuery, isPullRequest } from '../../helpers/branch-like'; +import { isPullRequest } from '../../helpers/branch-like'; import { CCT_SOFTWARE_QUALITY_METRICS, OLD_TAXONOMY_METRICS } from '../../helpers/constants'; +import { getBranchLikeQuery } from '../../sonar-aligned/helpers/branch-like'; import { BranchLike } from '../../types/branch-like'; import { ComponentQualifier, isPortfolioLike } from '../../types/component'; import { MetricKey } from '../../types/metrics'; diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/ComponentMeasuresApp.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/ComponentMeasuresApp.tsx index 91285196104..4df28d0b794 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/ComponentMeasuresApp.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/components/ComponentMeasuresApp.tsx @@ -39,11 +39,12 @@ import { Location, Router, withRouter } from '../../../components/hoc/withRouter import { enhanceMeasure } from '../../../components/measure/utils'; import '../../../components/search-navigator.css'; import AnalysisMissingInfoMessage from '../../../components/shared/AnalysisMissingInfoMessage'; -import { getBranchLikeQuery, isPullRequest, isSameBranchLike } from '../../../helpers/branch-like'; +import { isPullRequest, isSameBranchLike } from '../../../helpers/branch-like'; import { translate } from '../../../helpers/l10n'; import { areLeakAndOverallCCTMeasuresComputed } from '../../../helpers/measures'; import { WithBranchLikesProps, useBranchesQuery } from '../../../queries/branch'; import HelpTooltip from '../../../sonar-aligned/components/controls/HelpTooltip'; +import { getBranchLikeQuery } from '../../../sonar-aligned/helpers/branch-like'; import { ComponentQualifier, isPortfolioLike } from '../../../types/component'; import { MeasurePageView } from '../../../types/measures'; import { MetricKey } from '../../../types/metrics'; diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureContent.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureContent.tsx index 6c31247d817..617f2880c8e 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureContent.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureContent.tsx @@ -25,7 +25,7 @@ import SourceViewer from '../../../components/SourceViewer/SourceViewer'; import A11ySkipTarget from '../../../components/a11y/A11ySkipTarget'; import { Router } from '../../../components/hoc/withRouter'; import FilesCounter from '../../../components/ui/FilesCounter'; -import { getBranchLikeQuery, isSameBranchLike } from '../../../helpers/branch-like'; +import { isSameBranchLike } from '../../../helpers/branch-like'; import { getComponentMeasureUniqueKey } from '../../../helpers/component'; import { KeyboardKeys } from '../../../helpers/keycodes'; import { translate } from '../../../helpers/l10n'; @@ -33,6 +33,7 @@ import { getCCTMeasureValue, isDiffMetric } from '../../../helpers/measures'; import { RequestData } from '../../../helpers/request'; import { isDefined } from '../../../helpers/types'; import { getProjectUrl } from '../../../helpers/urls'; +import { getBranchLikeQuery } from '../../../sonar-aligned/helpers/branch-like'; import { BranchLike } from '../../../types/branch-like'; import { isApplication, isFile, isView } from '../../../types/component'; import { MeasurePageView } from '../../../types/measures'; diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureOverview.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureOverview.tsx index ed3c13e329f..6d577b2f458 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureOverview.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureOverview.tsx @@ -22,7 +22,8 @@ import * as React from 'react'; import { getComponentLeaves } from '../../../api/components'; import SourceViewer from '../../../components/SourceViewer/SourceViewer'; import A11ySkipTarget from '../../../components/a11y/A11ySkipTarget'; -import { getBranchLikeQuery, isSameBranchLike } from '../../../helpers/branch-like'; +import { isSameBranchLike } from '../../../helpers/branch-like'; +import { getBranchLikeQuery } from '../../../sonar-aligned/helpers/branch-like'; import { BranchLike } from '../../../types/branch-like'; import { isFile } from '../../../types/component'; import { diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureOverviewContainer.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureOverviewContainer.tsx index 66faba26be9..91bbc9ac8bc 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureOverviewContainer.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureOverviewContainer.tsx @@ -20,8 +20,9 @@ import * as React from 'react'; import { getComponentShow } from '../../../api/components'; import { Router } from '../../../components/hoc/withRouter'; -import { getBranchLikeQuery, isSameBranchLike } from '../../../helpers/branch-like'; +import { isSameBranchLike } from '../../../helpers/branch-like'; import { getProjectUrl } from '../../../helpers/urls'; +import { getBranchLikeQuery } from '../../../sonar-aligned/helpers/branch-like'; import { BranchLike } from '../../../types/branch-like'; import { isView } from '../../../types/component'; import { diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/MeasuresBreadcrumbs.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/MeasuresBreadcrumbs.tsx index 41a91b139a0..9a6797956b5 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/MeasuresBreadcrumbs.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/components/MeasuresBreadcrumbs.tsx @@ -21,10 +21,11 @@ import classNames from 'classnames'; import { Breadcrumbs, ClipboardIconButton, HoverLink } from 'design-system'; import * as React from 'react'; import { getBreadcrumbs } from '../../../api/components'; -import { getBranchLikeQuery, isSameBranchLike } from '../../../helpers/branch-like'; +import { isSameBranchLike } from '../../../helpers/branch-like'; import { KeyboardKeys } from '../../../helpers/keycodes'; import { translate } from '../../../helpers/l10n'; import { collapsePath, limitComponentName } from '../../../helpers/path'; +import { getBranchLikeQuery } from '../../../sonar-aligned/helpers/branch-like'; import { BranchLike } from '../../../types/branch-like'; import { ComponentQualifier, isProject } from '../../../types/component'; import { ComponentMeasure, ComponentMeasureIntern } from '../../../types/types'; diff --git a/server/sonar-web/src/main/js/apps/component-measures/utils.ts b/server/sonar-web/src/main/js/apps/component-measures/utils.ts index 558ad1bf8fa..6e0211e3177 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/utils.ts +++ b/server/sonar-web/src/main/js/apps/component-measures/utils.ts @@ -19,7 +19,7 @@ */ import { groupBy, memoize, sortBy, toPairs } from 'lodash'; import { enhanceMeasure } from '../../components/measure/utils'; -import { isBranch, isPullRequest } from '../../helpers/branch-like'; +import { isPullRequest } from '../../helpers/branch-like'; import { CCT_SOFTWARE_QUALITY_METRICS, HIDDEN_METRICS, @@ -42,6 +42,7 @@ import { parseAsString, serializeString, } from '../../helpers/query'; +import { isBranch } from '../../sonar-aligned/helpers/branch-like'; import { BranchLike } from '../../types/branch-like'; import { ComponentQualifier } from '../../types/component'; import { Domain, MeasurePageView } from '../../types/measures'; diff --git a/server/sonar-web/src/main/js/apps/issues/components/IssueHeader.tsx b/server/sonar-web/src/main/js/apps/issues/components/IssueHeader.tsx index 2ddcaf5f436..28840443a67 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/IssueHeader.tsx +++ b/server/sonar-web/src/main/js/apps/issues/components/IssueHeader.tsx @@ -32,12 +32,12 @@ import { setIssueAssignee } from '../../../api/issues'; import { updateIssue } from '../../../components/issue/actions'; import IssueActionsBar from '../../../components/issue/components/IssueActionsBar'; import { WorkspaceContext } from '../../../components/workspace/context'; -import { getBranchLikeQuery } from '../../../helpers/branch-like'; import { isInput, isShortcut } from '../../../helpers/keyboardEventHelpers'; import { KeyboardKeys } from '../../../helpers/keycodes'; import { translate } from '../../../helpers/l10n'; import { getKeyboardShortcutEnabled } from '../../../helpers/preferences'; import { getComponentIssuesUrl, getPathUrlAsString, getRuleUrl } from '../../../helpers/urls'; +import { getBranchLikeQuery } from '../../../sonar-aligned/helpers/branch-like'; import { BranchLike } from '../../../types/branch-like'; import { IssueActions, IssueType } from '../../../types/issues'; import { Issue, RuleDetails } from '../../../types/types'; diff --git a/server/sonar-web/src/main/js/apps/issues/components/IssuesApp.tsx b/server/sonar-web/src/main/js/apps/issues/components/IssuesApp.tsx index 0f8307aa4a8..e3e33e2c654 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/IssuesApp.tsx +++ b/server/sonar-web/src/main/js/apps/issues/components/IssuesApp.tsx @@ -52,12 +52,7 @@ import { Location, Router, withRouter } from '../../../components/hoc/withRouter import IssueTabViewer from '../../../components/rules/IssueTabViewer'; import '../../../components/search-navigator.css'; import { DEFAULT_ISSUES_QUERY } from '../../../components/shared/utils'; -import { - fillBranchLike, - getBranchLikeQuery, - isPullRequest, - isSameBranchLike, -} from '../../../helpers/branch-like'; +import { fillBranchLike, isPullRequest, isSameBranchLike } from '../../../helpers/branch-like'; import handleRequiredAuthentication from '../../../helpers/handleRequiredAuthentication'; import { parseIssueFromResponse } from '../../../helpers/issues'; import { isInput, isShortcut } from '../../../helpers/keyboardEventHelpers'; @@ -65,6 +60,7 @@ import { KeyboardKeys } from '../../../helpers/keycodes'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { serializeDate } from '../../../helpers/query'; import { withBranchLikes } from '../../../queries/branch'; +import { getBranchLikeQuery } from '../../../sonar-aligned/helpers/branch-like'; import { BranchLike } from '../../../types/branch-like'; import { ComponentQualifier, isPortfolioLike, isProject } from '../../../types/component'; import { diff --git a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/ComponentSourceSnippetGroupViewer.tsx b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/ComponentSourceSnippetGroupViewer.tsx index be83012b577..a51ee3debec 100644 --- a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/ComponentSourceSnippetGroupViewer.tsx +++ b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/ComponentSourceSnippetGroupViewer.tsx @@ -25,8 +25,8 @@ import { FormattedMessage } from 'react-intl'; import { getSources } from '../../../api/components'; import getCoverageStatus from '../../../components/SourceViewer/helpers/getCoverageStatus'; import { locationsByLine } from '../../../components/SourceViewer/helpers/indexing'; -import { getBranchLikeQuery } from '../../../helpers/branch-like'; import { translate } from '../../../helpers/l10n'; +import { getBranchLikeQuery } from '../../../sonar-aligned/helpers/branch-like'; import { BranchLike } from '../../../types/branch-like'; import { isFile } from '../../../types/component'; import { IssueDeprecatedStatus } from '../../../types/issues'; diff --git a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/CrossComponentSourceViewer.tsx b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/CrossComponentSourceViewer.tsx index 3e44f7a4be5..f212424c609 100644 --- a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/CrossComponentSourceViewer.tsx +++ b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/CrossComponentSourceViewer.tsx @@ -36,9 +36,9 @@ import { issuesByComponentAndLine, } from '../../../components/SourceViewer/helpers/indexing'; import { WorkspaceContext } from '../../../components/workspace/context'; -import { getBranchLikeQuery } from '../../../helpers/branch-like'; import { translate } from '../../../helpers/l10n'; import { HttpStatus } from '../../../helpers/request'; +import { getBranchLikeQuery } from '../../../sonar-aligned/helpers/branch-like'; import { throwGlobalError } from '../../../sonar-aligned/helpers/error'; import { BranchLike } from '../../../types/branch-like'; import { isFile } from '../../../types/component'; diff --git a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/IssueSourceViewerHeader.tsx b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/IssueSourceViewerHeader.tsx index 9b2b3c398bb..04e71337c92 100644 --- a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/IssueSourceViewerHeader.tsx +++ b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/IssueSourceViewerHeader.tsx @@ -35,11 +35,12 @@ import * as React from 'react'; import { ComponentContext } from '../../../app/components/componentContext/ComponentContext'; import { useCurrentUser } from '../../../app/components/current-user/CurrentUserContext'; import { DEFAULT_ISSUES_QUERY } from '../../../components/shared/utils'; -import { getBranchLikeQuery, isBranch, isPullRequest } from '../../../helpers/branch-like'; +import { isPullRequest } from '../../../helpers/branch-like'; import { translate } from '../../../helpers/l10n'; import { collapsedDirFromPath, fileFromPath } from '../../../helpers/path'; import { getBranchLikeUrl, getComponentIssuesUrl } from '../../../helpers/urls'; import { useBranchesQuery } from '../../../queries/branch'; +import { getBranchLikeQuery, isBranch } from '../../../sonar-aligned/helpers/branch-like'; import { ComponentQualifier } from '../../../types/component'; import { SourceViewerFile } from '../../../types/types'; import { isLoggedIn } from '../../../types/users'; diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/DirectoryFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/DirectoryFacet.tsx index bd03d07840d..354f678b77d 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/DirectoryFacet.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/DirectoryFacet.tsx @@ -21,10 +21,10 @@ import { QualifierIcon } from 'design-system'; import { omit } from 'lodash'; import * as React from 'react'; import { getDirectories } from '../../../api/components'; -import { getBranchLikeQuery } from '../../../helpers/branch-like'; import { translate } from '../../../helpers/l10n'; import { collapsePath } from '../../../helpers/path'; import { highlightTerm } from '../../../helpers/search'; +import { getBranchLikeQuery } from '../../../sonar-aligned/helpers/branch-like'; import { BranchLike } from '../../../types/branch-like'; import { TreeComponentWithPath } from '../../../types/component'; import { Facet } from '../../../types/issues'; diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/FileFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/FileFacet.tsx index 001e049cf71..e6dd87f1e23 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/FileFacet.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/FileFacet.tsx @@ -21,11 +21,11 @@ import { QualifierIcon } from 'design-system'; import { omit } from 'lodash'; import * as React from 'react'; import { getFiles } from '../../../api/components'; -import { getBranchLikeQuery } from '../../../helpers/branch-like'; import { translate } from '../../../helpers/l10n'; import { collapsePath, splitPath } from '../../../helpers/path'; import { highlightTerm } from '../../../helpers/search'; import { isDefined } from '../../../helpers/types'; +import { getBranchLikeQuery } from '../../../sonar-aligned/helpers/branch-like'; import { BranchLike } from '../../../types/branch-like'; import { TreeComponentWithPath } from '../../../types/component'; import { Facet } from '../../../types/issues'; diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.tsx index fc6ee8e722e..4cc16fa5f83 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.tsx @@ -21,8 +21,9 @@ import { BasicSeparator, FlagMessage, Link } from 'design-system'; import * as React from 'react'; import { FormattedMessage } from 'react-intl'; import withAppStateContext from '../../../app/components/app-state/withAppStateContext'; -import { isBranch, isPullRequest } from '../../../helpers/branch-like'; +import { isPullRequest } from '../../../helpers/branch-like'; import { translate } from '../../../helpers/l10n'; +import { isBranch } from '../../../sonar-aligned/helpers/branch-like'; import { AppState } from '../../../types/appstate'; import { BranchLike } from '../../../types/branch-like'; import { diff --git a/server/sonar-web/src/main/js/apps/overview/branches/ApplicationNonCaycProjectWarning.tsx b/server/sonar-web/src/main/js/apps/overview/branches/ApplicationNonCaycProjectWarning.tsx index 274bb6e8e75..9f305cb70dd 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/ApplicationNonCaycProjectWarning.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/ApplicationNonCaycProjectWarning.tsx @@ -19,10 +19,10 @@ */ import { Card, FlagMessage, Link } from 'design-system'; import * as React from 'react'; -import { getBranchLikeQuery } from '../../../helpers/branch-like'; import { useDocUrl } from '../../../helpers/docs'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { getProjectQueryUrl } from '../../../helpers/urls'; +import { getBranchLikeQuery } from '../../../sonar-aligned/helpers/branch-like'; import { QualityGateStatus } from '../../../types/quality-gates'; interface Props { diff --git a/server/sonar-web/src/main/js/apps/overview/branches/BranchOverview.tsx b/server/sonar-web/src/main/js/apps/overview/branches/BranchOverview.tsx index 89f06d9c6ec..587891faa43 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/BranchOverview.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/BranchOverview.tsx @@ -34,11 +34,7 @@ import { getHistoryMetrics, saveActivityGraph, } from '../../../components/activity-graph/utils'; -import { - getBranchLikeDisplayName, - getBranchLikeQuery, - isMainBranch, -} from '../../../helpers/branch-like'; +import { getBranchLikeDisplayName } from '../../../helpers/branch-like'; import { parseDate, toISO8601WithOffsetString } from '../../../helpers/dates'; import { enhanceConditionWithMeasure, enhanceMeasuresWithMetrics } from '../../../helpers/measures'; import { @@ -46,6 +42,7 @@ import { extractStatusConditionsFromProjectStatus, } from '../../../helpers/qualityGates'; import { isDefined } from '../../../helpers/types'; +import { getBranchLikeQuery, isMainBranch } from '../../../sonar-aligned/helpers/branch-like'; import { ApplicationPeriod } from '../../../types/application'; import { Branch, BranchLike } from '../../../types/branch-like'; import { ComponentQualifier } from '../../../types/component'; diff --git a/server/sonar-web/src/main/js/apps/overview/branches/MeasuresPanelNoNewCode.tsx b/server/sonar-web/src/main/js/apps/overview/branches/MeasuresPanelNoNewCode.tsx index 104eaf2ec42..3bda1c17337 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/MeasuresPanelNoNewCode.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/MeasuresPanelNoNewCode.tsx @@ -24,9 +24,9 @@ import * as React from 'react'; import { FormattedMessage } from 'react-intl'; import DocumentationLink from '../../../components/common/DocumentationLink'; import { Image } from '../../../components/common/Image'; -import { getBranchLikeQuery } from '../../../helpers/branch-like'; import { translate } from '../../../helpers/l10n'; import { CodeScope, queryToSearch } from '../../../helpers/urls'; +import { getBranchLikeQuery } from '../../../sonar-aligned/helpers/branch-like'; import { Branch } from '../../../types/branch-like'; import { ComponentQualifier } from '../../../types/component'; import { NewCodeDefinitionType } from '../../../types/new-code-definition'; diff --git a/server/sonar-web/src/main/js/apps/overview/branches/NewCodeMeasuresPanel.tsx b/server/sonar-web/src/main/js/apps/overview/branches/NewCodeMeasuresPanel.tsx index 05385c6a66a..94aae3bb987 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/NewCodeMeasuresPanel.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/NewCodeMeasuresPanel.tsx @@ -34,13 +34,13 @@ import React from 'react'; import { useIntl } from 'react-intl'; import { getLeakValue } from '../../../components/measure/utils'; import { DEFAULT_ISSUES_QUERY } from '../../../components/shared/utils'; -import { getBranchLikeQuery } from '../../../helpers/branch-like'; import { findMeasure, formatMeasure, formatRating } from '../../../helpers/measures'; import { CodeScope, getComponentIssuesUrl, getComponentSecurityHotspotsUrl, } from '../../../helpers/urls'; +import { getBranchLikeQuery } from '../../../sonar-aligned/helpers/branch-like'; import { Branch } from '../../../types/branch-like'; import { isApplication } from '../../../types/component'; import { IssueStatus } from '../../../types/issues'; diff --git a/server/sonar-web/src/main/js/apps/overview/branches/NoCodeWarning.tsx b/server/sonar-web/src/main/js/apps/overview/branches/NoCodeWarning.tsx index 350209b6934..87b684ac607 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/NoCodeWarning.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/NoCodeWarning.tsx @@ -19,8 +19,9 @@ */ import { FlagMessage } from 'design-system'; import * as React from 'react'; -import { getBranchLikeDisplayName, isMainBranch } from '../../../helpers/branch-like'; +import { getBranchLikeDisplayName } from '../../../helpers/branch-like'; import { translate, translateWithParameters } from '../../../helpers/l10n'; +import { isMainBranch } from '../../../sonar-aligned/helpers/branch-like'; import { BranchLike } from '../../../types/branch-like'; import { ComponentQualifier } from '../../../types/component'; import { MetricKey } from '../../../types/metrics'; diff --git a/server/sonar-web/src/main/js/apps/overview/branches/OverallCodeMeasuresPanel.tsx b/server/sonar-web/src/main/js/apps/overview/branches/OverallCodeMeasuresPanel.tsx index b0f131aac71..a594bfbf0ed 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/OverallCodeMeasuresPanel.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/OverallCodeMeasuresPanel.tsx @@ -26,13 +26,13 @@ import { } from 'design-system'; import * as React from 'react'; import { useIntl } from 'react-intl'; -import { getBranchLikeQuery } from '../../../helpers/branch-like'; import { findMeasure, formatMeasure, formatRating } from '../../../helpers/measures'; import { CodeScope, getComponentIssuesUrl, getComponentSecurityHotspotsUrl, } from '../../../helpers/urls'; +import { getBranchLikeQuery } from '../../../sonar-aligned/helpers/branch-like'; import { Branch } from '../../../types/branch-like'; import { SoftwareQuality } from '../../../types/clean-code-taxonomy'; import { isApplication } from '../../../types/component'; diff --git a/server/sonar-web/src/main/js/apps/overview/branches/QualityGateCondition.tsx b/server/sonar-web/src/main/js/apps/overview/branches/QualityGateCondition.tsx index a3dd605d790..d07769a9c80 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/QualityGateCondition.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/QualityGateCondition.tsx @@ -27,7 +27,6 @@ import { isIssueMeasure, propsToIssueParams, } from '../../../components/shared/utils'; -import { getBranchLikeQuery } from '../../../helpers/branch-like'; import { translate } from '../../../helpers/l10n'; import { formatMeasure, isDiffMetric, localizeMetric } from '../../../helpers/measures'; import { getOperatorLabel } from '../../../helpers/qualityGates'; @@ -36,6 +35,7 @@ import { getComponentIssuesUrl, getComponentSecurityHotspotsUrl, } from '../../../helpers/urls'; +import { getBranchLikeQuery } from '../../../sonar-aligned/helpers/branch-like'; import { BranchLike } from '../../../types/branch-like'; import { IssueType } from '../../../types/issues'; import { MetricKey, MetricType } from '../../../types/metrics'; diff --git a/server/sonar-web/src/main/js/apps/overview/branches/QualityGateSimplifiedCondition.tsx b/server/sonar-web/src/main/js/apps/overview/branches/QualityGateSimplifiedCondition.tsx index d4172a7110a..4c1b3e9ba6d 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/QualityGateSimplifiedCondition.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/QualityGateSimplifiedCondition.tsx @@ -20,10 +20,10 @@ import { Highlight, LinkBox } from 'design-system'; import * as React from 'react'; import { propsToIssueParams } from '../../../components/shared/utils'; -import { getBranchLikeQuery } from '../../../helpers/branch-like'; import { translate } from '../../../helpers/l10n'; import { formatMeasure, isDiffMetric, localizeMetric } from '../../../helpers/measures'; import { getComponentIssuesUrl } from '../../../helpers/urls'; +import { getBranchLikeQuery } from '../../../sonar-aligned/helpers/branch-like'; import { BranchLike } from '../../../types/branch-like'; import { MetricKey, MetricType } from '../../../types/metrics'; import { QualityGateStatusConditionEnhanced } from '../../../types/quality-gates'; diff --git a/server/sonar-web/src/main/js/apps/overview/components/AnalysisErrorMessage.tsx b/server/sonar-web/src/main/js/apps/overview/components/AnalysisErrorMessage.tsx index 8a42b1d2c97..6f843b731b6 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/AnalysisErrorMessage.tsx +++ b/server/sonar-web/src/main/js/apps/overview/components/AnalysisErrorMessage.tsx @@ -21,10 +21,11 @@ import { Link } from 'design-system'; import React from 'react'; import { FormattedMessage } from 'react-intl'; import { useLocation } from 'react-router-dom'; -import { isBranch, isMainBranch, isPullRequest } from '../../../helpers/branch-like'; +import { isPullRequest } from '../../../helpers/branch-like'; import { hasMessage, translate } from '../../../helpers/l10n'; import { getComponentBackgroundTaskUrl } from '../../../helpers/urls'; import { useBranchesQuery } from '../../../queries/branch'; +import { isBranch, isMainBranch } from '../../../sonar-aligned/helpers/branch-like'; import { BranchLike } from '../../../types/branch-like'; import { Task } from '../../../types/tasks'; import { Component } from '../../../types/types'; diff --git a/server/sonar-web/src/main/js/apps/overview/components/EmptyOverview.tsx b/server/sonar-web/src/main/js/apps/overview/components/EmptyOverview.tsx index 9c50ad01db4..585df52db9f 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/EmptyOverview.tsx +++ b/server/sonar-web/src/main/js/apps/overview/components/EmptyOverview.tsx @@ -23,11 +23,12 @@ import * as React from 'react'; import { Navigate } from 'react-router-dom'; import { getScannableProjects } from '../../../api/components'; import withCurrentUserContext from '../../../app/components/current-user/withCurrentUserContext'; -import { getBranchLikeDisplayName, isBranch, isMainBranch } from '../../../helpers/branch-like'; +import { getBranchLikeDisplayName } from '../../../helpers/branch-like'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { getProjectTutorialLocation } from '../../../helpers/urls'; import { hasGlobalPermission } from '../../../helpers/users'; import { useTaskForComponentQuery } from '../../../queries/component'; +import { isBranch, isMainBranch } from '../../../sonar-aligned/helpers/branch-like'; import { BranchLike } from '../../../types/branch-like'; import { ComponentQualifier } from '../../../types/component'; import { Permissions } from '../../../types/permissions'; diff --git a/server/sonar-web/src/main/js/apps/overview/pullRequests/BranchQualityGateConditions.tsx b/server/sonar-web/src/main/js/apps/overview/pullRequests/BranchQualityGateConditions.tsx index d3bfaa0bdad..9fe6fc70bb2 100644 --- a/server/sonar-web/src/main/js/apps/overview/pullRequests/BranchQualityGateConditions.tsx +++ b/server/sonar-web/src/main/js/apps/overview/pullRequests/BranchQualityGateConditions.tsx @@ -26,7 +26,6 @@ import { isIssueMeasure, propsToIssueParams, } from '../../../components/shared/utils'; -import { getBranchLikeQuery } from '../../../helpers/branch-like'; import { getLocalizedMetricName, translate } from '../../../helpers/l10n'; import { formatMeasure, getShortType, isDiffMetric } from '../../../helpers/measures'; import { @@ -34,6 +33,7 @@ import { getComponentIssuesUrl, getComponentSecurityHotspotsUrl, } from '../../../helpers/urls'; +import { getBranchLikeQuery } from '../../../sonar-aligned/helpers/branch-like'; import { BranchLike } from '../../../types/branch-like'; import { IssueType } from '../../../types/issues'; import { MetricType } from '../../../types/metrics'; diff --git a/server/sonar-web/src/main/js/apps/overview/pullRequests/IssueMeasuresCard.tsx b/server/sonar-web/src/main/js/apps/overview/pullRequests/IssueMeasuresCard.tsx index 0bca878392c..aaed573861a 100644 --- a/server/sonar-web/src/main/js/apps/overview/pullRequests/IssueMeasuresCard.tsx +++ b/server/sonar-web/src/main/js/apps/overview/pullRequests/IssueMeasuresCard.tsx @@ -35,9 +35,9 @@ import * as React from 'react'; import { useIntl } from 'react-intl'; import { getLeakValue } from '../../../components/measure/utils'; import { DEFAULT_ISSUES_QUERY } from '../../../components/shared/utils'; -import { getBranchLikeQuery } from '../../../helpers/branch-like'; import { findMeasure, formatMeasure } from '../../../helpers/measures'; import { getComponentIssuesUrl } from '../../../helpers/urls'; +import { getBranchLikeQuery } from '../../../sonar-aligned/helpers/branch-like'; import { PullRequest } from '../../../types/branch-like'; import { MetricKey, MetricType } from '../../../types/metrics'; import { QualityGateStatusConditionEnhanced } from '../../../types/quality-gates'; diff --git a/server/sonar-web/src/main/js/apps/overview/pullRequests/MeasuresCardPanel.tsx b/server/sonar-web/src/main/js/apps/overview/pullRequests/MeasuresCardPanel.tsx index b67e517ca95..ec42bcb0ce0 100644 --- a/server/sonar-web/src/main/js/apps/overview/pullRequests/MeasuresCardPanel.tsx +++ b/server/sonar-web/src/main/js/apps/overview/pullRequests/MeasuresCardPanel.tsx @@ -20,9 +20,9 @@ import classNames from 'classnames'; import * as React from 'react'; import { getLeakValue } from '../../../components/measure/utils'; -import { getBranchLikeQuery } from '../../../helpers/branch-like'; import { findMeasure } from '../../../helpers/measures'; import { getComponentDrilldownUrl, getComponentSecurityHotspotsUrl } from '../../../helpers/urls'; +import { getBranchLikeQuery } from '../../../sonar-aligned/helpers/branch-like'; import { PullRequest } from '../../../types/branch-like'; import { MetricKey } from '../../../types/metrics'; import { QualityGateStatusConditionEnhanced } from '../../../types/quality-gates'; diff --git a/server/sonar-web/src/main/js/apps/overview/pullRequests/PullRequestOverview.tsx b/server/sonar-web/src/main/js/apps/overview/pullRequests/PullRequestOverview.tsx index 476221616e7..f773f5abc5d 100644 --- a/server/sonar-web/src/main/js/apps/overview/pullRequests/PullRequestOverview.tsx +++ b/server/sonar-web/src/main/js/apps/overview/pullRequests/PullRequestOverview.tsx @@ -20,12 +20,12 @@ import { BasicSeparator, CenteredLayout, PageContentFontWrapper, Spinner } from 'design-system'; import { uniq } from 'lodash'; import * as React from 'react'; -import { getBranchLikeQuery } from '../../../helpers/branch-like'; import { enhanceConditionWithMeasure, enhanceMeasuresWithMetrics } from '../../../helpers/measures'; import { isDefined } from '../../../helpers/types'; import { useBranchStatusQuery } from '../../../queries/branch'; import { useComponentMeasuresWithMetricsQuery } from '../../../queries/component'; import { useComponentQualityGateQuery } from '../../../queries/quality-gates'; +import { getBranchLikeQuery } from '../../../sonar-aligned/helpers/branch-like'; import { PullRequest } from '../../../types/branch-like'; import { Component } from '../../../types/types'; import { AnalysisStatus } from '../components/AnalysisStatus'; diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityApp.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityApp.tsx index b0460c1475f..1a8801c8c99 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityApp.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityApp.tsx @@ -30,12 +30,12 @@ import { isCustomGraph, } from '../../../components/activity-graph/utils'; import { useLocation, useRouter } from '../../../components/hoc/withRouter'; -import { getBranchLikeQuery } from '../../../helpers/branch-like'; import { parseDate } from '../../../helpers/dates'; import useApplicationLeakQuery from '../../../queries/applications'; import { useBranchesQuery } from '../../../queries/branch'; import { useAllMeasuresHistoryQuery } from '../../../queries/measures'; import { useAllProjectAnalysesQuery } from '../../../queries/project-analyses'; +import { getBranchLikeQuery } from '../../../sonar-aligned/helpers/branch-like'; import { isApplication, isPortfolioLike, isProject } from '../../../types/component'; import { MetricKey } from '../../../types/metrics'; import { MeasureHistory, ParsedAnalysis } from '../../../types/project-activity'; diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeRow.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeRow.tsx index a4c5369ae30..bdf0ab3bce7 100644 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeRow.tsx +++ b/server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeRow.tsx @@ -30,13 +30,9 @@ import * as React from 'react'; import QualityGateStatus from '../../../app/components/nav/component/branch-like/QualityGateStatus'; import BranchLikeIcon from '../../../components/icon-mappers/BranchLikeIcon'; import DateFromNow from '../../../components/intl/DateFromNow'; -import { - getBranchLikeDisplayName, - isBranch, - isMainBranch, - isPullRequest, -} from '../../../helpers/branch-like'; +import { getBranchLikeDisplayName, isPullRequest } from '../../../helpers/branch-like'; import { translate, translateWithParameters } from '../../../helpers/l10n'; +import { isBranch, isMainBranch } from '../../../sonar-aligned/helpers/branch-like'; import { BranchLike } from '../../../types/branch-like'; import { Component } from '../../../types/types'; import BranchPurgeSetting from './BranchPurgeSetting'; diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeTabs.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeTabs.tsx index f7bd9e28061..c3f68f998e1 100644 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeTabs.tsx +++ b/server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeTabs.tsx @@ -22,15 +22,10 @@ import { IconGitBranch, IconPullrequest } from '@sonarsource/echoes-react'; import { ToggleButton, getTabId, getTabPanelId } from 'design-system'; import * as React from 'react'; import { useState } from 'react'; -import { - isBranch, - isMainBranch, - isPullRequest, - sortBranches, - sortPullRequests, -} from '../../../helpers/branch-like'; +import { isPullRequest, sortBranches, sortPullRequests } from '../../../helpers/branch-like'; import { translate } from '../../../helpers/l10n'; import { useBranchesQuery } from '../../../queries/branch'; +import { isBranch, isMainBranch } from '../../../sonar-aligned/helpers/branch-like'; import { Branch, BranchLike, PullRequest } from '../../../types/branch-like'; import { Component } from '../../../types/types'; import BranchLikeTable from './BranchLikeTable'; diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/BranchPurgeSetting.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/BranchPurgeSetting.tsx index ee171be74f5..b2787265400 100644 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/BranchPurgeSetting.tsx +++ b/server/sonar-web/src/main/js/apps/projectBranches/components/BranchPurgeSetting.tsx @@ -20,10 +20,10 @@ import { HelperHintIcon, Spinner, Switch } from 'design-system'; import * as React from 'react'; import { useEffect } from 'react'; -import { isMainBranch } from '../../../helpers/branch-like'; import { translate } from '../../../helpers/l10n'; import { useExcludeFromPurgeMutation } from '../../../queries/branch'; import HelpTooltip from '../../../sonar-aligned/components/controls/HelpTooltip'; +import { isMainBranch } from '../../../sonar-aligned/helpers/branch-like'; import { Branch } from '../../../types/branch-like'; import { Component } from '../../../types/types'; diff --git a/server/sonar-web/src/main/js/apps/projectInformation/badges/ProjectBadges.tsx b/server/sonar-web/src/main/js/apps/projectInformation/badges/ProjectBadges.tsx index d3ae3930556..bc0b86a8e3d 100644 --- a/server/sonar-web/src/main/js/apps/projectInformation/badges/ProjectBadges.tsx +++ b/server/sonar-web/src/main/js/apps/projectInformation/badges/ProjectBadges.tsx @@ -34,7 +34,6 @@ import { isEmpty } from 'lodash'; import * as React from 'react'; import { useState } from 'react'; import { Image } from '../../../components/common/Image'; -import { getBranchLikeQuery } from '../../../helpers/branch-like'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { localizeMetric } from '../../../helpers/measures'; import { @@ -43,6 +42,7 @@ import { useBadgeTokenQuery, useRenewBagdeTokenMutation, } from '../../../queries/badges'; +import { getBranchLikeQuery } from '../../../sonar-aligned/helpers/branch-like'; import { BranchLike } from '../../../types/branch-like'; import { MetricKey } from '../../../types/metrics'; import { Component } from '../../../types/types'; diff --git a/server/sonar-web/src/main/js/apps/projectInformation/projectRegulatoryReport/RegulatoryReport.tsx b/server/sonar-web/src/main/js/apps/projectInformation/projectRegulatoryReport/RegulatoryReport.tsx index 285e4231f5d..63a35ddea27 100644 --- a/server/sonar-web/src/main/js/apps/projectInformation/projectRegulatoryReport/RegulatoryReport.tsx +++ b/server/sonar-web/src/main/js/apps/projectInformation/projectRegulatoryReport/RegulatoryReport.tsx @@ -32,13 +32,10 @@ import { FormattedMessage } from 'react-intl'; import { getBranches } from '../../../api/branches'; import { getRegulatoryReportUrl } from '../../../api/regulatory-report'; import DocumentationLink from '../../../components/common/DocumentationLink'; -import { - getBranchLikeDisplayName, - getBranchLikeKey, - isMainBranch, -} from '../../../helpers/branch-like'; +import { getBranchLikeDisplayName, getBranchLikeKey } from '../../../helpers/branch-like'; import { translate } from '../../../helpers/l10n'; import { LabelValueSelectOption } from '../../../helpers/search'; +import { isMainBranch } from '../../../sonar-aligned/helpers/branch-like'; import { BranchLike } from '../../../types/branch-like'; import { Component } from '../../../types/types'; diff --git a/server/sonar-web/src/main/js/apps/projectNewCode/components/BranchList.tsx b/server/sonar-web/src/main/js/apps/projectNewCode/components/BranchList.tsx index a029b2efc7f..e47aead27ed 100644 --- a/server/sonar-web/src/main/js/apps/projectNewCode/components/BranchList.tsx +++ b/server/sonar-web/src/main/js/apps/projectNewCode/components/BranchList.tsx @@ -28,9 +28,10 @@ import { PreviouslyNonCompliantBranchNCD, isPreviouslyNonCompliantDaysNCD, } from '../../../components/new-code-definition/utils'; -import { isBranch, sortBranches } from '../../../helpers/branch-like'; +import { sortBranches } from '../../../helpers/branch-like'; import { translate } from '../../../helpers/l10n'; import { DEFAULT_NEW_CODE_DEFINITION_TYPE } from '../../../helpers/new-code-definition'; +import { isBranch } from '../../../sonar-aligned/helpers/branch-like'; import { Branch, BranchLike, BranchWithNewCodePeriod } from '../../../types/branch-like'; import { NewCodeDefinition } from '../../../types/new-code-definition'; import { Component } from '../../../types/types'; diff --git a/server/sonar-web/src/main/js/apps/projectNewCode/components/ProjectNewCodeDefinitionApp.tsx b/server/sonar-web/src/main/js/apps/projectNewCode/components/ProjectNewCodeDefinitionApp.tsx index 7f5dbca55af..21acdf82d5f 100644 --- a/server/sonar-web/src/main/js/apps/projectNewCode/components/ProjectNewCodeDefinitionApp.tsx +++ b/server/sonar-web/src/main/js/apps/projectNewCode/components/ProjectNewCodeDefinitionApp.tsx @@ -27,7 +27,7 @@ import withAvailableFeatures, { } from '../../../app/components/available-features/withAvailableFeatures'; import withComponentContext from '../../../app/components/componentContext/withComponentContext'; import Suggestions from '../../../components/embed-docs-modal/Suggestions'; -import { isBranch, sortBranches } from '../../../helpers/branch-like'; +import { sortBranches } from '../../../helpers/branch-like'; import { translate } from '../../../helpers/l10n'; import { DEFAULT_NEW_CODE_DEFINITION_TYPE, @@ -38,6 +38,7 @@ import { useNewCodeDefinitionMutation, useNewCodeDefinitionQuery, } from '../../../queries/newCodeDefinition'; +import { isBranch } from '../../../sonar-aligned/helpers/branch-like'; import { AppState } from '../../../types/appstate'; import { Branch, BranchLike } from '../../../types/branch-like'; import { Feature } from '../../../types/features'; diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/SecurityHotspotsApp.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/SecurityHotspotsApp.tsx index 372d7293833..c2c23eac0af 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/SecurityHotspotsApp.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/SecurityHotspotsApp.tsx @@ -27,11 +27,12 @@ import withCurrentUserContext from '../../app/components/current-user/withCurren import withIndexationGuard from '../../components/hoc/withIndexationGuard'; import { Location, Router, withRouter } from '../../components/hoc/withRouter'; import { getLeakValue } from '../../components/measure/utils'; -import { getBranchLikeQuery, isPullRequest, isSameBranchLike } from '../../helpers/branch-like'; +import { isPullRequest, isSameBranchLike } from '../../helpers/branch-like'; import { isInput } from '../../helpers/keyboardEventHelpers'; import { KeyboardKeys } from '../../helpers/keycodes'; import { getStandards } from '../../helpers/security-standard'; import { withBranchLikes } from '../../queries/branch'; +import { getBranchLikeQuery } from '../../sonar-aligned/helpers/branch-like'; import { BranchLike } from '../../types/branch-like'; import { ComponentQualifier } from '../../types/component'; import { MetricKey } from '../../types/metrics'; diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/SecurityHotspotsAppRenderer.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/SecurityHotspotsAppRenderer.tsx index fc30449e035..8bafc990a3d 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/SecurityHotspotsAppRenderer.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/SecurityHotspotsAppRenderer.tsx @@ -33,9 +33,9 @@ import * as React from 'react'; import { Helmet } from 'react-helmet-async'; import A11ySkipTarget from '../../components/a11y/A11ySkipTarget'; import Suggestions from '../../components/embed-docs-modal/Suggestions'; -import { isBranch } from '../../helpers/branch-like'; import { translate } from '../../helpers/l10n'; import useFollowScroll from '../../hooks/useFollowScroll'; +import { isBranch } from '../../sonar-aligned/helpers/branch-like'; import { BranchLike } from '../../types/branch-like'; import { ComponentQualifier } from '../../types/component'; import { MetricKey } from '../../types/metrics'; diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotHeader.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotHeader.tsx index 2ae71cfa95a..727ab6a2932 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotHeader.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotHeader.tsx @@ -27,7 +27,6 @@ import { StyledPageTitle, } from 'design-system'; import React from 'react'; -import { getBranchLikeQuery } from '../../../helpers/branch-like'; import { translate } from '../../../helpers/l10n'; import { getComponentSecurityHotspotsUrl, @@ -35,6 +34,7 @@ import { getRuleUrl, } from '../../../helpers/urls'; import { useRefreshBranchStatus } from '../../../queries/branch'; +import { getBranchLikeQuery } from '../../../sonar-aligned/helpers/branch-like'; import { BranchLike } from '../../../types/branch-like'; import { SecurityStandard, Standards } from '../../../types/security'; import { Hotspot, HotspotStatusOption } from '../../../types/security-hotspots'; diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotSidebarHeader.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotSidebarHeader.tsx index 49b4badb0c2..390490e2303 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotSidebarHeader.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotSidebarHeader.tsx @@ -36,9 +36,9 @@ import withCurrentUserContext from '../../../app/components/current-user/withCur import Tooltip from '../../../components/controls/Tooltip'; import Measure from '../../../components/measure/Measure'; import { PopupPlacement } from '../../../components/ui/popups'; -import { isBranch } from '../../../helpers/branch-like'; import { translate } from '../../../helpers/l10n'; import HelpTooltip from '../../../sonar-aligned/components/controls/HelpTooltip'; +import { isBranch } from '../../../sonar-aligned/helpers/branch-like'; import { BranchLike } from '../../../types/branch-like'; import { ComponentContextShape } from '../../../types/component'; import { MetricKey, MetricType } from '../../../types/metrics'; diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotSnippetContainer.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotSnippetContainer.tsx index 7bb2567c02e..92cbd6123a3 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotSnippetContainer.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotSnippetContainer.tsx @@ -20,7 +20,7 @@ import * as React from 'react'; import { getSources } from '../../../api/components'; import { locationsByLine } from '../../../components/SourceViewer/helpers/indexing'; -import { getBranchLikeQuery } from '../../../helpers/branch-like'; +import { getBranchLikeQuery } from '../../../sonar-aligned/helpers/branch-like'; import { BranchLike } from '../../../types/branch-like'; import { Hotspot } from '../../../types/security-hotspots'; import { Component, ExpandDirection, FlowLocation, SourceLine } from '../../../types/types'; diff --git a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewer.tsx b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewer.tsx index d37748db9a6..07ba7e6bfb0 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewer.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewer.tsx @@ -28,9 +28,10 @@ import { getSources, } from '../../api/components'; import { ComponentContext } from '../../app/components/componentContext/ComponentContext'; -import { getBranchLikeQuery, isSameBranchLike } from '../../helpers/branch-like'; +import { isSameBranchLike } from '../../helpers/branch-like'; import { translate } from '../../helpers/l10n'; import { HttpStatus } from '../../helpers/request'; +import { getBranchLikeQuery } from '../../sonar-aligned/helpers/branch-like'; import { BranchLike } from '../../types/branch-like'; import { ComponentQualifier } from '../../types/component'; import { diff --git a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.tsx b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.tsx index 2967f417707..fbe658763a6 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.tsx @@ -38,7 +38,6 @@ import { } from 'design-system'; import * as React from 'react'; import { useIntl } from 'react-intl'; -import { getBranchLikeQuery } from '../../helpers/branch-like'; import { SOFTWARE_QUALITIES } from '../../helpers/constants'; import { ISSUETYPE_METRIC_KEYS_MAP, @@ -59,6 +58,7 @@ import { getComponentIssuesUrl, getComponentSecurityHotspotsUrl, } from '../../helpers/urls'; +import { getBranchLikeQuery } from '../../sonar-aligned/helpers/branch-like'; import type { BranchLike } from '../../types/branch-like'; import { ComponentQualifier } from '../../types/component'; import { IssueType } from '../../types/issues'; diff --git a/server/sonar-web/src/main/js/components/SourceViewer/helpers/loadIssues.ts b/server/sonar-web/src/main/js/components/SourceViewer/helpers/loadIssues.ts index 79bb718804c..7627c87f14e 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/helpers/loadIssues.ts +++ b/server/sonar-web/src/main/js/components/SourceViewer/helpers/loadIssues.ts @@ -18,8 +18,8 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { listIssues, searchIssues } from '../../../api/issues'; -import { getBranchLikeQuery } from '../../../helpers/branch-like'; import { parseIssueFromResponse } from '../../../helpers/issues'; +import { getBranchLikeQuery } from '../../../sonar-aligned/helpers/branch-like'; import { BranchLike } from '../../../types/branch-like'; import { Issue, RawQuery } from '../../../types/types'; import { DEFAULT_ISSUES_QUERY } from '../../shared/utils'; diff --git a/server/sonar-web/src/main/js/components/activity-graph/DefinitionChangeEventInner.tsx b/server/sonar-web/src/main/js/components/activity-graph/DefinitionChangeEventInner.tsx index 693f4dd0f0c..49b18217e1c 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/DefinitionChangeEventInner.tsx +++ b/server/sonar-web/src/main/js/components/activity-graph/DefinitionChangeEventInner.tsx @@ -20,9 +20,9 @@ import { BareButton, BranchIcon, ChevronDownIcon, Note, StandoutLink } from 'design-system'; import * as React from 'react'; import { FormattedMessage } from 'react-intl'; -import { isMainBranch } from '../../helpers/branch-like'; import { translate } from '../../helpers/l10n'; import { getProjectUrl } from '../../helpers/urls'; +import { isMainBranch } from '../../sonar-aligned/helpers/branch-like'; import { BranchLike } from '../../types/branch-like'; import { AnalysisEvent, diff --git a/server/sonar-web/src/main/js/components/activity-graph/__tests__/EventInner-it.tsx b/server/sonar-web/src/main/js/components/activity-graph/__tests__/EventInner-it.tsx index 100cc2ab9b7..4b6d3a00176 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/__tests__/EventInner-it.tsx +++ b/server/sonar-web/src/main/js/components/activity-graph/__tests__/EventInner-it.tsx @@ -22,11 +22,11 @@ import userEvent from '@testing-library/user-event'; import * as React from 'react'; import { Route } from 'react-router-dom'; import BranchesServiceMock from '../../../api/mocks/BranchesServiceMock'; -import { isMainBranch } from '../../../helpers/branch-like'; import { mockBranch, mockMainBranch } from '../../../helpers/mocks/branch-like'; import { mockAnalysisEvent } from '../../../helpers/mocks/project-activity'; import { renderAppWithComponentContext } from '../../../helpers/testReactTestingUtils'; import { byRole, byText } from '../../../helpers/testSelector'; +import { isMainBranch } from '../../../sonar-aligned/helpers/branch-like'; import { Branch, BranchLike } from '../../../types/branch-like'; import { ApplicationAnalysisEventCategory, diff --git a/server/sonar-web/src/main/js/components/icon-mappers/BranchLikeIcon.tsx b/server/sonar-web/src/main/js/components/icon-mappers/BranchLikeIcon.tsx index 118109911fe..93b7c81f355 100644 --- a/server/sonar-web/src/main/js/components/icon-mappers/BranchLikeIcon.tsx +++ b/server/sonar-web/src/main/js/components/icon-mappers/BranchLikeIcon.tsx @@ -21,7 +21,8 @@ import { IconBranch, IconGitBranch, IconProps, IconPullrequest } from '@sonarsource/echoes-react'; import { StyledMutedText } from 'design-system'; import * as React from 'react'; -import { isMainBranch, isPullRequest } from '../../helpers/branch-like'; +import { isPullRequest } from '../../helpers/branch-like'; +import { isMainBranch } from '../../sonar-aligned/helpers/branch-like'; import { BranchLike } from '../../types/branch-like'; export interface BranchLikeIconProps extends IconProps { diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueMessage.tsx b/server/sonar-web/src/main/js/components/issue/components/IssueMessage.tsx index 82ccf81eb27..9eb6ade7f66 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueMessage.tsx +++ b/server/sonar-web/src/main/js/components/issue/components/IssueMessage.tsx @@ -21,9 +21,9 @@ import { IssueMessageHighlighting, StandoutLink } from 'design-system'; import * as React from 'react'; import { ComponentContext } from '../../../app/components/componentContext/ComponentContext'; import { areMyIssuesSelected, parseQuery, serializeQuery } from '../../../apps/issues/utils'; -import { getBranchLikeQuery } from '../../../helpers/branch-like'; import { translate } from '../../../helpers/l10n'; import { getComponentIssuesUrl, getIssuesUrl } from '../../../helpers/urls'; +import { getBranchLikeQuery } from '../../../sonar-aligned/helpers/branch-like'; import { BranchLike } from '../../../types/branch-like'; import { Issue } from '../../../types/types'; import { useLocation } from '../../hoc/withRouter'; diff --git a/server/sonar-web/src/main/js/components/shared/DrilldownLink.tsx b/server/sonar-web/src/main/js/components/shared/DrilldownLink.tsx index d0a2c56a958..53f39eaf9aa 100644 --- a/server/sonar-web/src/main/js/components/shared/DrilldownLink.tsx +++ b/server/sonar-web/src/main/js/components/shared/DrilldownLink.tsx @@ -18,8 +18,8 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import { getBranchLikeQuery } from '../../helpers/branch-like'; import { getComponentDrilldownUrl, getComponentIssuesUrl } from '../../helpers/urls'; +import { getBranchLikeQuery } from '../../sonar-aligned/helpers/branch-like'; import { BranchLike } from '../../types/branch-like'; import Link from '../common/Link'; import { isIssueMeasure, propsToIssueParams } from './utils'; diff --git a/server/sonar-web/src/main/js/components/tutorials/TutorialSelectionRenderer.tsx b/server/sonar-web/src/main/js/components/tutorials/TutorialSelectionRenderer.tsx index 842584e7d61..9d6cb91d871 100644 --- a/server/sonar-web/src/main/js/components/tutorials/TutorialSelectionRenderer.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/TutorialSelectionRenderer.tsx @@ -30,10 +30,10 @@ import { } from 'design-system'; import * as React from 'react'; import { AnalysisStatus } from '../../apps/overview/components/AnalysisStatus'; -import { isMainBranch } from '../../helpers/branch-like'; import { translate } from '../../helpers/l10n'; import { getProjectTutorialLocation } from '../../helpers/urls'; import { useBranchesQuery } from '../../queries/branch'; +import { isMainBranch } from '../../sonar-aligned/helpers/branch-like'; import { AlmKeys, AlmSettingsInstance, ProjectAlmBindingResponse } from '../../types/alm-settings'; import { MainBranch } from '../../types/branch-like'; import { Component } from '../../types/types'; diff --git a/server/sonar-web/src/main/js/helpers/branch-like.ts b/server/sonar-web/src/main/js/helpers/branch-like.ts index afa621317ca..2e4474e19ca 100644 --- a/server/sonar-web/src/main/js/helpers/branch-like.ts +++ b/server/sonar-web/src/main/js/helpers/branch-like.ts @@ -18,22 +18,8 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { orderBy } from 'lodash'; -import { - Branch, - BranchLike, - BranchLikeTree, - BranchParameters, - MainBranch, - PullRequest, -} from '../types/branch-like'; - -export function isBranch(branchLike?: BranchLike): branchLike is Branch { - return branchLike !== undefined && (branchLike as Branch).isMain !== undefined; -} - -export function isMainBranch(branchLike?: BranchLike): branchLike is MainBranch { - return isBranch(branchLike) && branchLike.isMain; -} +import { isBranch, isMainBranch } from '../sonar-aligned/helpers/branch-like'; +import { Branch, BranchLike, BranchLikeTree, PullRequest } from '../types/branch-like'; export function sortBranches(branches: Branch[]) { return orderBy(branches, [(b) => b.isMain, (b) => b.name], ['desc', 'asc']); @@ -113,18 +99,6 @@ export function getBrancheLikesAsTree(branchLikes: BranchLike[]): BranchLikeTree } } -export function getBranchLikeQuery( - branchLike?: BranchLike, - includeMainBranch = false, -): BranchParameters { - if (isBranch(branchLike) && (includeMainBranch || !isMainBranch(branchLike))) { - return { branch: branchLike.name }; - } else if (isPullRequest(branchLike)) { - return { pullRequest: branchLike.key }; - } - return {}; -} - // Create branch object from branch name or pull request key export function fillBranchLike( branch?: string, diff --git a/server/sonar-web/src/main/js/helpers/urls.ts b/server/sonar-web/src/main/js/helpers/urls.ts index 2899b7999dd..d48bf47f45e 100644 --- a/server/sonar-web/src/main/js/helpers/urls.ts +++ b/server/sonar-web/src/main/js/helpers/urls.ts @@ -21,6 +21,7 @@ import { isArray, mapValues, omitBy, pick } from 'lodash'; import { Path, To } from 'react-router-dom'; import { getProfilePath } from '../apps/quality-profiles/utils'; import { DEFAULT_ISSUES_QUERY } from '../components/shared/utils'; +import { getBranchLikeQuery, isBranch, isMainBranch } from '../sonar-aligned/helpers/branch-like'; import { BranchLike, BranchParameters } from '../types/branch-like'; import { ComponentQualifier, isApplication, isPortfolioLike } from '../types/component'; import { MeasurePageView } from '../types/measures'; @@ -28,7 +29,7 @@ import { GraphType } from '../types/project-activity'; import { SecurityStandard } from '../types/security'; import { Dict, RawQuery } from '../types/types'; import { HomePage } from '../types/users'; -import { getBranchLikeQuery, isBranch, isMainBranch, isPullRequest } from './branch-like'; +import { isPullRequest } from './branch-like'; import { serializeOptionalBoolean } from './query'; import { getBaseUrl } from './system'; diff --git a/server/sonar-web/src/main/js/queries/branch.tsx b/server/sonar-web/src/main/js/queries/branch.tsx index 07ebdebf426..68cef8ddef5 100644 --- a/server/sonar-web/src/main/js/queries/branch.tsx +++ b/server/sonar-web/src/main/js/queries/branch.tsx @@ -35,9 +35,10 @@ import { dismissAnalysisWarning, getAnalysisStatus } from '../api/ce'; import { getQualityGateProjectStatus } from '../api/quality-gates'; import { AvailableFeaturesContext } from '../app/components/available-features/AvailableFeaturesContext'; import { useLocation } from '../components/hoc/withRouter'; -import { isBranch, isPullRequest } from '../helpers/branch-like'; +import { isPullRequest } from '../helpers/branch-like'; import { extractStatusConditionsFromProjectStatus } from '../helpers/qualityGates'; import { searchParamsToQuery } from '../helpers/urls'; +import { isBranch } from '../sonar-aligned/helpers/branch-like'; import { Branch, BranchLike } from '../types/branch-like'; import { isApplication, isPortfolioLike, isProject } from '../types/component'; import { Feature } from '../types/features'; diff --git a/server/sonar-web/src/main/js/queries/project-analyses.ts b/server/sonar-web/src/main/js/queries/project-analyses.ts index 7365b156ea1..1dadbe71e90 100644 --- a/server/sonar-web/src/main/js/queries/project-analyses.ts +++ b/server/sonar-web/src/main/js/queries/project-analyses.ts @@ -32,9 +32,9 @@ import { useComponent, useTopLevelComponentKey, } from '../app/components/componentContext/withComponentContext'; -import { getBranchLikeQuery } from '../helpers/branch-like'; import { parseDate } from '../helpers/dates'; import { serializeStringArray } from '../helpers/query'; +import { getBranchLikeQuery } from '../sonar-aligned/helpers/branch-like'; import { BranchParameters } from '../types/branch-like'; import { ParsedAnalysis } from '../types/project-activity'; import { useBranchesQuery } from './branch'; diff --git a/server/sonar-web/src/main/js/sonar-aligned/helpers/branch-like.ts b/server/sonar-web/src/main/js/sonar-aligned/helpers/branch-like.ts new file mode 100644 index 00000000000..c8fed5f3f57 --- /dev/null +++ b/server/sonar-web/src/main/js/sonar-aligned/helpers/branch-like.ts @@ -0,0 +1,40 @@ +/* + * SonarQube + * Copyright (C) 2009-2024 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import { isPullRequest } from '../../helpers/branch-like'; + +import { Branch, BranchLike, BranchParameters, MainBranch } from '../../types/branch-like'; + +export function getBranchLikeQuery( + branchLike?: BranchLike, + includeMainBranch = false, +): BranchParameters { + if (isBranch(branchLike) && (includeMainBranch || !isMainBranch(branchLike))) { + return { branch: branchLike.name }; + } else if (isPullRequest(branchLike)) { + return { pullRequest: branchLike.key }; + } + return {}; +} +export function isBranch(branchLike?: BranchLike): branchLike is Branch { + return branchLike !== undefined && (branchLike as Branch).isMain !== undefined; +} +export function isMainBranch(branchLike?: BranchLike): branchLike is MainBranch { + return isBranch(branchLike) && branchLike.isMain; +}