mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-05 04:39:07 -04:00
feat(repository): add ability to set and get namespace
This commit is contained in:
parent
b8b69100f1
commit
9acf3a8a9e
3 changed files with 45 additions and 19 deletions
|
@ -70,6 +70,24 @@ String getNamespace(Pointer<git_repository> repo) {
|
|||
}
|
||||
}
|
||||
|
||||
/// Sets the active namespace for this repository.
|
||||
///
|
||||
/// This namespace affects all reference operations for the repo. See `man gitnamespaces`
|
||||
///
|
||||
/// The [namespace] should not include the refs folder, e.g. to namespace all references
|
||||
/// under refs/namespaces/foo/, use foo as the namespace.
|
||||
///
|
||||
/// Throws a [LibGit2Error] if error occured.
|
||||
void setNamespace(Pointer<git_repository> repo, String? namespace) {
|
||||
final nmspace = namespace?.toNativeUtf8().cast<Int8>() ?? nullptr;
|
||||
final error = libgit2.git_repository_set_namespace(repo, nmspace);
|
||||
calloc.free(nmspace);
|
||||
|
||||
if (error < 0) {
|
||||
throw LibGit2Error(libgit2.git_error_last());
|
||||
}
|
||||
}
|
||||
|
||||
/// Check if a repository is bare or not.
|
||||
bool isBare(Pointer<git_repository> repo) {
|
||||
final result = libgit2.git_repository_is_bare(repo);
|
||||
|
@ -331,24 +349,6 @@ void setHeadDetachedFromAnnotated(
|
|||
}
|
||||
}
|
||||
|
||||
/// Sets the active namespace for this Git Repository
|
||||
///
|
||||
/// This namespace affects all reference operations for the repo. See `man gitnamespaces`
|
||||
///
|
||||
/// The [namespace] should not include the refs folder, e.g. to namespace all references
|
||||
/// under refs/namespaces/foo/, use foo as the namespace.
|
||||
///
|
||||
/// Throws a [LibGit2Error] if error occured.
|
||||
void setNamespace(Pointer<git_repository> repo, String namespace) {
|
||||
final nmspace = namespace.toNativeUtf8().cast<Int8>();
|
||||
final error = libgit2.git_repository_set_namespace(repo, nmspace);
|
||||
calloc.free(nmspace);
|
||||
|
||||
if (error < 0) {
|
||||
throw LibGit2Error(libgit2.git_error_last());
|
||||
}
|
||||
}
|
||||
|
||||
/// Set the path to the working directory for this repository
|
||||
///
|
||||
/// The working directory doesn't need to be the same one that contains the
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue