advertiseRefs method

  1. @override
Future<GitServiceResponse> advertiseRefs(
  1. GitServedRepositoryId repository, {
  2. required GitProtocolParameters protocol,
})
override

Produces the first response of the protocol by launching git upload-pack --stateless-rpc --advertise-refs on the resolved git directory.

In protocol v0/v1 the body advertises the references; in v2 it announces the capabilities, and the references come through the ls-refs command of a later uploadPack request.

Implementation

@override
Future<GitServiceResponse> advertiseRefs(
  GitServedRepositoryId repository, {
  required GitProtocolParameters protocol,
}) async {
  final String gitDir = await _gitDirOf(repository);
  final List<String> arguments = <String>[
    'upload-pack',
    '--stateless-rpc',
    '--advertise-refs',
    gitDir,
  ];
  final GitLaunchedProcess process = await _launch(arguments, protocol);
  // The advertisement reads no input: close stdin so git sees an end of
  // stream instead of a writer that never comes.
  unawaited(process.closeStdin());
  return ProcessUploadPackExchange(
    process: process,
    arguments: arguments,
    inactivityTimeout: _inactivityTimeout,
    bufferBytes: _bufferBytes,
  );
}