Skip to content

Commit

Permalink
Fix gitClone error logging and improve code quality (#1366)
Browse files Browse the repository at this point in the history
* Fix gitClone error logging and improve code quality

Signed-off-by: amuravski <[email protected]>

* Fix lint warning and ran ```pnpm lint && pnpm run gen-types```

Signed-off-by: amuravski <[email protected]>

---------

Signed-off-by: amuravski <[email protected]>
  • Loading branch information
amuravski authored Sep 9, 2024
1 parent e7be44f commit 057205c
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 33 deletions.
41 changes: 15 additions & 26 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,32 +31,21 @@ const gitClone = (repoUrl, branch = null) => {
path.join(os.tmpdir(), path.basename(repoUrl)),
);

if (branch == null) {
console.log("Cloning Repo", "to", tempDir);
const result = spawnSync(
"git",
["clone", repoUrl, "--depth", "1", tempDir],
{
encoding: "utf-8",
shell: false,
},
);
if (result.status !== 0 || result.error) {
console.log(result.error);
}
} else {
console.log("Cloning repo with optional branch", "to", tempDir);
const result = spawnSync(
"git",
["clone", repoUrl, "--branch", branch, "--depth", "1", tempDir],
{
encoding: "utf-8",
shell: false,
},
);
if (result.status !== 0 || result.error) {
console.log(result.error);
}
const gitArgs = ["clone", repoUrl, "--depth", "1", tempDir];
if (branch) {
gitArgs.splice(2, 0, "--branch", branch);
}

console.log(
`Cloning Repo${branch ? ` with branch ${branch}` : ""} to ${tempDir}`,
);

const result = spawnSync("git", gitArgs, {
encoding: "utf-8",
shell: false,
});
if (result.status !== 0) {
console.log(result.stderr);
}

return tempDir;
Expand Down
2 changes: 1 addition & 1 deletion types/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion types/server.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 12 additions & 4 deletions types/utils.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,20 +269,18 @@ export function parseGradleProperties(rawOutput: string): {
* Execute gradle properties command using multi-threading and return parsed output
*
* @param {string} dir Directory to execute the command
* @param {string} rootPath Root directory
* @param {array} allProjectsStr List of all sub-projects (including the preceding `:`)
*
* @returns {string} The combined output for all subprojects of the Gradle properties task
*/
export function executeParallelGradleProperties(dir: string, rootPath: string, allProjectsStr: any[]): string;
export function executeParallelGradleProperties(dir: string, allProjectsStr: any[]): string;
/**
* Execute gradle properties command and return parsed output
*
* @param {string} dir Directory to execute the command
* @param {string} rootPath Root directory
* @param {string} subProject Sub project name
*/
export function executeGradleProperties(dir: string, rootPath: string, subProject: string): {};
export function executeGradleProperties(dir: string, subProject: string): {};
/**
* Parse bazel action graph output
* @param {string} rawOutput Raw string output
Expand Down Expand Up @@ -1052,6 +1050,16 @@ export function getJarClasses(jarFile: string): Promise<any[]>;
* @param {string} rootPath Root directory to look for gradlew wrapper
*/
export function getGradleCommand(srcPath: string, rootPath: string): string;
/**
* Method to combine the general gradle arguments, the sub-commands and the sub-commands' arguments in the correct way
*
* @param {string[]} gradleArguments The general gradle arguments, which must only be added once
* @param {string[]} gradleSubCommands The sub-commands that are to be executed by gradle
* @param {string[]} gradleSubCommandArguments The arguments specific to the sub-command(s), which much be added PER sub-command
*
* @returns {string[]} Array of arguments to be added to the gradle command
*/
export function buildGradleCommandArguments(gradleArguments: string[], gradleSubCommands: string[], gradleSubCommandArguments: string[]): string[];
/**
* Method to split the output produced by Gradle using parallel processing by project
*
Expand Down
2 changes: 1 addition & 1 deletion types/utils.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 057205c

Please sign in to comment.