├── github-plugin
├── src
│ ├── main
│ │ ├── resources
│ │ │ ├── static
│ │ │ │ ├── footer.html
│ │ │ │ ├── header.html
│ │ │ │ ├── images
│ │ │ │ │ ├── done.png
│ │ │ │ │ ├── failed.png
│ │ │ │ │ ├── cancelled.png
│ │ │ │ │ ├── spinner-24px.gif
│ │ │ │ │ └── spinner-32px.gif
│ │ │ │ ├── styles.html
│ │ │ │ ├── scripts.html
│ │ │ │ ├── css
│ │ │ │ │ └── github-plugin.css
│ │ │ │ ├── js
│ │ │ │ │ ├── jquery.cookie.min.js
│ │ │ │ │ ├── datatables
│ │ │ │ │ │ └── license-bsd.txt
│ │ │ │ │ └── jquery
│ │ │ │ │ │ ├── jquery.hotkeys.js
│ │ │ │ │ │ ├── jquery.color.js
│ │ │ │ │ │ ├── jquery.table-hotkeys.js
│ │ │ │ │ │ └── jquery.schedule.js
│ │ │ │ ├── account.html
│ │ │ │ ├── scope.html
│ │ │ │ ├── pullrequests.html
│ │ │ │ └── repositories.html
│ │ │ └── Documentation
│ │ │ │ └── about.md
│ │ └── java
│ │ │ └── com
│ │ │ ├── googlesource
│ │ │ └── gerrit
│ │ │ │ └── plugins
│ │ │ │ └── github
│ │ │ │ ├── git
│ │ │ │ ├── PullRequestImportType.java
│ │ │ │ ├── JobCancelledException.java
│ │ │ │ ├── GitJob.java
│ │ │ │ ├── ProtectedBranchFoundException.java
│ │ │ │ ├── MagicRefFoundException.java
│ │ │ │ ├── QuotaEnforcedException.java
│ │ │ │ ├── GitDestinationAlreadyExistsException.java
│ │ │ │ ├── GitDestinationNotWritableException.java
│ │ │ │ ├── GitException.java
│ │ │ │ ├── BatchImporter.java
│ │ │ │ ├── ImportStep.java
│ │ │ │ ├── AbstractCloneJob.java
│ │ │ │ ├── ErrorJob.java
│ │ │ │ ├── JobExecutor.java
│ │ │ │ ├── PullRequestImporter.java
│ │ │ │ ├── GitCloneFailedException.java
│ │ │ │ ├── GitHubUser.java
│ │ │ │ ├── GitJobStatus.java
│ │ │ │ ├── ProtectedBranchesCheckStep.java
│ │ │ │ ├── MagicRefCheckStep.java
│ │ │ │ ├── ReplicateProjectStep.java
│ │ │ │ ├── QuotaCheckStep.java
│ │ │ │ ├── ReplicationRemoteConfigBuilder.java
│ │ │ │ └── GitImporter.java
│ │ │ │ ├── wizard
│ │ │ │ ├── WrappedResponse.java
│ │ │ │ ├── VelocityController.java
│ │ │ │ ├── JobStatusController.java
│ │ │ │ ├── ControllerErrors.java
│ │ │ │ ├── RepositoriesCloneCancelController.java
│ │ │ │ ├── PullRequestImportStatusController.java
│ │ │ │ ├── RepositoriesCloneStatusController.java
│ │ │ │ ├── PullRequestImportController.java
│ │ │ │ └── RepositoriesCloneController.java
│ │ │ │ ├── GitHubURL.java
│ │ │ │ ├── InvalidGitHubConfigException.java
│ │ │ │ ├── GitHubURLProvider.java
│ │ │ │ ├── replication
│ │ │ │ ├── ReplicationStatusStore.java
│ │ │ │ ├── GerritGsonProvider.java
│ │ │ │ ├── RemoteSiteUser.java
│ │ │ │ ├── ListProjectReplicationStatus.java
│ │ │ │ ├── ReplicationStatusListener.java
│ │ │ │ └── ReplicationStatusFlatFile.java
│ │ │ │ ├── OnStartStop.java
│ │ │ │ ├── notification
│ │ │ │ ├── WebhookEventHandler.java
│ │ │ │ ├── PingHandler.java
│ │ │ │ └── PullRequestHandler.java
│ │ │ │ ├── velocity
│ │ │ │ └── PluginVelocityModel.java
│ │ │ │ ├── group
│ │ │ │ ├── GitHubGroup.java
│ │ │ │ ├── CurrentUsernameProvider.java
│ │ │ │ ├── GitHubTeamGroup.java
│ │ │ │ ├── GitHubGroupMembership.java
│ │ │ │ └── GitHubOrganisationGroup.java
│ │ │ │ ├── GitHubTopMenu.java
│ │ │ │ ├── GitHubOAuthServiceProvider.java
│ │ │ │ ├── GuiceModule.java
│ │ │ │ └── filters
│ │ │ │ └── GitHubGroupCacheRefreshFilter.java
│ │ │ └── google
│ │ │ └── gerrit
│ │ │ └── server
│ │ │ └── account
│ │ │ └── AccountImporter.java
│ └── test
│ │ └── java
│ │ └── com
│ │ └── googlesource
│ │ └── gerrit
│ │ └── plugins
│ │ └── github
│ │ └── FakeHttpSession.java
├── .gitignore
├── web
│ ├── main.ts
│ ├── tsconfig.json
│ ├── eslint.config.js
│ ├── BUILD
│ └── gr-github-oauth-progress.ts
├── tsconfig.json
├── rollup.config.mjs
├── package.json
├── tsconfig-plugins-base.json
└── BUILD
├── .gitignore
├── Jenkinsfile
├── BUILD
├── github-oauth
├── src
│ ├── main
│ │ └── java
│ │ │ └── com
│ │ │ ├── googlesource
│ │ │ └── gerrit
│ │ │ │ └── plugins
│ │ │ │ └── github
│ │ │ │ ├── oauth
│ │ │ │ ├── ScopeKey.java
│ │ │ │ ├── UserScopedProvider.java
│ │ │ │ ├── ScopedProvider.java
│ │ │ │ ├── ConcurrentFileBasedConfigWriteException.java
│ │ │ │ ├── OAuthTokenException.java
│ │ │ │ ├── AuthenticatedLoginHttpRequest.java
│ │ │ │ ├── GsonProvider.java
│ │ │ │ ├── CipherException.java
│ │ │ │ ├── GitHubLogoutServletResponse.java
│ │ │ │ ├── VirtualDomainConfig.java
│ │ │ │ ├── GitHubHttpConnector.java
│ │ │ │ ├── AuthenticatedPathHttpRequest.java
│ │ │ │ ├── OAuthGitWrappedResponse.java
│ │ │ │ ├── CanonicalWebUrls.java
│ │ │ │ ├── AuthenticatedHttpRequest.java
│ │ │ │ ├── HttpSessionProvider.java
│ │ │ │ ├── OAuthCache.java
│ │ │ │ ├── PooledHttpClientProvider.java
│ │ │ │ ├── IdentifiedUserGitHubLoginProvider.java
│ │ │ │ └── PasswordGenerator.java
│ │ │ │ └── groups
│ │ │ │ └── OrganizationStructure.java
│ │ │ └── google
│ │ │ └── gerrit
│ │ │ └── httpd
│ │ │ └── XGerritAuth.java
│ └── test
│ │ └── java
│ │ └── com
│ │ └── googlesource
│ │ └── gerrit
│ │ └── plugins
│ │ └── github
│ │ └── oauth
│ │ └── PasswordGeneratorTest.java
└── BUILD
├── java_library_without_header_compilation.bzl
└── external_plugin_deps.bzl
/github-plugin/src/main/resources/static/footer.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/github-plugin/src/main/resources/static/header.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | target
2 | .project
3 | .classpath
4 | .settings
5 | .idea
6 | *.iml
7 | .DS_Store
8 |
--------------------------------------------------------------------------------
/github-plugin/src/main/resources/static/images/done.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GerritCodeReview/plugins_github/HEAD/github-plugin/src/main/resources/static/images/done.png
--------------------------------------------------------------------------------
/github-plugin/src/main/resources/static/images/failed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GerritCodeReview/plugins_github/HEAD/github-plugin/src/main/resources/static/images/failed.png
--------------------------------------------------------------------------------
/github-plugin/src/main/resources/static/images/cancelled.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GerritCodeReview/plugins_github/HEAD/github-plugin/src/main/resources/static/images/cancelled.png
--------------------------------------------------------------------------------
/github-plugin/src/main/resources/static/images/spinner-24px.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GerritCodeReview/plugins_github/HEAD/github-plugin/src/main/resources/static/images/spinner-24px.gif
--------------------------------------------------------------------------------
/github-plugin/src/main/resources/static/images/spinner-32px.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GerritCodeReview/plugins_github/HEAD/github-plugin/src/main/resources/static/images/spinner-32px.gif
--------------------------------------------------------------------------------
/github-plugin/.gitignore:
--------------------------------------------------------------------------------
1 | /target
2 | /.classpath
3 | /.project
4 | /.settings/org.maven.ide.eclipse.prefs
5 | /.settings/org.eclipse.m2e.core.prefs
6 | /node_modules
7 | yarn-error.log
8 | /.rollup.cache
9 |
--------------------------------------------------------------------------------
/github-plugin/src/main/resources/static/styles.html:
--------------------------------------------------------------------------------
1 |
4 |
5 |
--------------------------------------------------------------------------------
/Jenkinsfile:
--------------------------------------------------------------------------------
1 | pluginPipeline(formatCheckId: 'gerritforge:github-format-3852e64366bb37d13b8baf8af9b15cfd38eb9227',
2 | buildCheckId: 'gerritforge:github-3852e64366bb37d13b8baf8af9b15cfd38eb9227',
3 | gjfVersion: '1.22.0')
4 |
--------------------------------------------------------------------------------
/github-plugin/web/main.ts:
--------------------------------------------------------------------------------
1 | import '@gerritcodereview/typescript-api/gerrit';
2 | import './gr-github-oauth-progress';
3 |
4 | window.Gerrit.install(plugin => {
5 | plugin.registerCustomComponent(
6 | 'auth-link',
7 | 'gr-github-oauth-progress',
8 | { replace: true });
9 | });
10 |
--------------------------------------------------------------------------------
/github-plugin/web/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../../tsconfig-plugins-base.json",
3 | "compilerOptions": {
4 | "experimentalDecorators": true,
5 | /* outDir for IDE (overridden by Bazel rule arg) */
6 | "outDir": "../../../../.ts-out/plugins/github-plugin/ui",
7 | },
8 | "include": [
9 | "**/*",
10 | ],
11 | }
--------------------------------------------------------------------------------
/github-plugin/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | /* TODO: should be change to ./node_modules/@gerritcodereview/typescript-api/tsconfig-plugins-base.json' when NPM paclage is fixed */
3 | "extends": "./tsconfig-plugins-base.json",
4 | "compilerOptions": {
5 | "rootDir": ".",
6 | "experimentalDecorators": true,
7 | "skipLibCheck": true,
8 | "outDir": "./target/web"
9 | },
10 | }
--------------------------------------------------------------------------------
/github-plugin/src/main/resources/static/scripts.html:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/github-plugin/web/eslint.config.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @license
3 | * Copyright 2022 Google LLC
4 | * SPDX-License-Identifier: Apache-2.0
5 | */
6 |
7 | const {defineConfig} = require('eslint/config');
8 |
9 | // eslint-disable-next-line no-undef
10 | __plugindir = 'github/github-plugin/web';
11 |
12 | const gerritEslint = require('../../eslint.config.js');
13 |
14 | module.exports = defineConfig([
15 | {
16 | extends: [gerritEslint],
17 | },
18 | ]);
--------------------------------------------------------------------------------
/github-plugin/rollup.config.mjs:
--------------------------------------------------------------------------------
1 | import terser from '@rollup/plugin-terser';
2 | import { nodeResolve } from '@rollup/plugin-node-resolve';
3 |
4 | export default {
5 | input: 'target/web/src/main/ts/main.js',
6 | treeshake: false,
7 | output: {
8 | format: 'iife',
9 | compact: true,
10 | file: 'target/classes/static/github-plugin.js',
11 | },
12 | context: 'window',
13 | plugins: [
14 | terser(),
15 | nodeResolve(),
16 | ],
17 | }
--------------------------------------------------------------------------------
/github-plugin/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "github-oauth-ui",
3 | "description": "UI for the Gerrit GitHub OAuth plugin",
4 | "browser": true,
5 | "dependencies": {
6 | "@gerritcodereview/typescript-api": "^3.8.0",
7 | "@lit/ts-transformers": "^1.1.3",
8 | "@polymer/polymer": "^3.5.1",
9 | "@rollup/plugin-node-resolve": "^15.2.1",
10 | "@rollup/plugin-terser": "^0.4.3",
11 | "lit": "^2.8.0",
12 | "rollup": "^3.29.4",
13 | "typescript": "^4.9.5"
14 | },
15 | "license": "Apache-2.0",
16 | "private": true,
17 | "scripts": {
18 | "build": "tsc && rollup -c"
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/BUILD:
--------------------------------------------------------------------------------
1 | load("//tools/bzl:genrule2.bzl", "genrule2")
2 |
3 | genrule(
4 | name = "github",
5 | srcs = [
6 | ":github-plugin",
7 | ":github-oauth",
8 | ],
9 | outs = ["github.zip"],
10 | cmd = "zip -o $@ $(SRCS)",
11 | )
12 |
13 | genrule(
14 | name = "github-oauth",
15 | srcs = ["//plugins/github/github-oauth:github-oauth_deploy.jar"],
16 | outs = ["github-oauth.jar"],
17 | cmd = "cp $< $@",
18 | )
19 |
20 | genrule(
21 | name = "github-plugin",
22 | srcs = ["//plugins/github/github-plugin"],
23 | outs = ["github-plugin.jar"],
24 | cmd = "cp $< $@",
25 | )
26 |
--------------------------------------------------------------------------------
/github-plugin/src/main/resources/static/css/github-plugin.css:
--------------------------------------------------------------------------------
1 | .repo-sync span.status {
2 | width: 24px;
3 | height: 24px;
4 | display: inline-block;
5 | }
6 |
7 | .repo-sync .sync {
8 | background-image: url("../images/spinner-24px.gif");
9 | }
10 |
11 | .repo-sync .failed {
12 | background-image: url("../images/failed.png");
13 | }
14 |
15 | .repo-sync .complete {
16 | background-image: url("../images/done.png");
17 | }
18 |
19 | .repo-sync .cancelled {
20 | background-image: url("../images/cancelled.png");
21 | }
22 |
23 | div.loading {
24 | margin-left: 30px;
25 | background-image: url("../images/spinner-32px.gif");
26 | background-repeat: no-repeat;
27 | padding-left: 50px;
28 | width: 300px;
29 | height: 40px;
30 | display: inline-block;
31 | }
32 |
--------------------------------------------------------------------------------
/github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/ScopeKey.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2018 The Android Open Source Project
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package com.googlesource.gerrit.plugins.github.oauth;
16 |
17 | public record ScopeKey(String name, String description, int sequence) {}
18 |
--------------------------------------------------------------------------------
/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/PullRequestImportType.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2013 The Android Open Source Project
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | package com.googlesource.gerrit.plugins.github.git;
15 |
16 | public enum PullRequestImportType {
17 | Commits,
18 | Squash
19 | }
20 |
--------------------------------------------------------------------------------
/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/JobCancelledException.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2013 The Android Open Source Project
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | package com.googlesource.gerrit.plugins.github.git;
15 |
16 | public class JobCancelledException extends Exception {
17 | private static final long serialVersionUID = 4358474273091335160L;
18 | }
19 |
--------------------------------------------------------------------------------
/github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/UserScopedProvider.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2014 The Android Open Source Project
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package com.googlesource.gerrit.plugins.github.oauth;
16 |
17 | import com.google.gerrit.common.Nullable;
18 | import com.google.inject.Provider;
19 |
20 | public interface UserScopedProvider extends Provider {
21 | @Nullable
22 | T get(String username);
23 | }
24 |
--------------------------------------------------------------------------------
/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/GitJob.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2013 The Android Open Source Project
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | package com.googlesource.gerrit.plugins.github.git;
15 |
16 | public interface GitJob extends Runnable {
17 |
18 | GitJobStatus getStatus();
19 |
20 | int getIndex();
21 |
22 | String getOrganisation();
23 |
24 | String getRepository();
25 |
26 | public abstract void cancel();
27 | }
28 |
--------------------------------------------------------------------------------
/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/ProtectedBranchFoundException.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2021 The Android Open Source Project
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package com.googlesource.gerrit.plugins.github.git;
16 |
17 | public class ProtectedBranchFoundException extends Exception {
18 |
19 | private static final long serialVersionUID = 1L;
20 |
21 | public ProtectedBranchFoundException(String msg) {
22 | super(msg);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/WrappedResponse.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2013 The Android Open Source Project
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | package com.googlesource.gerrit.plugins.github.wizard;
15 |
16 | import javax.servlet.http.HttpServletResponse;
17 | import javax.servlet.http.HttpServletResponseWrapper;
18 |
19 | public class WrappedResponse extends HttpServletResponseWrapper {
20 |
21 | public WrappedResponse(HttpServletResponse response) {
22 | super(response);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/ScopedProvider.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2014 The Android Open Source Project
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | package com.googlesource.gerrit.plugins.github.oauth;
15 |
16 | import com.google.inject.Provider;
17 | import javax.servlet.http.HttpServletRequest;
18 |
19 | public interface ScopedProvider extends Provider {
20 | T get(HttpServletRequest request);
21 |
22 | void clear(HttpServletRequest request);
23 |
24 | HttpServletRequest getScopedRequest();
25 | }
26 |
--------------------------------------------------------------------------------
/github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/ConcurrentFileBasedConfigWriteException.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2013 The Android Open Source Project
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | package com.googlesource.gerrit.plugins.github.oauth;
15 |
16 | import java.io.IOException;
17 |
18 | public class ConcurrentFileBasedConfigWriteException extends IOException {
19 | private static final long serialVersionUID = -4019991986934953417L;
20 |
21 | public ConcurrentFileBasedConfigWriteException(String message) {
22 | super(message);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/github-plugin/web/BUILD:
--------------------------------------------------------------------------------
1 | load("//tools/js:eslint.bzl", "plugin_eslint")
2 | load("//tools/bzl:js.bzl", "gerrit_js_bundle")
3 | load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project")
4 |
5 | package_group(
6 | name = "visibility",
7 | packages = ["//plugins/github/github-plugin/..."],
8 | )
9 |
10 | package(default_visibility = [":visibility"])
11 |
12 | ts_config(
13 | name = "tsconfig",
14 | src = "tsconfig.json",
15 | deps = [
16 | "//plugins:tsconfig-plugins-base.json",
17 | ],
18 | )
19 |
20 | ts_project(
21 | name = "github-plugin-ts",
22 | srcs = glob(
23 | ["**/*.ts"],
24 | ),
25 | incremental = True,
26 | out_dir = "_bazel_ts_out",
27 | tsc = "//tools/node_tools:tsc-bin",
28 | tsconfig = ":tsconfig",
29 | deps = [
30 | "@plugins_npm//@gerritcodereview/typescript-api",
31 | "@plugins_npm//lit",
32 | "@plugins_npm//rxjs",
33 | ],
34 | )
35 |
36 | gerrit_js_bundle(
37 | name = "github-plugin",
38 | srcs = [":github-plugin-ts"],
39 | entry_point = "_bazel_ts_out/main.js",
40 | )
41 |
42 | plugin_eslint()
43 |
--------------------------------------------------------------------------------
/github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/OAuthTokenException.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2013 The Android Open Source Project
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | package com.googlesource.gerrit.plugins.github.oauth;
15 |
16 | public class OAuthTokenException extends Exception {
17 | public OAuthTokenException(String message, Exception e) {
18 | super(message, e);
19 | }
20 |
21 | public OAuthTokenException(String message) {
22 | super(message);
23 | }
24 |
25 | private static final long serialVersionUID = -2177841968402814337L;
26 | }
27 |
--------------------------------------------------------------------------------
/github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/AuthenticatedLoginHttpRequest.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2014 The Android Open Source Project
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | package com.googlesource.gerrit.plugins.github.oauth;
15 |
16 | import javax.servlet.http.HttpServletRequest;
17 |
18 | public class AuthenticatedLoginHttpRequest extends AuthenticatedPathHttpRequest {
19 |
20 | public AuthenticatedLoginHttpRequest(
21 | HttpServletRequest request, String userHeader, String username) {
22 | super(request, "/login", userHeader, username);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/github-oauth/BUILD:
--------------------------------------------------------------------------------
1 | load("//tools/bzl:junit.bzl", "junit_tests")
2 | load("//tools/bzl:plugin.bzl", "PLUGIN_DEPS", "PLUGIN_DEPS_NEVERLINK")
3 |
4 | java_binary(
5 | name = "github-oauth",
6 | main_class = "Dummy",
7 | visibility = ["//visibility:public"],
8 | runtime_deps = [":github-oauth-lib"],
9 | )
10 |
11 | java_library(
12 | name = "github-oauth-lib",
13 | srcs = glob(["src/main/java/**/*.java"]),
14 | visibility = ["//visibility:public"],
15 | deps = PLUGIN_DEPS_NEVERLINK + [
16 | "//lib:servlet-api",
17 | "@bridge-method-annotation//jar",
18 | "@bridge-method-injector//jar",
19 | "@commons-io//jar",
20 | "@github-api//jar",
21 | "@jackson-annotations//jar",
22 | "@jackson-core//jar",
23 | "@jackson-databind//jar",
24 | "@org-ow2-asm-commons//jar",
25 | "@org-ow2-asm-tree//jar",
26 | "@org-ow2-asm//jar",
27 | ],
28 | )
29 |
30 | junit_tests(
31 | name = "github-oauth_tests",
32 | srcs = glob(["src/test/java/**/*.java"]),
33 | tags = ["github"],
34 | deps = PLUGIN_DEPS + [
35 | ":github-oauth-lib",
36 | ],
37 | )
38 |
--------------------------------------------------------------------------------
/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/GitHubURL.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2013 The Android Open Source Project
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | package com.googlesource.gerrit.plugins.github;
15 |
16 | import com.google.inject.BindingAnnotation;
17 | import java.lang.annotation.ElementType;
18 | import java.lang.annotation.Retention;
19 | import java.lang.annotation.RetentionPolicy;
20 | import java.lang.annotation.Target;
21 |
22 | @Target({ElementType.PARAMETER, ElementType.FIELD})
23 | @Retention(RetentionPolicy.RUNTIME)
24 | @BindingAnnotation
25 | public @interface GitHubURL {}
26 |
--------------------------------------------------------------------------------
/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/MagicRefFoundException.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2021 The Android Open Source Project
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | package com.googlesource.gerrit.plugins.github.git;
15 |
16 | public class MagicRefFoundException extends GitException {
17 |
18 | private static final long serialVersionUID = 1L;
19 |
20 | public MagicRefFoundException(String message) {
21 | super(message);
22 | }
23 |
24 | @Override
25 | public String getErrorDescription() {
26 | return String.format("Clash with Gerrit magic refs. %s", getMessage());
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/InvalidGitHubConfigException.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2013 The Android Open Source Project
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | package com.googlesource.gerrit.plugins.github;
15 |
16 | public class InvalidGitHubConfigException extends RuntimeException {
17 | private static final long serialVersionUID = 7006333621290095732L;
18 |
19 | public InvalidGitHubConfigException(String fromTo) {
20 | super(
21 | "Invalid configuration: invalid value "
22 | + fromTo
23 | + ": expected 'from-page.html => to-page.html");
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/QuotaEnforcedException.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2025 The Android Open Source Project
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | package com.googlesource.gerrit.plugins.github.git;
15 |
16 | public class QuotaEnforcedException extends GitException {
17 |
18 | private static final long serialVersionUID = 1L;
19 |
20 | public QuotaEnforcedException(String message, Exception e) {
21 | super(message, e);
22 | }
23 |
24 | @Override
25 | public String getErrorDescription() {
26 | return String.format("Quota enforcing error. %s", getMessage());
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/GitHubURLProvider.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2013 The Android Open Source Project
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | package com.googlesource.gerrit.plugins.github;
15 |
16 | import com.google.inject.Inject;
17 | import com.google.inject.Provider;
18 |
19 | public class GitHubURLProvider implements Provider {
20 |
21 | private String gitHubUrl;
22 |
23 | @Inject
24 | public GitHubURLProvider(GitHubConfig gitHubConfig) {
25 | this.gitHubUrl = gitHubConfig.gitHubUrl;
26 | }
27 |
28 | @Override
29 | public String get() {
30 | return gitHubUrl;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/java_library_without_header_compilation.bzl:
--------------------------------------------------------------------------------
1 | # See https://github.com/bazelbuild/bazel/issues/12837
2 | # for workaround suggestion for incompatibility between
3 | # Bazel Turbine processor and Lombok library.
4 |
5 | def _java_header_compilation_transition(settings, attr):
6 | _ignore = (settings, attr)
7 | return {"//command_line_option:java_header_compilation": "False"}
8 |
9 | java_header_compilation_transition = transition(
10 | implementation = _java_header_compilation_transition,
11 | inputs = [],
12 | outputs = ["//command_line_option:java_header_compilation"],
13 | )
14 |
15 | def _java_library_without_header_compilation(ctx):
16 | return [java_common.merge([d[JavaInfo] for d in ctx.attr.dep])]
17 |
18 | java_library_without_header_compilation = rule(
19 | implementation = _java_library_without_header_compilation,
20 | attrs = {
21 | "dep": attr.label(
22 | providers = [JavaInfo],
23 | mandatory = True,
24 | cfg = java_header_compilation_transition,
25 | ),
26 | "_allowlist_function_transition": attr.label(
27 | default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
28 | ),
29 | },
30 | )
31 |
--------------------------------------------------------------------------------
/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/replication/ReplicationStatusStore.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2015 The Android Open Source Project
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package com.googlesource.gerrit.plugins.github.replication;
16 |
17 | import com.google.gerrit.entities.Project;
18 | import com.google.gson.JsonObject;
19 | import java.io.IOException;
20 | import java.util.List;
21 |
22 | public interface ReplicationStatusStore {
23 |
24 | public void set(Project.NameKey projectKey, String refKey, JsonObject statusEvent)
25 | throws IOException;
26 |
27 | public List list(Project.NameKey projectKey) throws IOException;
28 | }
29 |
--------------------------------------------------------------------------------
/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/replication/GerritGsonProvider.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2013 The Android Open Source Project
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package com.googlesource.gerrit.plugins.github.replication;
16 |
17 | import com.google.gerrit.json.OutputFormat;
18 | import com.google.gson.Gson;
19 | import com.google.inject.Provider;
20 | import com.google.inject.Singleton;
21 |
22 | @Singleton
23 | public class GerritGsonProvider implements Provider {
24 | private final Gson gerritStyleGson = OutputFormat.JSON_COMPACT.newGson();
25 |
26 | @Override
27 | public Gson get() {
28 | return gerritStyleGson;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/GitDestinationAlreadyExistsException.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2013 The Android Open Source Project
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | package com.googlesource.gerrit.plugins.github.git;
15 |
16 | public class GitDestinationAlreadyExistsException extends GitException {
17 | private static final long serialVersionUID = -6202681486717426148L;
18 |
19 | public GitDestinationAlreadyExistsException(String projectName) {
20 | super("Git project " + projectName + " already exists");
21 | }
22 |
23 | @Override
24 | public String getErrorDescription() {
25 | return "A repository with the same name already exists";
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/github-plugin/src/main/resources/static/js/jquery.cookie.min.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Cookie plugin
3 | *
4 | * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
5 | * Dual licensed under the MIT and GPL licenses:
6 | * http://www.opensource.org/licenses/mit-license.php
7 | * http://www.gnu.org/licenses/gpl.html
8 | *
9 | */
10 | jQuery.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';options.expires=-1}var expires='';if(options.expires&&(typeof options.expires=='number'||options.expires.toUTCString)){var date;if(typeof options.expires=='number'){date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000))}else{date=options.expires}expires='; expires='+date.toUTCString()}var path=options.path?'; path='+(options.path):'';var domain=options.domain?'; domain='+(options.domain):'';var secure=options.secure?'; secure':'';document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('')}else{var cookieValue=null;if(document.cookie&&document.cookie!=''){var cookies=document.cookie.split(';');for(var i=0;i {
25 |
26 | @Override
27 | public Gson get() {
28 | return new GsonBuilder()
29 | .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
30 | .create();
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/GitDestinationNotWritableException.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2013 The Android Open Source Project
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | package com.googlesource.gerrit.plugins.github.git;
15 |
16 | import java.io.File;
17 |
18 | public class GitDestinationNotWritableException extends GitException {
19 | private static final long serialVersionUID = -6486633812790391401L;
20 |
21 | public GitDestinationNotWritableException(File destDirectory) {
22 | super("Destination Git directory " + destDirectory + " is not writable");
23 | }
24 |
25 | @Override
26 | public String getErrorDescription() {
27 | return "Output destination directory is not writeable";
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/GitException.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2013 The Android Open Source Project
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | package com.googlesource.gerrit.plugins.github.git;
15 |
16 | import java.io.IOException;
17 |
18 | public class GitException extends IOException {
19 | private static final long serialVersionUID = -1180349547385523064L;
20 |
21 | public GitException() {
22 | super();
23 | }
24 |
25 | public GitException(String message) {
26 | super(message);
27 | }
28 |
29 | public GitException(Throwable cause) {
30 | super(cause);
31 | }
32 |
33 | public GitException(String message, Throwable cause) {
34 | super(message, cause);
35 | }
36 |
37 | public String getErrorDescription() {
38 | return getMessage();
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/VelocityController.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2013 The Android Open Source Project
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | package com.googlesource.gerrit.plugins.github.wizard;
15 |
16 | import com.google.gerrit.server.IdentifiedUser;
17 | import com.googlesource.gerrit.plugins.github.oauth.GitHubLogin;
18 | import java.io.IOException;
19 | import javax.servlet.ServletException;
20 | import javax.servlet.http.HttpServletRequest;
21 | import javax.servlet.http.HttpServletResponse;
22 |
23 | public interface VelocityController {
24 |
25 | void doAction(
26 | IdentifiedUser user,
27 | GitHubLogin hubLogin,
28 | HttpServletRequest req,
29 | HttpServletResponse resp,
30 | ControllerErrors errors)
31 | throws ServletException, IOException;
32 | }
33 |
--------------------------------------------------------------------------------
/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/OnStartStop.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2012 The Android Open Source Project
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package com.googlesource.gerrit.plugins.github;
16 |
17 | import com.google.gerrit.extensions.events.LifecycleListener;
18 | import com.google.inject.Inject;
19 | import com.google.inject.Singleton;
20 | import org.slf4j.Logger;
21 | import org.slf4j.LoggerFactory;
22 |
23 | @Singleton
24 | public class OnStartStop implements LifecycleListener {
25 | private static final Logger LOG = LoggerFactory.getLogger(OnStartStop.class);
26 |
27 | @Inject
28 | public OnStartStop() {}
29 |
30 | @Override
31 | public void start() {
32 | LOG.info("Starting up ...");
33 | }
34 |
35 | @Override
36 | public void stop() {
37 | LOG.info("Stopping ...");
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/notification/WebhookEventHandler.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2015 The Android Open Source Project
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package com.googlesource.gerrit.plugins.github.notification;
16 |
17 | import java.io.IOException;
18 | import org.kohsuke.github.GHEvent;
19 |
20 | /**
21 | * Abstract interface to handler which is responsible for a specific github webhook event type.
22 | *
23 | *
Implementation classes must be named by the convention which {@link
24 | * WebhookServlet#getWebhookClassName(GHEvent)} defines.
25 | *
26 | * @param Type of payload. Must be consistent to the event type.
27 | * @return true if the event has been successfully processed
28 | */
29 | interface WebhookEventHandler {
30 | Class getPayloadType();
31 |
32 | boolean doAction(T payload) throws IOException;
33 | }
34 |
--------------------------------------------------------------------------------
/github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/CipherException.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2022 The Android Open Source Project
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | package com.googlesource.gerrit.plugins.github.oauth;
15 |
16 | import java.io.IOException;
17 |
18 | /**
19 | * Signals that a cipher exception has occurred. This class can be used to represent exception for
20 | * both encryption and decryption failures
21 | */
22 | public class CipherException extends IOException {
23 | private static final long serialVersionUID = 1L;
24 |
25 | /**
26 | * Constructs a {@code CipherException} with the specified detail message and cause
27 | *
28 | * @param message The detail message of the failure
29 | * @param cause The cause of the failure
30 | */
31 | public CipherException(String message, Exception cause) {
32 | super(message, cause);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/GitHubLogoutServletResponse.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2013 The Android Open Source Project
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | package com.googlesource.gerrit.plugins.github.oauth;
15 |
16 | import com.google.common.base.MoreObjects;
17 | import java.io.IOException;
18 | import javax.servlet.http.HttpServletResponse;
19 | import javax.servlet.http.HttpServletResponseWrapper;
20 |
21 | public class GitHubLogoutServletResponse extends HttpServletResponseWrapper {
22 | private String redirectUrl;
23 |
24 | public GitHubLogoutServletResponse(HttpServletResponse response, String redirectUrl) {
25 | super(response);
26 | this.redirectUrl = redirectUrl;
27 | }
28 |
29 | @Override
30 | public void sendRedirect(String location) throws IOException {
31 | super.sendRedirect(MoreObjects.firstNonNull(redirectUrl, location));
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/github-plugin/src/main/resources/Documentation/about.md:
--------------------------------------------------------------------------------
1 |
2 | This plugins allows to integrate Gerrit with external set of users configured
3 | on GitHub.
4 | It relies on the installation of the github-oauth Java library under the `$GERRIT_SITE/lib`
5 | in order filter all the HTTP requests through the GitHub OAuth 2.0 secure authentication.
6 |
7 | GitHub application registration
8 | -------------------------------
9 |
10 | GitHub uses OAuth2 as protocol to allow external apps request authorization to private
11 | details in a user's GitHub account without getting their password. This is
12 | preferred over Basic Authentication because tokens can be limited to specific
13 | types of data, and can be revoked by users at any time.
14 |
15 | Site owners have to register their application before getting started. For
16 | more information see [GitHub application registration page](https://github.com/settings/applications/new).
17 | A registered OAuth application is assigned a unique `Client ID` and `Client
18 | Secret`. The `Client Secret` should never be shared.
19 |
20 | The Gerrit OAuth callback `/oauth`
21 | needs to be specified in the GitHub application registration to establish mutual
22 | trust between the two domains and exchange the authorization codes. The use of HTTPS
23 | for Gerrit is strongly recommended for keeping the secrets exchange confidential.
24 |
25 | `auth.httpHeader` is set to `GITHUB_USER` with this authentication method and `auth.type`
26 | must be set to HTTP.
--------------------------------------------------------------------------------
/github-plugin/src/main/resources/static/js/datatables/license-bsd.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2008-2010, Allan Jardine
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5 |
6 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8 | * Neither the name of Allan Jardine nor SpryMedia UK may be used to endorse or promote products derived from this software without specific prior written permission.
9 |
10 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------------
/github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/VirtualDomainConfig.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2023 The Android Open Source Project
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package com.googlesource.gerrit.plugins.github.oauth;
16 |
17 | import com.google.inject.Inject;
18 | import com.google.inject.Singleton;
19 | import java.util.List;
20 | import java.util.Optional;
21 | import java.util.SortedMap;
22 | import javax.servlet.http.HttpServletRequest;
23 |
24 | @Singleton
25 | public class VirtualDomainConfig {
26 | private final GitHubOAuthConfig oauthConfig;
27 |
28 | @Inject
29 | VirtualDomainConfig(GitHubOAuthConfig oauthConfig) {
30 | this.oauthConfig = oauthConfig;
31 | }
32 |
33 | public SortedMap> getScopes(HttpServletRequest req) {
34 | String serverName = req.getServerName();
35 | return Optional.ofNullable(oauthConfig.virtualScopes.get(serverName))
36 | .orElse(oauthConfig.scopes);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/github-oauth/src/main/java/com/google/gerrit/httpd/XGerritAuth.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2014 The Android Open Source Project
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | package com.google.gerrit.httpd;
15 |
16 | import com.google.common.cache.Cache;
17 | import com.google.gerrit.httpd.WebSessionManager.Val;
18 | import com.google.inject.Inject;
19 | import com.google.inject.Singleton;
20 | import com.google.inject.name.Named;
21 | import javax.servlet.http.Cookie;
22 |
23 | @Singleton
24 | public class XGerritAuth {
25 | public static final String X_GERRIT_AUTH = "X-Gerrit-Auth";
26 | private WebSessionManager manager;
27 |
28 | @Inject
29 | public XGerritAuth(
30 | WebSessionManagerFactory managerFactory,
31 | @Named(WebSessionManager.CACHE_NAME) Cache cache) {
32 | this.manager = managerFactory.create(cache);
33 | }
34 |
35 | public String getAuthValue(Cookie gerritCookie) {
36 | Val session = manager.get(new WebSessionManager.Key(gerritCookie.getValue()));
37 | return session.getAuth();
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/GitHubHttpConnector.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2015 The Android Open Source Project
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package com.googlesource.gerrit.plugins.github.oauth;
16 |
17 | import com.google.inject.Inject;
18 | import java.io.IOException;
19 | import java.net.HttpURLConnection;
20 | import java.net.URL;
21 | import org.kohsuke.github.HttpConnector;
22 |
23 | public class GitHubHttpConnector implements HttpConnector {
24 |
25 | private final GitHubOAuthConfig config;
26 |
27 | @Inject
28 | public GitHubHttpConnector(final GitHubOAuthConfig config) {
29 | this.config = config;
30 | }
31 |
32 | @Override
33 | public HttpURLConnection connect(URL url) throws IOException {
34 | HttpURLConnection huc = (HttpURLConnection) url.openConnection();
35 | HttpURLConnection.setFollowRedirects(true);
36 | huc.setConnectTimeout((int) config.httpConnectionTimeout);
37 | huc.setReadTimeout((int) config.httpReadTimeout);
38 | return huc;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/replication/RemoteSiteUser.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2013 The Android Open Source Project
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package com.googlesource.gerrit.plugins.github.replication;
16 |
17 | import com.google.gerrit.server.CurrentUser;
18 | import com.google.gerrit.server.account.GroupMembership;
19 | import com.google.inject.Inject;
20 | import com.google.inject.assistedinject.Assisted;
21 |
22 | public class RemoteSiteUser extends CurrentUser {
23 | public interface Factory {
24 | RemoteSiteUser create(@Assisted GroupMembership authGroups);
25 | }
26 |
27 | private final GroupMembership effectiveGroups;
28 |
29 | @Inject
30 | RemoteSiteUser(@Assisted GroupMembership authGroups) {
31 | effectiveGroups = authGroups;
32 | }
33 |
34 | @Override
35 | public GroupMembership getEffectiveGroups() {
36 | return effectiveGroups;
37 | }
38 |
39 | @Override
40 | public Object getCacheKey() {
41 | return effectiveGroups.getKnownGroups();
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/velocity/PluginVelocityModel.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2013 The Android Open Source Project
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | package com.googlesource.gerrit.plugins.github.velocity;
15 |
16 | import com.google.inject.Inject;
17 | import com.google.inject.servlet.RequestScoped;
18 | import org.apache.velocity.VelocityContext;
19 |
20 | @RequestScoped
21 | public class PluginVelocityModel {
22 |
23 | private final VelocityContext context;
24 |
25 | public VelocityContext getContext() {
26 | return context;
27 | }
28 |
29 | @Inject
30 | public PluginVelocityModel(VelocityContext context) {
31 | this.context = context;
32 | }
33 |
34 | public Object get(String key) {
35 | return context.get(key);
36 | }
37 |
38 | public Object[] getKeys() {
39 | return context.getKeys();
40 | }
41 |
42 | public Object put(String key, Object value) {
43 | return context.put(key, value);
44 | }
45 |
46 | public Object remove(String key) {
47 | return context.remove(key);
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/group/GitHubGroup.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2014 The Android Open Source Project
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package com.googlesource.gerrit.plugins.github.group;
16 |
17 | import com.google.gerrit.entities.AccountGroup;
18 | import com.google.gerrit.entities.AccountGroup.UUID;
19 | import com.google.gerrit.entities.GroupDescription.Basic;
20 |
21 | public abstract class GitHubGroup implements Basic {
22 | public static final String UUID_PREFIX = "github:";
23 | public static final String NAME_PREFIX = "github/";
24 |
25 | protected final UUID groupUUID;
26 |
27 | protected final String url;
28 |
29 | GitHubGroup(UUID groupUUID, String url) {
30 | this.groupUUID = groupUUID;
31 | this.url = url;
32 | }
33 |
34 | @Override
35 | public String getEmailAddress() {
36 | return "";
37 | }
38 |
39 | @Override
40 | public AccountGroup.UUID getGroupUUID() {
41 | return groupUUID;
42 | }
43 |
44 | @Override
45 | public String getUrl() {
46 | return url;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/group/CurrentUsernameProvider.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2023 The Android Open Source Project
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package com.googlesource.gerrit.plugins.github.group;
16 |
17 | import com.google.gerrit.server.CurrentUser;
18 | import com.google.gerrit.server.IdentifiedUser;
19 | import com.google.inject.Inject;
20 | import com.google.inject.Provider;
21 | import java.util.Optional;
22 |
23 | public class CurrentUsernameProvider implements Provider {
24 | public static final String CURRENT_USERNAME = "CurrentUsername";
25 |
26 | private final Provider userProvider;
27 |
28 | @Inject
29 | CurrentUsernameProvider(Provider userProvider) {
30 | this.userProvider = userProvider;
31 | }
32 |
33 | @Override
34 | public String get() {
35 | return Optional.ofNullable(userProvider.get())
36 | .filter(CurrentUser::isIdentifiedUser)
37 | .map(CurrentUser::asIdentifiedUser)
38 | .flatMap(IdentifiedUser::getUserName)
39 | .orElse(null);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/notification/PingHandler.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2015 The Android Open Source Project
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package com.googlesource.gerrit.plugins.github.notification;
16 |
17 | import com.google.inject.Singleton;
18 | import java.io.IOException;
19 | import org.slf4j.Logger;
20 | import org.slf4j.LoggerFactory;
21 |
22 | /**
23 | * Handles ping event in github webhook.
24 | *
25 | * @see Ping Event
26 | */
27 | @Singleton
28 | class PingHandler implements WebhookEventHandler {
29 | private static final Logger logger = LoggerFactory.getLogger(PingHandler.class);
30 |
31 | static class Ping {
32 | String zen;
33 | int hookId;
34 |
35 | @Override
36 | public String toString() {
37 | return "Ping [zen=" + zen + ", hookId=" + hookId + "]";
38 | }
39 | }
40 |
41 | @Override
42 | public boolean doAction(Ping payload) throws IOException {
43 | logger.info(payload.toString());
44 | return true;
45 | }
46 |
47 | @Override
48 | public Class getPayloadType() {
49 | return Ping.class;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/BatchImporter.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2013 The Android Open Source Project
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | package com.googlesource.gerrit.plugins.github.git;
15 |
16 | import com.google.gerrit.server.IdentifiedUser;
17 | import java.util.Collection;
18 | import java.util.concurrent.ConcurrentHashMap;
19 |
20 | public class BatchImporter {
21 |
22 | private final ConcurrentHashMap jobs = new ConcurrentHashMap<>();
23 | private final JobExecutor executor;
24 | protected final IdentifiedUser user;
25 |
26 | public BatchImporter(final JobExecutor executor, final IdentifiedUser user) {
27 | this.executor = executor;
28 | this.user = user;
29 | }
30 |
31 | public Collection getJobs() {
32 | return jobs.values();
33 | }
34 |
35 | public void reset() {
36 | cancel();
37 | jobs.clear();
38 | }
39 |
40 | public void cancel() {
41 | for (GitJob job : jobs.values()) {
42 | job.cancel();
43 | }
44 | }
45 |
46 | public synchronized void schedule(int idx, GitJob pullRequestImportJob) {
47 | jobs.put(Integer.valueOf(idx), pullRequestImportJob);
48 | executor.exec(pullRequestImportJob);
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/replication/ListProjectReplicationStatus.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2013 The Android Open Source Project
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package com.googlesource.gerrit.plugins.github.replication;
16 |
17 | import com.google.gerrit.extensions.restapi.AuthException;
18 | import com.google.gerrit.extensions.restapi.BadRequestException;
19 | import com.google.gerrit.extensions.restapi.ResourceConflictException;
20 | import com.google.gerrit.extensions.restapi.Response;
21 | import com.google.gerrit.extensions.restapi.RestReadView;
22 | import com.google.gerrit.server.project.ProjectResource;
23 | import com.google.inject.Inject;
24 |
25 | public class ListProjectReplicationStatus implements RestReadView {
26 | private final ReplicationStatusStore statusStore;
27 |
28 | @Inject
29 | public ListProjectReplicationStatus(ReplicationStatusStore statusStore) {
30 | this.statusStore = statusStore;
31 | }
32 |
33 | @Override
34 | public Response