Skip to content

Commit 84fd9ed

Browse files
committed
Revert "init"
This reverts commit a61935f.
1 parent a61935f commit 84fd9ed

3 files changed

Lines changed: 22 additions & 159 deletions

File tree

packages/app/app/components/Commits.vue

Lines changed: 18 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -12,55 +12,32 @@ const props = defineProps<{
1212
repo: string;
1313
}>();
1414
15-
type BranchesResponse = {
16-
branches: string[];
17-
};
18-
19-
const [data, branchesResponse] = await Promise.all([
20-
$fetch("/api/repo/commits", {
21-
query: {
22-
owner: props.owner,
23-
repo: props.repo,
24-
},
25-
}),
26-
$fetch<BranchesResponse>("/api/repo/branches", {
27-
query: {
28-
owner: props.owner,
29-
repo: props.repo,
30-
},
31-
}).catch(() => null),
32-
]);
15+
const data = await $fetch("/api/repo/commits", {
16+
query: {
17+
owner: props.owner,
18+
repo: props.repo,
19+
},
20+
});
3321
3422
if (!data) {
3523
throw createError("Could not load Commits");
3624
}
3725
3826
const branch = shallowReactive(data);
39-
const selectedBranch = ref(branch.name);
40-
const availableBranches = ref<string[]>(
41-
branchesResponse?.branches?.length ? branchesResponse.branches : [branch.name],
42-
);
43-
44-
if (!availableBranches.value.includes(branch.name)) {
45-
availableBranches.value.unshift(branch.name);
46-
}
4727
4828
const commitsWithRelease = computed(() =>
4929
branch.target.history.nodes
50-
.flatMap((commit) => {
51-
const release = commit.statusCheckRollup?.contexts.nodes.find(
30+
.filter((commit) =>
31+
commit.statusCheckRollup?.contexts.nodes.some(
5232
(context) => context.name === "Continuous Releases",
53-
);
54-
55-
return release
56-
? [
57-
{
58-
...commit,
59-
release,
60-
},
61-
]
62-
: [];
63-
}),
33+
),
34+
)
35+
.map((commit) => ({
36+
...commit,
37+
release: commit.statusCheckRollup.contexts.nodes.find(
38+
(context) => context.name === "Continuous Releases",
39+
)!,
40+
})),
6441
);
6542
6643
const selectedCommit = shallowRef<
@@ -137,39 +114,6 @@ onBeforeUnmount(() => {
137114
// Pagination
138115
const fetching = ref(false);
139116
const fetchMoreForceDisabled = ref(!commitsWithRelease.value.length);
140-
const switchingBranch = ref(false);
141-
142-
async function loadBranch(branchName: string) {
143-
if (switchingBranch.value) {
144-
return;
145-
}
146-
147-
const previousBranch = branch.name;
148-
149-
try {
150-
switchingBranch.value = true;
151-
selectedCommit.value = null;
152-
153-
const result = await $fetch("/api/repo/commits", {
154-
query: {
155-
owner: props.owner,
156-
repo: props.repo,
157-
branch: branchName,
158-
},
159-
});
160-
161-
Object.assign(branch, result);
162-
fetchMoreForceDisabled.value = !commitsWithRelease.value.length;
163-
} catch (error) {
164-
selectedBranch.value = previousBranch;
165-
} finally {
166-
switchingBranch.value = false;
167-
}
168-
}
169-
170-
async function onBranchChange() {
171-
await loadBranch(selectedBranch.value);
172-
}
173117
174118
async function fetchMore() {
175119
if (!branch.target.history.pageInfo.hasNextPage) {
@@ -189,7 +133,6 @@ async function fetchMore() {
189133
query: {
190134
owner: props.owner,
191135
repo: props.repo,
192-
branch: selectedBranch.value,
193136
cursor,
194137
},
195138
});
@@ -216,23 +159,10 @@ async function fetchMore() {
216159

217160
<template>
218161
<div class="flex flex-col gap-6">
219-
<div class="text-center flex justify-center items-center gap-2 opacity-80">
162+
<div class="text-center flex justify-center items-center gap-1 opacity-80">
220163
Continuous Releases from
221164
<UIcon name="i-ph-git-branch" />
222-
<select
223-
v-model="selectedBranch"
224-
class="px-2 py-1 rounded-md bg-transparent border border-gray-300 dark:border-gray-700 text-sm"
225-
:disabled="switchingBranch"
226-
@change="onBranchChange"
227-
>
228-
<option
229-
v-for="branchName of availableBranches"
230-
:key="branchName"
231-
:value="branchName"
232-
>
233-
{{ branchName }}
234-
</option>
235-
</select>
165+
{{ branch.name }}
236166
</div>
237167

238168
<div class="flex flex-col gap-2">

packages/app/server/api/repo/branches.get.ts

Lines changed: 0 additions & 65 deletions
This file was deleted.

packages/app/server/api/repo/commits.get.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { z } from "zod";
33
const querySchema = z.object({
44
owner: z.string(),
55
repo: z.string(),
6-
branch: z.string().optional(),
76
cursor: z.string().optional(),
87
page: z.string().optional(),
98
per_page: z.string().optional().default("10"),
@@ -29,7 +28,6 @@ export default defineEventHandler(async (event) => {
2928
);
3029

3130
const defaultBranch = repo.default_branch;
32-
const targetBranch = query.branch || defaultBranch;
3331

3432
const page = query.page
3533
? Number.parseInt(query.page)
@@ -43,7 +41,7 @@ export default defineEventHandler(async (event) => {
4341
{
4442
owner: query.owner,
4543
repo: query.repo,
46-
sha: targetBranch,
44+
sha: defaultBranch,
4745
page,
4846
per_page,
4947
},
@@ -120,10 +118,10 @@ export default defineEventHandler(async (event) => {
120118
const nextPage = hasNextPage ? (page + 1).toString() : null;
121119

122120
return {
123-
id: `branch-${targetBranch}`,
124-
name: targetBranch,
121+
id: `branch-${defaultBranch}`,
122+
name: defaultBranch,
125123
target: {
126-
id: `target-${targetBranch}`,
124+
id: `target-${defaultBranch}`,
127125
history: {
128126
nodes: commitsWithStatuses,
129127
pageInfo: {

0 commit comments

Comments
 (0)