GerritUrlReader: Implemented "readTree"

"readTree" has been implemented for the "GerritUrlReader". Gerrit have
a REST API's to download repo contents but there are a number of
limitations that makes it unusable.

This implementation works as follows:
* The project and branch is parsed from the url.
* The current revision is fetched from the Gerrit REST API.
* The revision string is used as "etag".
* If the etag has changed a temporary directory is created.
* The project is cloned to the temporary directory.
* The cloned content is read into a "Readable Stream".
* The temporary directory is removed.
* "readTree" returns a response using "fromTarArchive" as read from the
  temporary directory.

Also added an option to specify the base "cloneUrl" has been added to the
gerrit integration config.

Signed-off-by: Niklas Aronsson <niklasar@axis.com>
This commit is contained in:
Niklas Aronsson
2022-04-12 10:50:58 +02:00
parent 74bf95277a
commit 6673babab9
14 changed files with 414 additions and 34 deletions
+5
View File
@@ -108,6 +108,11 @@ export interface Config {
* @visibility frontend
*/
baseUrl?: string;
/**
* The base url for cloning repos.
* @visibility frontend
*/
cloneUrl?: string;
/**
* The username to use for authenticated requests.
* @visibility secret