Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
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
9 changes: 8 additions & 1 deletion action/src/platforms/_base.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { execSync } from "child_process";
import Z from "zod";

const defaultMessage = "feat: update translations via @lingodotdev";
Expand All @@ -23,7 +24,13 @@ export abstract class PlatformKit<PlatformConfig extends BasePlatformConfig = Ba

abstract buildPullRequestUrl(pullRequestNumber: number): string;

gitConfig(): Promise<void> | void {}
gitConfig(token?: string, repoUrl?: string) {
if (token && repoUrl) {
execSync(`git remote set-url origin ${repoUrl}`, {
stdio: "inherit",
});
}
}

get config() {
const env = Z.object({
Expand Down
6 changes: 1 addition & 5 deletions action/src/platforms/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { Octokit } from "octokit";
import { PlatformKit } from "./_base.js";
import Z from "zod";

import { execSync } from "child_process";

export class GitHubPlatformKit extends PlatformKit {
private _octokit?: Octokit;

Expand Down Expand Up @@ -79,9 +77,7 @@ export class GitHubPlatformKit extends PlatformKit {

const url = `https://${ghToken}@github.com/${repositoryOwner}/${repositoryName}.git`;

execSync(`git remote set-url origin ${url}`, {
stdio: "inherit",
});
super.gitConfig(ghToken, url);
}
}

Expand Down
8 changes: 3 additions & 5 deletions action/src/platforms/gitlab.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Gitlab } from "@gitbeaker/rest";
import Z from "zod";
import { PlatformKit } from "./_base.js";
import { execSync } from "child_process";

const gl = new Gitlab({ token: "" });

Expand Down Expand Up @@ -91,11 +90,10 @@ export class GitlabPlatformKit extends PlatformKit {
}

gitConfig(): Promise<void> | void {
const url = `https://oauth2:${this.platformConfig.glToken}@gitlab.com/${this.platformConfig.repositoryOwner}/${this.platformConfig.repositoryName}.git`;
const glToken = this.platformConfig.glToken;
const url = `https://oauth2:${glToken}@gitlab.com/${this.platformConfig.repositoryOwner}/${this.platformConfig.repositoryName}.git`;

execSync(`git remote set-url origin ${url}`, {
stdio: "inherit",
});
super.gitConfig(glToken, url);
}

buildPullRequestUrl(pullRequestNumber: number): string {
Expand Down