RemoteRepositoryAdapter class

A RepositoryAdapter that talks to a remote repository server over HTTP.

It is the client half of the JSON contract defined by RepositoryRpc: each call POSTs {'op': ..., ...args} to <baseUrl>/rpc and deserializes the result with the value types' fromJson. The wire op names come from Op, so client and server can never drift.

This is web-safepackage:http runs in the browser — so a web IDE can browse, edit and run git against a real project served by tool/repository_server.dart (see RepoCapabilities.isRemote, which this adapter always reports true).

Because capabilities is a synchronous getter, construct the adapter with the async connect factory, which fetches the server's capabilities once:

final adapter = await RemoteRepositoryAdapter.connect('http://127.0.0.1:8090');
final repo = RepositoryService(adapter,
    config: const RepoConfig(allowWrite: true, allowGitMutation: true));
Implemented types

Properties

baseUrl String
The server base URL, e.g. http://127.0.0.1:8090 (no trailing slash).
final
capabilities RepoCapabilities
What this adapter can/‌may do, so tools can report unsupported operations cleanly.
no setteroverride
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

close() → void
Closes the underlying HTTP client (only if this adapter created it).
delete(String path) Future<void>
Deletes the file or directory path.
override
edit(String path, String oldString, String newString, {bool replaceAll = false, int? atLine}) Future<RepoEdit>
Replaces oldString with newString in path. When replaceAll is false exactly one occurrence must match. When atLine is given, the match must occur on that 1-based line or the edit is rejected.
override
find({String? glob, int? limit}) Future<List<String>>
Finds files whose workspace-relative path matches glob (returns up to limit paths).
override
gitAdd(List<String> paths) Future<GitResult>
override
gitBlame(String path) Future<List<GitBlameLine>>
override
gitCheckout(String rev) Future<GitResult>
override
gitCommit(String message, {List<String>? paths}) Future<GitResult>
override
gitDiff({String? rev, bool staged = false, String? path}) Future<String>
override
gitLog({int? limit, String? path}) Future<List<GitCommit>>
override
gitRestore(List<String> paths, {bool staged = false}) Future<GitResult>
override
gitShow({required String rev, String? path}) Future<String>
override
gitStatus() Future<List<GitStatusEntry>>
override
list(String path, {bool recursive = false, int? maxDepth, String? glob}) Future<List<RepoEntry>>
Lists the directory at path. When recursive, descends up to maxDepth levels; glob filters entries by name/path pattern.
override
mkdir(String path) Future<void>
Creates the directory path (and any missing parents).
override
move(String from, String to) Future<void>
Moves/renames from to to.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
read(String path, {LineRange? range}) Future<RepoFile>
Reads path, optionally only the lines in range.
override
searchText(String pattern, {String? glob, bool ignoreCase = false, int context = 0, int? limit}) Future<List<TextMatch>>
Searches file contents for pattern (a regular expression). glob limits which files are searched; context lines of surrounding text are attached.
override
stat(String path) Future<RepoStat>
Metadata for path (never throws for a missing path — returns exists: false).
override
toString() String
A string representation of this object.
inherited
write(String path, String content) Future<RepoEdit>
Creates or overwrites path with content.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

connect(String baseUrl, {Client? client}) Future<RemoteRepositoryAdapter>
Connects to the repository server at baseUrl, fetching its capabilities.