Skip to content

Commit

Permalink
fix: remove unnecessary async in function
Browse files Browse the repository at this point in the history
  • Loading branch information
lizacullis committed Aug 3, 2023
1 parent 3dc89df commit fa9db17
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/common/ci/gitlab/commentOnPR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { getGitLabEnvVariables } from "../../../config";
export const commentOnPR = async (comment: string, signOff: string) => {
try {
const { gitlabToken, projectId, mergeRequestIIdString } =
await getGitLabEnvVariables();
getGitLabEnvVariables();
const mergeRequestIId = parseInt(mergeRequestIIdString, 10);
const api = new Gitlab({
token: gitlabToken,
Expand Down
8 changes: 4 additions & 4 deletions src/common/git/getChangedFileLines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { exec } from "child_process";

import { getGitHubEnvVariables, getGitLabEnvVariables } from "../../config";
import { PlatformOptions } from "../types";
export const getChangesFileLinesCommand = async (
export const getChangesFileLinesCommand = (
isCi: string,
fileName: string
): Promise<string> => {
): string => {
if (isCi === PlatformOptions.GITHUB) {
const { githubSha, baseSha } = getGitHubEnvVariables();
return `git diff -U0 --diff-filter=AMT ${baseSha} ${githubSha} ${fileName}`;
} else if (isCi === PlatformOptions.GITLAB) {
const { gitlabSha, mergeRequestBaseSha } = await getGitLabEnvVariables();
const { gitlabSha, mergeRequestBaseSha } = getGitLabEnvVariables();
return `git diff -U0 --diff-filter=AMT ${mergeRequestBaseSha} ${gitlabSha} ${fileName}`;
}
return `git diff -U0 --diff-filter=AMT --cached ${fileName}`;
Expand All @@ -20,7 +20,7 @@ export const getChangedFileLines = async (
isCi: string,
fileName: string
): Promise<string> => {
const commandString = await getChangesFileLinesCommand(isCi, fileName);
const commandString = getChangesFileLinesCommand(isCi, fileName);

return new Promise((resolve, reject) => {
exec(commandString, (error, stdout, stderr) => {
Expand Down
14 changes: 7 additions & 7 deletions src/common/git/getChangedFilesNames.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@ import { exec } from "child_process";
import { join } from "path";

import { getGitHubEnvVariables, getGitLabEnvVariables } from "../../config";
import { GITHUB, GITLAB } from "../constants";
import { PlatformOptions } from "../types";

export const getChangedFilesNamesCommand = async (
export const getChangedFilesNamesCommand = (
isCi: string
): Promise<string> => {
if (isCi === GITHUB) {
): string => {
if (isCi === PlatformOptions.GITHUB) {
const { githubSha, baseSha } = getGitHubEnvVariables();
return `git diff --name-only --diff-filter=AMT ${baseSha} ${githubSha}`;
} else if (isCi === GITLAB) {
const { mergeRequestBaseSha } = await getGitLabEnvVariables();
} else if (isCi === PlatformOptions.GITLAB) {
const { mergeRequestBaseSha } = getGitLabEnvVariables();
return `git diff --name-only ${mergeRequestBaseSha}...HEAD`;
}
return "git diff --name-only --diff-filter=AMT --cached";
};

export const getChangedFilesNames = async (isCi: string): Promise<string[]> => {
const commandString = await getChangedFilesNamesCommand(isCi);
const commandString = getChangedFilesNamesCommand(isCi);

return new Promise((resolve, reject) => {
exec(commandString, (error, stdout, stderr) => {
Expand Down
4 changes: 1 addition & 3 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ export const getGitHubEnvVariables = (): Record<string, string> => {
};
};

export const getGitLabEnvVariables = async (): Promise<
Record<string, string>
> => {
export const getGitLabEnvVariables = (): Record<string, string> => {
const missingVars = [
"CI_MERGE_REQUEST_DIFF_BASE_SHA",
"CI_PROJECT_ID",
Expand Down

0 comments on commit fa9db17

Please sign in to comment.