mirror of https://github.com/harness/drone.git
feat: [CDE-367]: fixed generating repoIdentifier and repoName (#2764)
* chore: Sycn with main * feat: [CDE-367]: fixed generating repoIdentifier and repoName * feat: [CDE-348]: Stop showing failure notification for logspull/3571/head
parent
8e4fd70ef0
commit
0e8dc4e544
|
@ -27,7 +27,7 @@ import { useListRepos, useListBranches, useRepoLookupForGitspace } from 'service
|
|||
import { useGetCDEAPIParams } from 'cde-gitness/hooks/useGetCDEAPIParams'
|
||||
import { scmOptions, SCMType, type RepoQueryParams } from 'cde-gitness/pages/GitspaceCreate/CDECreateGitspace'
|
||||
import { useQueryParams } from 'hooks/useQueryParams'
|
||||
import { getRepoIdFromURL, getRepoNameFromURL, isValidUrl } from './CDEAnyGitImport.utils'
|
||||
import { getRepoIdFromURL, getRepoNameFromURL, isValidUrl } from 'cde-gitness/utils/SelectRepository.utils'
|
||||
import { GitspaceSelect } from '../GitspaceSelect/GitspaceSelect'
|
||||
import css from './CDEAnyGitImport.module.scss'
|
||||
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
* Copyright 2024 Harness, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export const isValidUrl = (url: string) => {
|
||||
const urlPattern = new RegExp(
|
||||
'^(https?:\\/\\/)?' + // validate protocol
|
||||
'((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' + // validate domain name
|
||||
'((\\d{1,3}\\.){3}\\d{1,3}))' + // validate OR ip (v4) address
|
||||
'(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' + // validate port and path
|
||||
'(\\?[;&a-z\\d%_.~+=-]*)?' + // validate query string
|
||||
'(\\#[-a-z\\d_]*)?$',
|
||||
'i'
|
||||
) // validate fragment locator
|
||||
return !!urlPattern.test(url)
|
||||
}
|
||||
|
||||
export const getRepoIdFromURL = (repoURL?: string) => {
|
||||
const repoURLSplit = repoURL?.split('/')
|
||||
return repoURLSplit?.[repoURLSplit?.length - 1]
|
||||
?.replace(/-/g, '')
|
||||
?.replace(/_/g, '')
|
||||
.replace(/\./g, '')
|
||||
?.toLowerCase()
|
||||
}
|
||||
|
||||
export const getRepoNameFromURL = (repoURL?: string) => {
|
||||
const repoURLSplit = repoURL?.split('/')
|
||||
return repoURLSplit?.[repoURLSplit?.length - 1]
|
||||
}
|
|
@ -29,7 +29,7 @@ import { useRepoLookupForGitspace } from 'services/cde'
|
|||
import { useGetCDEAPIParams } from 'cde-gitness/hooks/useGetCDEAPIParams'
|
||||
import type { RepoQueryParams } from 'cde-gitness/pages/GitspaceCreate/CDECreateGitspace'
|
||||
import { useQueryParams } from 'hooks/useQueryParams'
|
||||
import { getRepoIdFromURL, getRepoNameFromURL, isValidUrl } from './CDEAnyGitImport.utils'
|
||||
import { getRepoIdFromURL, getRepoNameFromURL, isValidUrl } from 'cde-gitness/utils/SelectRepository.utils'
|
||||
import css from './CDEAnyGitImport.module.scss'
|
||||
|
||||
enum RepoCheckStatus {
|
||||
|
|
|
@ -19,6 +19,7 @@ import { useHistory } from 'react-router-dom'
|
|||
import { Color, FontVariation } from '@harnessio/design-system'
|
||||
import { Menu, MenuItem } from '@blueprintjs/core'
|
||||
import { defaultTo, omit } from 'lodash-es'
|
||||
import { getRepoIdFromURL, getRepoNameFromURL } from 'cde-gitness/utils/SelectRepository.utils'
|
||||
import { useGetSpaceParam } from 'hooks/useGetSpaceParam'
|
||||
import { useStrings } from 'framework/strings'
|
||||
import { useAppContext } from 'AppContext'
|
||||
|
@ -38,7 +39,6 @@ import { useGetCDEAPIParams } from 'cde-gitness/hooks/useGetCDEAPIParams'
|
|||
import { EnumGitspaceCodeRepoType, IDEType } from 'cde-gitness/constants'
|
||||
import { CDESSHSelect } from 'cde-gitness/components/CDESSHSelect/CDESSHSelect'
|
||||
import { useQueryParams } from 'hooks/useQueryParams'
|
||||
import { getRepoIdFromURL, getRepoNameFromURL } from 'cde-gitness/components/CDEAnyGitImport/CDEAnyGitImport.utils'
|
||||
import { CDEUnknownSCM } from 'cde-gitness/components/CDEAnyGitImport/CDEUnknownSCM'
|
||||
import { gitnessFormInitialValues } from './GitspaceCreate.constants'
|
||||
import { validateGitnessForm } from './GitspaceCreate.utils'
|
||||
|
|
|
@ -35,16 +35,14 @@ export const isValidUrl = (url: string) => {
|
|||
|
||||
export const getRepoIdFromURL = (repoURL?: string) => {
|
||||
const repoURLSplit = repoURL?.split('/')
|
||||
return repoURLSplit?.[repoURLSplit?.length - 1]
|
||||
?.replace(/-/g, '')
|
||||
?.replace(/_/g, '')
|
||||
.replace(/\./g, '')
|
||||
?.toLowerCase()
|
||||
const filtered = repoURLSplit?.filter(i => !!i)
|
||||
return filtered?.[filtered?.length - 1]?.replace(/-/g, '')?.replace(/_/g, '').replace(/\./g, '')?.toLowerCase()
|
||||
}
|
||||
|
||||
export const getRepoNameFromURL = (repoURL?: string) => {
|
||||
const repoURLSplit = repoURL?.split('/')
|
||||
return repoURLSplit?.[repoURLSplit?.length - 1]
|
||||
const filtered = repoURLSplit?.filter(i => !!i)
|
||||
return filtered?.[filtered?.length - 1]
|
||||
}
|
||||
|
||||
export enum CodeRepoType {
|
||||
|
|
Loading…
Reference in New Issue