Skip to content

Commit

Permalink
fix parameter that is sent to build endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
ilayda-cp committed Feb 4, 2025
1 parent 7b40994 commit c67dbe3
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions static/js/publisher/pages/Builds/RepoSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,18 @@ function RepoSelector({ githubData, setAutoTriggerBuild }: Props) {
const [reposLoading, setReposLoading] = useState<boolean>(false);
const [validRepo, setValidRepo] = useState<boolean | null>(null);
const [validationError, setValidationError] = useState<boolean>(false);

const getRepoNameWithOwner = (repo: Repo) =>
selectedOrg ? `${selectedOrg}/${repo.name}` : repo.nameWithOwner;

const validateRepo = async (repo: Repo | undefined) => {
if (!repo) {
return;
}

setValidating(true);

const repoName = selectedOrg
? `${selectedOrg}/${repo.name}`
: repo.nameWithOwner;
const repoName = getRepoNameWithOwner(repo);

const response = await fetch(
`/api/${snapId}/builds/validate-repo?repo=${repoName}`,
Expand Down Expand Up @@ -160,14 +162,8 @@ function RepoSelector({ githubData, setAutoTriggerBuild }: Props) {
const formData = new FormData();
formData.set("csrf_token", window.CSRF_TOKEN);
if (selectedRepo) {
if (selectedRepo.nameWithOwner) {
formData.set("github_repository", selectedRepo.nameWithOwner);
} else {
formData.set(
"github_repository",
`${selectedOrg}/${selectedRepo.name}`,
);
}
const repoName = getRepoNameWithOwner(selectedRepo);
formData.set("github_repository", repoName);
}

const response = await fetch(`/api/${snapId}/builds`, {
Expand Down

0 comments on commit c67dbe3

Please sign in to comment.