Manages the repository's remote configurations.
More...
#include <RemoteManager.hxx>
|
| | RemoteManager (const fs::path &repo_path) |
| | Constructs a RemoteManager and loads existing remotes.
|
| bool | addRemote (const std::string &name, const std::string &url) |
| | Adds a new remote configuration.
|
| bool | removeRemote (const std::string &name) |
| | Removes a remote configuration by name.
|
| bool | hasRemote (const std::string &name) const |
| | Checks if a remote with the given name exists.
|
| std::string | getRemoteUrl (const std::string &name) const |
| | Gets the URL of a configured remote.
|
| std::vector< std::string > | listRemotes () const |
| | Lists the names of all configured remotes.
|
| void | save () const |
| | Saves the current remote configurations back to the config file.
|
| void | load () |
| | Loads (or reloads) the remote configurations from the config file.
|
| size_t | count () const |
| | Gets the number of configured remotes.
|
Manages the repository's remote configurations.
This class provides an interface to manage remote repositories. It handles adding, removing, and listing remotes, as well as persisting these configurations to and from the repository's .svcs/config file.
◆ RemoteManager()
| svcs::server::RemoteManager::RemoteManager |
( |
const fs::path & | repo_path | ) |
|
|
explicit |
Constructs a RemoteManager and loads existing remotes.
- Parameters
-
| repo_path | The root path of the repository (e.g., "/path/to/my-project"), not the .svcs directory. |
The constructor sets the path to the config file (repo_path / ".svcs" / "config") and automatically calls load() to populate the remotes list.
◆ addRemote()
| bool svcs::server::RemoteManager::addRemote |
( |
const std::string & | name, |
|
|
const std::string & | url ) |
Adds a new remote configuration.
- Parameters
-
| name | The shortname for the new remote (e.g., "origin"). |
| url | The URL for the new remote. |
- Returns
- bool True if the remote was added successfully, false if a remote with that name already exists.
◆ count()
| size_t svcs::server::RemoteManager::count |
( |
| ) |
const |
|
inline |
Gets the number of configured remotes.
- Returns
- size_t The count of remotes.
◆ getRemoteUrl()
| std::string svcs::server::RemoteManager::getRemoteUrl |
( |
const std::string & | name | ) |
const |
Gets the URL of a configured remote.
- Parameters
-
| name | The name of the remote. |
- Returns
- std::string The URL if the remote is found, otherwise an empty string.
◆ hasRemote()
| bool svcs::server::RemoteManager::hasRemote |
( |
const std::string & | name | ) |
const |
Checks if a remote with the given name exists.
- Parameters
-
| name | The name of the remote to check. |
- Returns
- bool True if the remote exists, false otherwise.
◆ listRemotes()
| std::vector< std::string > svcs::server::RemoteManager::listRemotes |
( |
| ) |
const |
Lists the names of all configured remotes.
- Returns
- std::vector<std::string> A vector containing the names of all remotes.
◆ load()
| void svcs::server::RemoteManager::load |
( |
| ) |
|
Loads (or reloads) the remote configurations from the config file.
This method clears the current in-memory cache and parses the config file to populate it.
◆ removeRemote()
| bool svcs::server::RemoteManager::removeRemote |
( |
const std::string & | name | ) |
|
Removes a remote configuration by name.
- Parameters
-
| name | The shortname of the remote to remove. |
- Returns
- bool True if the remote was found and removed, false otherwise.
◆ save()
| void svcs::server::RemoteManager::save |
( |
| ) |
const |
Saves the current remote configurations back to the config file.
This method overwrites the remote sections of the config file with the current in-memory state.
The documentation for this class was generated from the following files: