Skip to content

Commit

Permalink
Remove getCheckoutDirectoryBasename()
Browse files Browse the repository at this point in the history
It looks like that's not needed,
at least with the repos I've been testing.
  • Loading branch information
kienstra committed Aug 16, 2021
1 parent 823c6b1 commit 3a0f28d
Showing 1 changed file with 1 addition and 40 deletions.
41 changes: 1 addition & 40 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,43 +54,6 @@ export function getCheckoutJobs(inputFile = ''): string[] {
);
}

export function getCheckoutDirectoryBasename(processFile: string): string {
const checkoutJobs = getCheckoutJobs(processFile);
const configFile = getConfigFile(processFile);

if (!configFile || !checkoutJobs.length) {
return '';
}

const checkoutJob = checkoutJobs[0];
if (!configFile.jobs[checkoutJob]?.steps) {
return '';
}

const stepWithPersist = configFile?.jobs[checkoutJob]?.steps?.find(
(step) => step?.persist_to_workspace
);

const persistToWorkspacePath = stepWithPersist?.persist_to_workspace?.paths
?.length
? stepWithPersist.persist_to_workspace.paths[0]
: '';

const pathBase =
!stepWithPersist?.persist_to_workspace?.root ||
'.' === stepWithPersist.persist_to_workspace.root
? configFile.jobs[checkoutJob]?.working_directory ??
getDefaultWorkspace(configFile.jobs[checkoutJob]?.docker[0]?.image)
: stepWithPersist.persist_to_workspace.root;

const pathMatches =
!persistToWorkspacePath || persistToWorkspacePath === '.'
? pathBase.match(/[^/]+$/)
: persistToWorkspacePath.match(/[^/]+$/);

return pathMatches ? pathMatches[0] : '';
}

export function changeCheckoutJob(processFile: string): void {
const checkoutJobs = getCheckoutJobs(processFile);
const configFile = getConfigFile(processFile);
Expand Down Expand Up @@ -215,9 +178,7 @@ export async function runJob(jobName: string): Promise<void> {
const localVolume = `${tmpPath}/${directory}`;
const volume = checkoutJobs.includes(jobName)
? `${localVolume}:${getCheckoutJobDirectory(jobName, configFile)}`
: `${localVolume}/${getCheckoutDirectoryBasename(
`${tmpPath}/${processFile}`
)}:${attachWorkspace}`;
: `${localVolume}:${attachWorkspace}`;
const debuggingTerminalName = `local-ci debugging ${jobName}`;
const finalTerminalName = 'local-ci final terminal';

Expand Down

0 comments on commit 3a0f28d

Please sign in to comment.