getRemoteUrl method

Future<Uri> getRemoteUrl({
  1. required String gitDirpath,
  2. required String remote,
  3. Map<String, String>? environment,
  4. bool includeParentEnvironment = true,
})

Implementation

Future<Uri> getRemoteUrl({
  required String gitDirpath,
  required String remote,
  Map<String, String>? environment,
  bool includeParentEnvironment = true,
}) async {
  final dir = checkDirectoryExists(gitDirpath, "gitDirpath");

  final res = await runAsync(
    ["remote", "get-url", remote],
    workingDirectory: dir.path,
    environment: environment,
    includeParentEnvironment: includeParentEnvironment,
  );

  if (0 != res.exitCode)
    throw CliResultException(
      exitCode: res.exitCode,
      stderr: res.stderr,
      message: "Failed to get the url for the remote '$remote' "
          "int the git directory at '$gitDirpath'",
    );

  return Uri.parse(res.stdout.toString().trim());
}