Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gitea support #8131

Draft
wants to merge 23 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'upstream/main' into gitea
  • Loading branch information
anbraten committed May 20, 2022
commit 944637acfcb2128eca17a2d7361c559296d1f13a
2 changes: 2 additions & 0 deletions components/dashboard/src/provider-utils.tsx
Original file line number Diff line number Diff line change
@@ -20,6 +20,8 @@ function iconForAuthProvider(type: string) {
return <img className="fill-current filter-grayscale w-5 h-5 ml-3 mr-3 my-auto" src={bitbucket} />;
case "Gitea":
return <img className="fill-current filter-grayscale w-5 h-5 ml-3 mr-3 my-auto" src={gitea} />;
case "BitbucketServer":
return <img className="fill-current filter-grayscale w-5 h-5 ml-3 mr-3 my-auto" src={bitbucket} />;
default:
return <></>;
}
6 changes: 4 additions & 2 deletions components/dashboard/src/settings/Integrations.tsx
Original file line number Diff line number Diff line change
@@ -448,7 +448,7 @@ function GitIntegrations() {
<div className="flex items-start sm:justify-between mb-2">
<div>
<h3>Git Integrations</h3>
<h2>Manage Git integrations for GitLab, GitHub or Gitea self-hosted instances.</h2>
<h2>Manage Git integrations for self-managed instances of GitLab, GitHub, Bitbucket or Gitea.</h2>
</div>
{providers.length !== 0 ? (
<div className="mt-3 flex mt-0">
@@ -759,7 +759,7 @@ export function GitIntegrationModal(
<div className="flex flex-col">
<span className="text-gray-500">
{props.headerText ||
"Configure a Git integration with a GitLab, GitHub or Gitea self-hosted instance."}
"Configure an integration with a self-managed instance of GitLab, GitHub, Bitbucket or Gitea."}
</span>
</div>

@@ -779,6 +779,8 @@ export function GitIntegrationModal(
<option value="GitHub">GitHub</option>
<option value="GitLab">GitLab</option>
<option value="Gitea">Gitea</option>
{!isGitpodIo() && <option value="Bitbucket">Bitbucket</option>}
<option value="BitbucketServer">Bitbucket Server</option>
</select>
</div>
)}
1 change: 1 addition & 0 deletions components/server/ee/src/server.ts
Original file line number Diff line number Diff line change
@@ -22,6 +22,7 @@ export class ServerEE<C extends GitpodClient, S extends GitpodServer> extends Se
@inject(GitLabApp) protected readonly gitLabApp: GitLabApp;
@inject(BitbucketApp) protected readonly bitbucketApp: BitbucketApp;
@inject(GiteaApp) protected readonly giteaApp: GiteaApp;
@inject(BitbucketServerApp) protected readonly bitbucketServerApp: BitbucketServerApp;
@inject(SnapshotService) protected readonly snapshotService: SnapshotService;
@inject(GitHubEnterpriseApp) protected readonly gitHubEnterpriseApp: GitHubEnterpriseApp;

28 changes: 20 additions & 8 deletions components/server/src/auth/auth-provider-service.ts
Original file line number Diff line number Diff line change
@@ -13,7 +13,9 @@ import { v4 as uuidv4 } from "uuid";
import { oauthUrls as githubUrls } from "../github/github-urls";
import { oauthUrls as gitlabUrls } from "../gitlab/gitlab-urls";
import { oauthUrls as giteaUrls } from "../gitea/gitea-urls";
import { log } from '@gitpod/gitpod-protocol/lib/util/logging';
import { oauthUrls as bbsUrls } from "../bitbucket-server/bitbucket-server-urls";
import { oauthUrls as bbUrls } from "../bitbucket/bitbucket-urls";
import { log } from "@gitpod/gitpod-protocol/lib/util/logging";

@injectable()
export class AuthProviderService {
@@ -112,13 +114,23 @@ export class AuthProviderService {
}
protected initializeNewProvider(newEntry: AuthProviderEntry.NewEntry): AuthProviderEntry {
const { host, type, clientId, clientSecret } = newEntry;
let urls: { authorizationUrl: string, tokenUrl: string } | undefined = undefined;
if (type === "GitHub") {
urls =githubUrls(host);
} else if (type === "GitLab") {
urls =gitlabUrls(host);
} else if (type === "Gitea") {
urls = giteaUrls(host);
let urls;
switch (type) {
case "GitHub":
urls = githubUrls(host);
break;
case "GitLab":
urls = gitlabUrls(host);
break;
case "BitbucketServer":
urls = bbsUrls(host);
break;
case "Gitea":
urls = giteaUrls(host);
break;
case "Bitbucket":
urls = bbUrls(host);
break;
}
if (!urls) {
throw new Error("Unexpected service type.");
9 changes: 7 additions & 2 deletions components/server/src/projects/projects-service.ts
Original file line number Diff line number Diff line change
@@ -151,8 +151,13 @@ export class ProjectsService {
const hostContext = parsedUrl?.host ? this.hostContextProvider.get(parsedUrl?.host) : undefined;
const authProvider = hostContext && hostContext.authProvider.info;
const type = authProvider && authProvider.authProviderType;
// TODO: handle gitea
if (type === "GitLab" || type === "Bitbucket" || AuthProviderInfo.isGitHubEnterprise(authProvider)) {
if (
type === "GitLab" ||
type === "Bitbucket" ||
type === "BitbucketServer" ||
type === "Gitea" ||
(type === "GitHub" && (authProvider?.host !== "github.com" || !this.config.githubApp?.enabled))
) {
const repositoryService = hostContext?.services?.repositoryService;
if (repositoryService) {
// Note: For GitLab, we expect .canInstallAutomatedPrebuilds() to always return true, because earlier
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
@@ -12155,7 +12155,11 @@ node-emoji@^1.11.0:
dependencies:
lodash "^4.17.21"

<<<<<<< HEAD
node-fetch@2.6.7, node-fetch@^2.1.2, node-fetch@^2.6.0, node-fetch@^2.6.1, node-fetch@^2.6.5, node-fetch@^2.6.7:
=======
node-fetch@^2.6.0, node-fetch@^2.6.1, node-fetch@^2.6.5, node-fetch@^2.6.7:
>>>>>>> upstream/main
version "2.6.7"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad"
integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==
You are viewing a condensed version of this merge commit. You can view the full changes here.