For the PreviewSubmit call plain tar as well as zip works fine, but
formats like tbz2, tgz and txz are broken.
This bug comes from not knowing the size of the bundles before writing
them, such that it was assumed to 0. Plain tar as well as zip worked
just fine as the tools ignored the wrong size.
Fix the bug by creating the bundle in memory and then correctly use
JGits ArchiveCommand for different formats.
To demonstrate the bug is fixed, add a test that just lists files
in the return of a call of preview submit call with tgz format
specificed.
By this change a bundle cannot be streamed any more, but needs to
be kept in memory. As bundles may become large, introduce a new
config option to set an upper bound for a bundle that is build up
in memory.
A slightly unrelated change is the wrapping of the
ArchiveOutputStream in a try-with-resource block as it implements
AutoCloseable. (Before it was not closed explicitly but just
finish()ed.)
Change-Id: I587c0e81ed79be94d7abf2a19ad2086c005933d9
Signed-off-by: Stefan Beller <sbeller@google.com>