-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathconvert.ts
34 lines (28 loc) · 1.01 KB
/
convert.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/**
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
* Licensed under the GNU Affero General Public License (AGPL).
* See License-AGPL.txt in the project root for license information.
*/
import { Repository } from "@gitpod/gitpod-protocol";
import { RepoURL } from "../repohost";
import { Gitea } from "./api";
export function convertRepo(repo: Gitea.Repository): Repository | undefined {
if (!repo.clone_url || !repo.name || !repo.owner?.login) {
return undefined;
}
const host = RepoURL.parseRepoUrl(repo.clone_url)!.host;
return {
host,
owner: repo.owner.login,
name: repo.name,
cloneUrl: repo.clone_url,
description: repo.description,
avatarUrl: repo.avatar_url,
webUrl: repo.html_url, // TODO: is this correct?
defaultBranch: repo.default_branch,
private: repo.private,
fork: undefined, // TODO: load fork somehow
};
}
// export function convertBranch(repo: Gitea.Repository): Branch | undefined {
// }