mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-12 15:05:19 +00:00
Merge pull request #3539 from Dokploy/3493-when-adding-a-git-repository-as-a-provider-spaces-in-the-repo-name-break-the-repo-selection
feat(bitbucket): add optional slug field for repositories and update …
This commit is contained in:
@@ -29,6 +29,7 @@ const baseApp: ApplicationNested = {
|
|||||||
applicationId: "",
|
applicationId: "",
|
||||||
previewLabels: [],
|
previewLabels: [],
|
||||||
createEnvFile: true,
|
createEnvFile: true,
|
||||||
|
bitbucketRepositorySlug: "",
|
||||||
herokuVersion: "",
|
herokuVersion: "",
|
||||||
giteaBranch: "",
|
giteaBranch: "",
|
||||||
buildServerId: "",
|
buildServerId: "",
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ const baseApp: ApplicationNested = {
|
|||||||
applicationId: "",
|
applicationId: "",
|
||||||
previewLabels: [],
|
previewLabels: [],
|
||||||
createEnvFile: true,
|
createEnvFile: true,
|
||||||
|
bitbucketRepositorySlug: "",
|
||||||
herokuVersion: "",
|
herokuVersion: "",
|
||||||
giteaRepository: "",
|
giteaRepository: "",
|
||||||
giteaOwner: "",
|
giteaOwner: "",
|
||||||
|
|||||||
+12
-3
@@ -54,6 +54,7 @@ const BitbucketProviderSchema = z.object({
|
|||||||
.object({
|
.object({
|
||||||
repo: z.string().min(1, "Repo is required"),
|
repo: z.string().min(1, "Repo is required"),
|
||||||
owner: z.string().min(1, "Owner is required"),
|
owner: z.string().min(1, "Owner is required"),
|
||||||
|
slug: z.string().optional(),
|
||||||
})
|
})
|
||||||
.required(),
|
.required(),
|
||||||
branch: z.string().min(1, "Branch is required"),
|
branch: z.string().min(1, "Branch is required"),
|
||||||
@@ -82,6 +83,7 @@ export const SaveBitbucketProvider = ({ applicationId }: Props) => {
|
|||||||
repository: {
|
repository: {
|
||||||
owner: "",
|
owner: "",
|
||||||
repo: "",
|
repo: "",
|
||||||
|
slug: "",
|
||||||
},
|
},
|
||||||
bitbucketId: "",
|
bitbucketId: "",
|
||||||
branch: "",
|
branch: "",
|
||||||
@@ -114,11 +116,14 @@ export const SaveBitbucketProvider = ({ applicationId }: Props) => {
|
|||||||
} = api.bitbucket.getBitbucketBranches.useQuery(
|
} = api.bitbucket.getBitbucketBranches.useQuery(
|
||||||
{
|
{
|
||||||
owner: repository?.owner,
|
owner: repository?.owner,
|
||||||
repo: repository?.repo,
|
repo: repository?.slug || repository?.repo || "",
|
||||||
bitbucketId,
|
bitbucketId,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
enabled: !!repository?.owner && !!repository?.repo && !!bitbucketId,
|
enabled:
|
||||||
|
!!repository?.owner &&
|
||||||
|
!!(repository?.slug || repository?.repo) &&
|
||||||
|
!!bitbucketId,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -129,6 +134,7 @@ export const SaveBitbucketProvider = ({ applicationId }: Props) => {
|
|||||||
repository: {
|
repository: {
|
||||||
repo: data.bitbucketRepository || "",
|
repo: data.bitbucketRepository || "",
|
||||||
owner: data.bitbucketOwner || "",
|
owner: data.bitbucketOwner || "",
|
||||||
|
slug: data.bitbucketRepositorySlug || "",
|
||||||
},
|
},
|
||||||
buildPath: data.bitbucketBuildPath || "/",
|
buildPath: data.bitbucketBuildPath || "/",
|
||||||
bitbucketId: data.bitbucketId || "",
|
bitbucketId: data.bitbucketId || "",
|
||||||
@@ -142,6 +148,7 @@ export const SaveBitbucketProvider = ({ applicationId }: Props) => {
|
|||||||
await mutateAsync({
|
await mutateAsync({
|
||||||
bitbucketBranch: data.branch,
|
bitbucketBranch: data.branch,
|
||||||
bitbucketRepository: data.repository.repo,
|
bitbucketRepository: data.repository.repo,
|
||||||
|
bitbucketRepositorySlug: data.repository.slug || data.repository.repo,
|
||||||
bitbucketOwner: data.repository.owner,
|
bitbucketOwner: data.repository.owner,
|
||||||
bitbucketBuildPath: data.buildPath,
|
bitbucketBuildPath: data.buildPath,
|
||||||
bitbucketId: data.bitbucketId,
|
bitbucketId: data.bitbucketId,
|
||||||
@@ -181,6 +188,7 @@ export const SaveBitbucketProvider = ({ applicationId }: Props) => {
|
|||||||
form.setValue("repository", {
|
form.setValue("repository", {
|
||||||
owner: "",
|
owner: "",
|
||||||
repo: "",
|
repo: "",
|
||||||
|
slug: "",
|
||||||
});
|
});
|
||||||
form.setValue("branch", "");
|
form.setValue("branch", "");
|
||||||
}}
|
}}
|
||||||
@@ -217,7 +225,7 @@ export const SaveBitbucketProvider = ({ applicationId }: Props) => {
|
|||||||
<FormLabel>Repository</FormLabel>
|
<FormLabel>Repository</FormLabel>
|
||||||
{field.value.owner && field.value.repo && (
|
{field.value.owner && field.value.repo && (
|
||||||
<Link
|
<Link
|
||||||
href={`https://bitbucket.org/${field.value.owner}/${field.value.repo}`}
|
href={`https://bitbucket.org/${field.value.owner}/${field.value.slug || field.value.repo}`}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
className="flex items-center gap-1 text-sm text-muted-foreground hover:text-primary"
|
className="flex items-center gap-1 text-sm text-muted-foreground hover:text-primary"
|
||||||
@@ -271,6 +279,7 @@ export const SaveBitbucketProvider = ({ applicationId }: Props) => {
|
|||||||
form.setValue("repository", {
|
form.setValue("repository", {
|
||||||
owner: repo.owner.username as string,
|
owner: repo.owner.username as string,
|
||||||
repo: repo.name,
|
repo: repo.name,
|
||||||
|
slug: repo.slug,
|
||||||
});
|
});
|
||||||
form.setValue("branch", "");
|
form.setValue("branch", "");
|
||||||
}}
|
}}
|
||||||
|
|||||||
+12
-3
@@ -54,6 +54,7 @@ const BitbucketProviderSchema = z.object({
|
|||||||
.object({
|
.object({
|
||||||
repo: z.string().min(1, "Repo is required"),
|
repo: z.string().min(1, "Repo is required"),
|
||||||
owner: z.string().min(1, "Owner is required"),
|
owner: z.string().min(1, "Owner is required"),
|
||||||
|
slug: z.string().optional(),
|
||||||
})
|
})
|
||||||
.required(),
|
.required(),
|
||||||
branch: z.string().min(1, "Branch is required"),
|
branch: z.string().min(1, "Branch is required"),
|
||||||
@@ -82,6 +83,7 @@ export const SaveBitbucketProviderCompose = ({ composeId }: Props) => {
|
|||||||
repository: {
|
repository: {
|
||||||
owner: "",
|
owner: "",
|
||||||
repo: "",
|
repo: "",
|
||||||
|
slug: "",
|
||||||
},
|
},
|
||||||
bitbucketId: "",
|
bitbucketId: "",
|
||||||
branch: "",
|
branch: "",
|
||||||
@@ -114,11 +116,14 @@ export const SaveBitbucketProviderCompose = ({ composeId }: Props) => {
|
|||||||
} = api.bitbucket.getBitbucketBranches.useQuery(
|
} = api.bitbucket.getBitbucketBranches.useQuery(
|
||||||
{
|
{
|
||||||
owner: repository?.owner,
|
owner: repository?.owner,
|
||||||
repo: repository?.repo,
|
repo: repository?.slug || repository?.repo || "",
|
||||||
bitbucketId,
|
bitbucketId,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
enabled: !!repository?.owner && !!repository?.repo && !!bitbucketId,
|
enabled:
|
||||||
|
!!repository?.owner &&
|
||||||
|
!!(repository?.slug || repository?.repo) &&
|
||||||
|
!!bitbucketId,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -129,6 +134,7 @@ export const SaveBitbucketProviderCompose = ({ composeId }: Props) => {
|
|||||||
repository: {
|
repository: {
|
||||||
repo: data.bitbucketRepository || "",
|
repo: data.bitbucketRepository || "",
|
||||||
owner: data.bitbucketOwner || "",
|
owner: data.bitbucketOwner || "",
|
||||||
|
slug: data.bitbucketRepositorySlug || "",
|
||||||
},
|
},
|
||||||
composePath: data.composePath,
|
composePath: data.composePath,
|
||||||
bitbucketId: data.bitbucketId || "",
|
bitbucketId: data.bitbucketId || "",
|
||||||
@@ -142,6 +148,7 @@ export const SaveBitbucketProviderCompose = ({ composeId }: Props) => {
|
|||||||
await mutateAsync({
|
await mutateAsync({
|
||||||
bitbucketBranch: data.branch,
|
bitbucketBranch: data.branch,
|
||||||
bitbucketRepository: data.repository.repo,
|
bitbucketRepository: data.repository.repo,
|
||||||
|
bitbucketRepositorySlug: data.repository.slug || data.repository.repo,
|
||||||
bitbucketOwner: data.repository.owner,
|
bitbucketOwner: data.repository.owner,
|
||||||
bitbucketId: data.bitbucketId,
|
bitbucketId: data.bitbucketId,
|
||||||
composePath: data.composePath,
|
composePath: data.composePath,
|
||||||
@@ -183,6 +190,7 @@ export const SaveBitbucketProviderCompose = ({ composeId }: Props) => {
|
|||||||
form.setValue("repository", {
|
form.setValue("repository", {
|
||||||
owner: "",
|
owner: "",
|
||||||
repo: "",
|
repo: "",
|
||||||
|
slug: "",
|
||||||
});
|
});
|
||||||
form.setValue("branch", "");
|
form.setValue("branch", "");
|
||||||
}}
|
}}
|
||||||
@@ -219,7 +227,7 @@ export const SaveBitbucketProviderCompose = ({ composeId }: Props) => {
|
|||||||
<FormLabel>Repository</FormLabel>
|
<FormLabel>Repository</FormLabel>
|
||||||
{field.value.owner && field.value.repo && (
|
{field.value.owner && field.value.repo && (
|
||||||
<Link
|
<Link
|
||||||
href={`https://bitbucket.org/${field.value.owner}/${field.value.repo}`}
|
href={`https://bitbucket.org/${field.value.owner}/${field.value.slug || field.value.repo}`}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
className="flex items-center gap-1 text-sm text-muted-foreground hover:text-primary"
|
className="flex items-center gap-1 text-sm text-muted-foreground hover:text-primary"
|
||||||
@@ -273,6 +281,7 @@ export const SaveBitbucketProviderCompose = ({ composeId }: Props) => {
|
|||||||
form.setValue("repository", {
|
form.setValue("repository", {
|
||||||
owner: repo.owner.username as string,
|
owner: repo.owner.username as string,
|
||||||
repo: repo.name,
|
repo: repo.name,
|
||||||
|
slug: repo.slug,
|
||||||
});
|
});
|
||||||
form.setValue("branch", "");
|
form.setValue("branch", "");
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
ALTER TABLE "application" ADD COLUMN "bitbucketRepositorySlug" text;--> statement-breakpoint
|
||||||
|
ALTER TABLE "compose" ADD COLUMN "bitbucketRepositorySlug" text;
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -953,6 +953,13 @@
|
|||||||
"when": 1768271617042,
|
"when": 1768271617042,
|
||||||
"tag": "0135_illegal_magik",
|
"tag": "0135_illegal_magik",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 136,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1769580434296,
|
||||||
|
"tag": "0136_tidy_puff_adder",
|
||||||
|
"breakpoints": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -195,7 +195,9 @@ export default async function handler(
|
|||||||
const commitedPaths = await extractCommitedPaths(
|
const commitedPaths = await extractCommitedPaths(
|
||||||
req.body,
|
req.body,
|
||||||
application.bitbucket,
|
application.bitbucket,
|
||||||
application.bitbucketRepository || "",
|
application.bitbucketRepositorySlug ||
|
||||||
|
application.bitbucketRepository ||
|
||||||
|
"",
|
||||||
);
|
);
|
||||||
|
|
||||||
const shouldDeployPaths = shouldDeploy(
|
const shouldDeployPaths = shouldDeploy(
|
||||||
|
|||||||
@@ -100,7 +100,9 @@ export default async function handler(
|
|||||||
const commitedPaths = await extractCommitedPaths(
|
const commitedPaths = await extractCommitedPaths(
|
||||||
req.body,
|
req.body,
|
||||||
composeResult.bitbucket,
|
composeResult.bitbucket,
|
||||||
composeResult.bitbucketRepository || "",
|
composeResult.bitbucketRepositorySlug ||
|
||||||
|
composeResult.bitbucketRepository ||
|
||||||
|
"",
|
||||||
);
|
);
|
||||||
|
|
||||||
const shouldDeployPaths = shouldDeploy(
|
const shouldDeployPaths = shouldDeploy(
|
||||||
|
|||||||
@@ -469,6 +469,7 @@ export const applicationRouter = createTRPCRouter({
|
|||||||
}
|
}
|
||||||
await updateApplication(input.applicationId, {
|
await updateApplication(input.applicationId, {
|
||||||
bitbucketRepository: input.bitbucketRepository,
|
bitbucketRepository: input.bitbucketRepository,
|
||||||
|
bitbucketRepositorySlug: input.bitbucketRepositorySlug,
|
||||||
bitbucketOwner: input.bitbucketOwner,
|
bitbucketOwner: input.bitbucketOwner,
|
||||||
bitbucketBranch: input.bitbucketBranch,
|
bitbucketBranch: input.bitbucketBranch,
|
||||||
bitbucketBuildPath: input.bitbucketBuildPath,
|
bitbucketBuildPath: input.bitbucketBuildPath,
|
||||||
|
|||||||
@@ -136,6 +136,7 @@ export const applications = pgTable("application", {
|
|||||||
giteaBuildPath: text("giteaBuildPath").default("/"),
|
giteaBuildPath: text("giteaBuildPath").default("/"),
|
||||||
// Bitbucket
|
// Bitbucket
|
||||||
bitbucketRepository: text("bitbucketRepository"),
|
bitbucketRepository: text("bitbucketRepository"),
|
||||||
|
bitbucketRepositorySlug: text("bitbucketRepositorySlug"),
|
||||||
bitbucketOwner: text("bitbucketOwner"),
|
bitbucketOwner: text("bitbucketOwner"),
|
||||||
bitbucketBranch: text("bitbucketBranch"),
|
bitbucketBranch: text("bitbucketBranch"),
|
||||||
bitbucketBuildPath: text("bitbucketBuildPath").default("/"),
|
bitbucketBuildPath: text("bitbucketBuildPath").default("/"),
|
||||||
@@ -451,6 +452,7 @@ export const apiSaveBitbucketProvider = createSchema
|
|||||||
bitbucketBuildPath: true,
|
bitbucketBuildPath: true,
|
||||||
bitbucketOwner: true,
|
bitbucketOwner: true,
|
||||||
bitbucketRepository: true,
|
bitbucketRepository: true,
|
||||||
|
bitbucketRepositorySlug: true,
|
||||||
bitbucketId: true,
|
bitbucketId: true,
|
||||||
applicationId: true,
|
applicationId: true,
|
||||||
watchPaths: true,
|
watchPaths: true,
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ export const compose = pgTable("compose", {
|
|||||||
gitlabPathNamespace: text("gitlabPathNamespace"),
|
gitlabPathNamespace: text("gitlabPathNamespace"),
|
||||||
// Bitbucket
|
// Bitbucket
|
||||||
bitbucketRepository: text("bitbucketRepository"),
|
bitbucketRepository: text("bitbucketRepository"),
|
||||||
|
bitbucketRepositorySlug: text("bitbucketRepositorySlug"),
|
||||||
bitbucketOwner: text("bitbucketOwner"),
|
bitbucketOwner: text("bitbucketOwner"),
|
||||||
bitbucketBranch: text("bitbucketBranch"),
|
bitbucketBranch: text("bitbucketBranch"),
|
||||||
// Gitea
|
// Gitea
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ export const getBitbucketHeaders = (bitbucketProvider: Bitbucket) => {
|
|||||||
interface CloneBitbucketRepository {
|
interface CloneBitbucketRepository {
|
||||||
appName: string;
|
appName: string;
|
||||||
bitbucketRepository: string | null;
|
bitbucketRepository: string | null;
|
||||||
|
bitbucketRepositorySlug?: string | null;
|
||||||
bitbucketOwner: string | null;
|
bitbucketOwner: string | null;
|
||||||
bitbucketBranch: string | null;
|
bitbucketBranch: string | null;
|
||||||
bitbucketId: string | null;
|
bitbucketId: string | null;
|
||||||
@@ -117,7 +118,8 @@ export const cloneBitbucketRepository = async ({
|
|||||||
const outputPath = join(basePath, appName, "code");
|
const outputPath = join(basePath, appName, "code");
|
||||||
command += `rm -rf ${outputPath};`;
|
command += `rm -rf ${outputPath};`;
|
||||||
command += `mkdir -p ${outputPath};`;
|
command += `mkdir -p ${outputPath};`;
|
||||||
const repoclone = `bitbucket.org/${bitbucketOwner}/${bitbucketRepository}.git`;
|
const repoToUse = entity.bitbucketRepositorySlug || bitbucketRepository;
|
||||||
|
const repoclone = `bitbucket.org/${bitbucketOwner}/${repoToUse}.git`;
|
||||||
const cloneUrl = getBitbucketCloneUrl(bitbucket, repoclone);
|
const cloneUrl = getBitbucketCloneUrl(bitbucket, repoclone);
|
||||||
command += `echo "Cloning Repo ${repoclone} to ${outputPath}: ✅";`;
|
command += `echo "Cloning Repo ${repoclone} to ${outputPath}: ✅";`;
|
||||||
command += `git clone --branch ${bitbucketBranch} --depth 1 ${enableSubmodules ? "--recurse-submodules" : ""} ${cloneUrl} ${outputPath} --progress;`;
|
command += `git clone --branch ${bitbucketBranch} --depth 1 ${enableSubmodules ? "--recurse-submodules" : ""} ${cloneUrl} ${outputPath} --progress;`;
|
||||||
@@ -137,6 +139,7 @@ export const getBitbucketRepositories = async (bitbucketId?: string) => {
|
|||||||
let repositories: {
|
let repositories: {
|
||||||
name: string;
|
name: string;
|
||||||
url: string;
|
url: string;
|
||||||
|
slug: string;
|
||||||
owner: { username: string };
|
owner: { username: string };
|
||||||
}[] = [];
|
}[] = [];
|
||||||
|
|
||||||
@@ -159,6 +162,7 @@ export const getBitbucketRepositories = async (bitbucketId?: string) => {
|
|||||||
const mappedData = data.values.map((repo: any) => ({
|
const mappedData = data.values.map((repo: any) => ({
|
||||||
name: repo.name,
|
name: repo.name,
|
||||||
url: repo.links.html.href,
|
url: repo.links.html.href,
|
||||||
|
slug: repo.slug,
|
||||||
owner: {
|
owner: {
|
||||||
username: repo.workspace.slug,
|
username: repo.workspace.slug,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user