fix(git-gateway): pass options through git-gateway backend (#1532)

This commit is contained in:
Shawn Erquhart
2018-07-27 18:40:53 -04:00
committed by GitHub
parent 5af05865e5
commit 4c5436a83d

View File

@ -34,7 +34,12 @@ function getEndpoint(endpoint, netlifySiteURL) {
} }
export default class GitGateway { export default class GitGateway {
constructor(config) { constructor(config, options = {}) {
this.options = {
proxied: false,
API: null,
...options,
};
this.config = config; this.config = config;
this.branch = config.getIn(["backend", "branch"], "master").trim(); this.branch = config.getIn(["backend", "branch"], "master").trim();
this.squash_merges = config.getIn(["backend", "squash_merges"]); this.squash_merges = config.getIn(["backend", "squash_merges"]);
@ -103,17 +108,17 @@ export default class GitGateway {
if (this.backendType === "github") { if (this.backendType === "github") {
this.api = new GitHubAPI(apiConfig); this.api = new GitHubAPI(apiConfig);
this.backend = new GitHubBackend(this.config, { proxied: true, API: this.api }); this.backend = new GitHubBackend(this.config, { ...this.options, API: this.api });
} else if (this.backendType === "gitlab") { } else if (this.backendType === "gitlab") {
this.api = new GitLabAPI(apiConfig); this.api = new GitLabAPI(apiConfig);
this.backend = new GitLabBackend(this.config, { proxied: true, API: this.api }); this.backend = new GitLabBackend(this.config, { ...this.options, API: this.api });
} else if (this.backendType === "bitbucket") { } else if (this.backendType === "bitbucket") {
this.api = new BitBucketAPI({ this.api = new BitBucketAPI({
...apiConfig, ...apiConfig,
requestFunction: this.requestFunction, requestFunction: this.requestFunction,
hasWriteAccess: async () => true, hasWriteAccess: async () => true,
}); });
this.backend = new BitBucketBackend(this.config, { proxied: true, API: this.api }); this.backend = new BitBucketBackend(this.config, { ...this.options, API: this.api });
} }
if (!(await this.api.hasWriteAccess())) { if (!(await this.api.hasWriteAccess())) {