simplify ReadTreeResponseFactory options and small fixes
Signed-off-by: Thomas Cardonne <thomas.cardonne@adevinta.com>
This commit is contained in:
@@ -610,7 +610,9 @@ export interface ReadTreeResponseFactory {
|
||||
): Promise<ReadTreeResponse>;
|
||||
// (undocumented)
|
||||
fromTarArchive(
|
||||
options: ReadTreeResponseFactoryOptions,
|
||||
options: ReadTreeResponseFactoryOptions & {
|
||||
stripFirstDirectory?: boolean;
|
||||
},
|
||||
): Promise<ReadTreeResponse>;
|
||||
// (undocumented)
|
||||
fromZipArchive(
|
||||
@@ -629,7 +631,6 @@ export type ReadTreeResponseFactoryOptions = {
|
||||
size: number;
|
||||
},
|
||||
) => boolean;
|
||||
tarStripFirstDirectory?: boolean;
|
||||
};
|
||||
|
||||
export { ReadTreeResponseFile };
|
||||
|
||||
@@ -257,9 +257,7 @@ describe('GerritUrlReader', () => {
|
||||
|
||||
worker.use(
|
||||
rest.get(
|
||||
new RegExp(
|
||||
'https://gerrit.com/gitiles/app/web/\\+archive/refs/heads/master.tar.gz',
|
||||
),
|
||||
'https://gerrit.com/gitiles/app/web/\\+archive/refs/heads/master.tar.gz',
|
||||
(_, res, ctx) =>
|
||||
res(
|
||||
ctx.status(200),
|
||||
@@ -272,9 +270,7 @@ describe('GerritUrlReader', () => {
|
||||
),
|
||||
),
|
||||
rest.get(
|
||||
new RegExp(
|
||||
'https://gerrit.com/gitiles/app/web/\\+archive/refs/heads/master/docs.tar.gz',
|
||||
),
|
||||
'https://gerrit.com/gitiles/app/web/\\+archive/refs/heads/master/docs.tar.gz',
|
||||
(_, res, ctx) =>
|
||||
res(
|
||||
ctx.status(200),
|
||||
|
||||
@@ -283,7 +283,7 @@ export class GerritUrlReader implements UrlReader {
|
||||
stream: archiveResponse.body as unknown as Readable,
|
||||
etag: revision,
|
||||
filter: options?.filter,
|
||||
tarStripFirstDirectory: false,
|
||||
stripFirstDirectory: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,9 @@ export class DefaultReadTreeResponseFactory implements ReadTreeResponseFactory {
|
||||
constructor(private readonly workDir: string) {}
|
||||
|
||||
async fromTarArchive(
|
||||
options: ReadTreeResponseFactoryOptions,
|
||||
options: ReadTreeResponseFactoryOptions & {
|
||||
stripFirstDirectory?: boolean;
|
||||
},
|
||||
): Promise<ReadTreeResponse> {
|
||||
return new TarArchiveResponse(
|
||||
options.stream,
|
||||
@@ -45,7 +47,7 @@ export class DefaultReadTreeResponseFactory implements ReadTreeResponseFactory {
|
||||
this.workDir,
|
||||
options.etag,
|
||||
options.filter,
|
||||
options.tarStripFirstDirectory ?? true,
|
||||
options.stripFirstDirectory ?? true,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -83,8 +83,6 @@ export type ReadTreeResponseFactoryOptions = {
|
||||
etag: string;
|
||||
// Filter passed on from the ReadTreeOptions
|
||||
filter?: (path: string, info?: { size: number }) => boolean;
|
||||
// First directory of a tar archive is stripped when set to true
|
||||
tarStripFirstDirectory?: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -118,7 +116,13 @@ export type FromReadableArrayOptions = Array<{
|
||||
*/
|
||||
export interface ReadTreeResponseFactory {
|
||||
fromTarArchive(
|
||||
options: ReadTreeResponseFactoryOptions,
|
||||
options: ReadTreeResponseFactoryOptions & {
|
||||
/**
|
||||
* Strip the first parent directory of a tar archive.
|
||||
* Defaults to true.
|
||||
*/
|
||||
stripFirstDirectory?: boolean;
|
||||
},
|
||||
): Promise<ReadTreeResponse>;
|
||||
fromZipArchive(
|
||||
options: ReadTreeResponseFactoryOptions,
|
||||
|
||||
@@ -152,7 +152,6 @@ export function getAuthenticationPrefix(
|
||||
* be used.
|
||||
*
|
||||
* @param config - A Gerrit provider config.
|
||||
* @public
|
||||
*/
|
||||
export function getGitilesAuthenticationUrl(
|
||||
config: GerritIntegrationConfig,
|
||||
|
||||
Reference in New Issue
Block a user