feat(tag)!: add bindings and API methods

- add binding and API method for git_tag_create_lightweight
- add API method that returns tag target type

BREAKING CHANGE: add specific methods `createAnnotated` and `createLightweight`.
This commit is contained in:
Aleksey Kulikov 2022-01-24 15:52:14 +03:00
parent f7dde69de3
commit d5038bcb9e
6 changed files with 366 additions and 42 deletions

View file

@ -746,13 +746,12 @@ class Repository {
/// **IMPORTANT**: Should be freed to release allocated memory.
Tag lookupTag(Oid oid) => Tag.lookup(repo: this, oid: oid);
/// Creates a new tag in the repository for provided [target] object.
/// Creates a new annotated tag in the repository for provided [target]
/// object.
///
/// A new reference will also be created pointing to this tag object. If
/// [force] is true and a reference already exists with the given name, it'll
/// be replaced.
///
/// The [message] will not be cleaned up.
/// A new reference will also be created in the `/refs/tags` folder pointing
/// to this tag object. If [force] is true and a reference already exists
/// with the given name, it'll be replaced.
///
/// The [tagName] will be checked for validity. You must avoid the characters
/// '~', '^', ':', '\', '?', '[', and '*', and the sequences ".." and "@{" which have
@ -777,7 +776,7 @@ class Repository {
/// should be replaced.
///
/// Throws a [LibGit2Error] if error occured.
Oid createTag({
Oid createAnnotatedTag({
required String tagName,
required Oid target,
required GitObject targetType,
@ -785,7 +784,7 @@ class Repository {
required String message,
bool force = false,
}) {
return Tag.create(
return Tag.createAnnotated(
repo: this,
tagName: tagName,
target: target,
@ -796,6 +795,46 @@ class Repository {
);
}
/// Creates a new lightweight tag in the repository for provided [target]
/// object.
///
/// A new reference will also be created in the `/refs/tags` folder pointing
/// to this tag object. If [force] is true and a reference already exists
/// with the given name, it'll be replaced.
///
/// The [tagName] will be checked for validity. You must avoid the characters
/// '~', '^', ':', '\', '?', '[', and '*', and the sequences ".." and "@{" which have
/// special meaning to revparse.
///
/// [tagName] is the name for the tag. This name is validated for
/// consistency. It should also not conflict with an already existing tag
/// name.
///
/// [target] is the object to which this tag points. This object must belong
/// to the given [repo].
///
/// [targetType] is one of the [GitObject] basic types: commit, tree, blob or
/// tag.
///
/// [force] determines whether existing reference with the same [tagName]
/// should be replaced.
///
/// Throws a [LibGit2Error] if error occured.
void createLightweightTag({
required String tagName,
required Oid target,
required GitObject targetType,
bool force = false,
}) {
Tag.createLightweight(
repo: this,
tagName: tagName,
target: target,
targetType: targetType,
force: force,
);
}
/// Deletes an existing tag reference with provided [name].
///
/// The tag [name] will be checked for validity.