mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-04 20:29:08 -04:00
style: avoid lines longer than 80 characters
This commit is contained in:
parent
a806d0a312
commit
7b14ee6b9b
76 changed files with 1246 additions and 972 deletions
|
@ -4,6 +4,7 @@ linter:
|
||||||
- prefer_const_constructors
|
- prefer_const_constructors
|
||||||
- sort_constructors_first
|
- sort_constructors_first
|
||||||
- directives_ordering
|
- directives_ordering
|
||||||
|
- lines_longer_than_80_chars
|
||||||
analyzer:
|
analyzer:
|
||||||
exclude:
|
exclude:
|
||||||
- lib/src/bindings/libgit2_bindings.dart
|
- lib/src/bindings/libgit2_bindings.dart
|
||||||
|
|
|
@ -28,8 +28,8 @@ void main() {
|
||||||
|
|
||||||
// Set value of config variable
|
// Set value of config variable
|
||||||
repoConfig['core.variable'] = 'value';
|
repoConfig['core.variable'] = 'value';
|
||||||
print(
|
print('\nNew value for variable '
|
||||||
'\nNew value for variable "core.variable": ${repoConfig['core.variable']}');
|
'"core.variable": ${repoConfig['core.variable']}');
|
||||||
|
|
||||||
// Delete variable
|
// Delete variable
|
||||||
repoConfig.delete('core.variable');
|
repoConfig.delete('core.variable');
|
||||||
|
|
|
@ -5,8 +5,9 @@ import 'libgit2_bindings.dart';
|
||||||
|
|
||||||
/// Look up the value of one git attribute for path.
|
/// Look up the value of one git attribute for path.
|
||||||
///
|
///
|
||||||
/// Returned value can be either `true`, `false`, `null` (if the attribute was not set at all),
|
/// Returned value can be either `true`, `false`, `null` (if the attribute was
|
||||||
/// or a [String] value, if the attribute was set to an actual string.
|
/// not set at all), or a [String] value, if the attribute was set to an actual
|
||||||
|
/// string.
|
||||||
Object? getAttribute({
|
Object? getAttribute({
|
||||||
required Pointer<git_repository> repoPointer,
|
required Pointer<git_repository> repoPointer,
|
||||||
required int flags,
|
required int flags,
|
||||||
|
|
|
@ -79,7 +79,8 @@ Pointer<git_blame_hunk> getHunkByIndex({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the hunk that relates to the given line number (1-based) in the newest commit.
|
/// Gets the hunk that relates to the given line number (1-based) in the newest
|
||||||
|
/// commit.
|
||||||
///
|
///
|
||||||
/// Throws [RangeError] if [lineNumber] is out of range.
|
/// Throws [RangeError] if [lineNumber] is out of range.
|
||||||
Pointer<git_blame_hunk> getHunkByLine({
|
Pointer<git_blame_hunk> getHunkByLine({
|
||||||
|
|
|
@ -39,8 +39,8 @@ bool isBinary(Pointer<git_blob> blob) {
|
||||||
/// Get a read-only buffer with the raw content of a blob.
|
/// Get a read-only buffer with the raw content of a blob.
|
||||||
///
|
///
|
||||||
/// A pointer to the raw content of a blob is returned; this pointer is owned
|
/// A pointer to the raw content of a blob is returned; this pointer is owned
|
||||||
/// internally by the object and shall not be free'd. The pointer may be invalidated
|
/// internally by the object and shall not be free'd. The pointer may be
|
||||||
/// at a later time.
|
/// invalidated at a later time.
|
||||||
String content(Pointer<git_blob> blob) {
|
String content(Pointer<git_blob> blob) {
|
||||||
return libgit2.git_blob_rawcontent(blob).cast<Utf8>().toDartString();
|
return libgit2.git_blob_rawcontent(blob).cast<Utf8>().toDartString();
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,8 @@ Pointer<git_oid> createFromWorkdir({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Read a file from the filesystem and write its content to the Object Database as a loose blob.
|
/// Read a file from the filesystem and write its content to the Object
|
||||||
|
/// Database as a loose blob.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
Pointer<git_oid> createFromDisk({
|
Pointer<git_oid> createFromDisk({
|
||||||
|
|
|
@ -48,7 +48,8 @@ List<Pointer<git_reference>> list({
|
||||||
|
|
||||||
/// Lookup a branch by its name in a repository.
|
/// Lookup a branch by its name in a repository.
|
||||||
///
|
///
|
||||||
/// The generated reference must be freed by the user. The branch name will be checked for validity.
|
/// The generated reference must be freed by the user. The branch name will be
|
||||||
|
/// checked for validity.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
Pointer<git_reference> lookup({
|
Pointer<git_reference> lookup({
|
||||||
|
@ -78,7 +79,8 @@ Pointer<git_reference> lookup({
|
||||||
/// Create a new branch pointing at a target commit.
|
/// Create a new branch pointing at a target commit.
|
||||||
///
|
///
|
||||||
/// A new direct reference will be created pointing to this target commit.
|
/// A new direct reference will be created pointing to this target commit.
|
||||||
/// If force is true and a reference already exists with the given name, it'll be replaced.
|
/// If force is true and a reference already exists with the given name, it'll
|
||||||
|
/// be replaced.
|
||||||
///
|
///
|
||||||
/// The returned reference must be freed by the user.
|
/// The returned reference must be freed by the user.
|
||||||
///
|
///
|
||||||
|
@ -167,8 +169,8 @@ bool isHead(Pointer<git_reference> branch) {
|
||||||
|
|
||||||
/// Determine if any HEAD points to the current branch.
|
/// Determine if any HEAD points to the current branch.
|
||||||
///
|
///
|
||||||
/// This will iterate over all known linked repositories (usually in the form of worktrees)
|
/// This will iterate over all known linked repositories (usually in the form
|
||||||
/// and report whether any HEAD is pointing at the current branch.
|
/// of worktrees) and report whether any HEAD is pointing at the current branch.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
bool isCheckedOut(Pointer<git_reference> branch) {
|
bool isCheckedOut(Pointer<git_reference> branch) {
|
||||||
|
|
|
@ -6,13 +6,14 @@ import '../error.dart';
|
||||||
import '../util.dart';
|
import '../util.dart';
|
||||||
import 'libgit2_bindings.dart';
|
import 'libgit2_bindings.dart';
|
||||||
|
|
||||||
/// Updates files in the index and the working tree to match the content of the commit
|
/// Updates files in the index and the working tree to match the content of the
|
||||||
/// pointed at by HEAD.
|
/// commit pointed at by HEAD.
|
||||||
///
|
///
|
||||||
/// Note that this is not the correct mechanism used to switch branches; do not change
|
/// Note that this is not the correct mechanism used to switch branches; do not
|
||||||
/// your HEAD and then call this method, that would leave you with checkout conflicts
|
/// change your HEAD and then call this method, that would leave you with
|
||||||
/// since your working directory would then appear to be dirty. Instead, checkout the
|
/// checkout conflicts since your working directory would then appear to be
|
||||||
/// target of the branch and then update HEAD using `setHead` to point to the branch you checked out.
|
/// dirty. Instead, checkout the target of the branch and then update HEAD
|
||||||
|
/// using [setHead] to point to the branch you checked out.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
void head({
|
void head({
|
||||||
|
|
|
@ -26,14 +26,15 @@ Pointer<git_commit> lookup({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates an annotated commit from the given commit id. The resulting annotated commit
|
/// Creates an annotated commit from the given commit id. The resulting
|
||||||
/// must be freed with [annotatedFree].
|
/// annotated commit must be freed with [annotatedFree].
|
||||||
///
|
///
|
||||||
/// An annotated commit contains information about how it was looked up, which may be useful
|
/// An annotated commit contains information about how it was looked up, which
|
||||||
/// for functions like merge or rebase to provide context to the operation. For example, conflict
|
/// may be useful for functions like merge or rebase to provide context to the
|
||||||
/// files will include the name of the source or target branches being merged. It is therefore
|
/// operation. For example, conflict files will include the name of the source
|
||||||
/// preferable to use the most specific function (eg git_annotated_commit_from_ref) instead of
|
/// or target branches being merged. It is therefore preferable to use the most
|
||||||
/// this one when that data is known.
|
/// specific function (eg git_annotated_commit_from_ref) instead of this one
|
||||||
|
/// when that data is known.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
Pointer<Pointer<git_annotated_commit>> annotatedLookup({
|
Pointer<Pointer<git_annotated_commit>> annotatedLookup({
|
||||||
|
@ -117,13 +118,15 @@ Pointer<git_oid> create({
|
||||||
|
|
||||||
/// Amend an existing commit by replacing only non-null values.
|
/// Amend an existing commit by replacing only non-null values.
|
||||||
///
|
///
|
||||||
/// This creates a new commit that is exactly the same as the old commit, except that
|
/// This creates a new commit that is exactly the same as the old commit,
|
||||||
/// any non-null values will be updated. The new commit has the same parents as the old commit.
|
/// except that any non-null values will be updated. The new commit has the
|
||||||
|
/// same parents as the old commit.
|
||||||
///
|
///
|
||||||
/// The [updateRef] value works as in the regular [create], updating the ref to point to
|
/// The [updateRef] value works as in the regular [create], updating the ref to
|
||||||
/// the newly rewritten commit. If you want to amend a commit that is not currently
|
/// point to the newly rewritten commit. If you want to amend a commit that is
|
||||||
/// the tip of the branch and then rewrite the following commits to reach a ref, pass
|
/// not currently the tip of the branch and then rewrite the following commits
|
||||||
/// this as null and update the rest of the commit chain and ref separately.
|
/// to reach a ref, pass this as null and update the rest of the commit chain
|
||||||
|
/// and ref separately.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
Pointer<git_oid> amend({
|
Pointer<git_oid> amend({
|
||||||
|
@ -165,7 +168,8 @@ Pointer<git_oid> amend({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the encoding for the message of a commit, as a string representing a standard encoding name.
|
/// Get the encoding for the message of a commit, as a string representing a
|
||||||
|
/// standard encoding name.
|
||||||
///
|
///
|
||||||
/// The encoding may be NULL if the encoding header in the commit is missing;
|
/// The encoding may be NULL if the encoding header in the commit is missing;
|
||||||
/// in that case UTF-8 is assumed.
|
/// in that case UTF-8 is assumed.
|
||||||
|
@ -176,7 +180,8 @@ String messageEncoding(Pointer<git_commit> commit) {
|
||||||
|
|
||||||
/// Get the full message of a commit.
|
/// Get the full message of a commit.
|
||||||
///
|
///
|
||||||
/// The returned message will be slightly prettified by removing any potential leading newlines.
|
/// The returned message will be slightly prettified by removing any potential
|
||||||
|
/// leading newlines.
|
||||||
String message(Pointer<git_commit> commit) {
|
String message(Pointer<git_commit> commit) {
|
||||||
return libgit2.git_commit_message(commit).cast<Utf8>().toDartString();
|
return libgit2.git_commit_message(commit).cast<Utf8>().toDartString();
|
||||||
}
|
}
|
||||||
|
@ -217,10 +222,10 @@ Pointer<git_oid> tree(Pointer<git_commit> commit) {
|
||||||
return libgit2.git_commit_tree_id(commit);
|
return libgit2.git_commit_tree_id(commit);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Reverts the given commit against the given "our" commit, producing an index that
|
/// Reverts the given commit against the given "our" commit, producing an index
|
||||||
/// reflects the result of the revert.
|
/// that reflects the result of the revert.
|
||||||
///
|
///
|
||||||
/// The returned index must be freed explicitly with `free()`.
|
/// The returned index must be freed explicitly with [free].
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
Pointer<git_index> revertCommit({
|
Pointer<git_index> revertCommit({
|
||||||
|
|
|
@ -106,9 +106,9 @@ String findXdg() {
|
||||||
|
|
||||||
/// Create a snapshot of the configuration.
|
/// Create a snapshot of the configuration.
|
||||||
///
|
///
|
||||||
/// Create a snapshot of the current state of a configuration, which allows you to look
|
/// Create a snapshot of the current state of a configuration, which allows you
|
||||||
/// into a consistent view of the configuration for looking up complex values
|
/// to look into a consistent view of the configuration for looking up complex
|
||||||
/// (e.g. a remote, submodule).
|
/// values (e.g. a remote, submodule).
|
||||||
Pointer<git_config> snapshot(Pointer<git_config> config) {
|
Pointer<git_config> snapshot(Pointer<git_config> config) {
|
||||||
final out = calloc<Pointer<git_config>>();
|
final out = calloc<Pointer<git_config>>();
|
||||||
libgit2.git_config_snapshot(out, config);
|
libgit2.git_config_snapshot(out, config);
|
||||||
|
|
|
@ -10,7 +10,8 @@ import 'libgit2_bindings.dart';
|
||||||
///
|
///
|
||||||
/// Perform the describe operation on the given committish object.
|
/// Perform the describe operation on the given committish object.
|
||||||
///
|
///
|
||||||
/// Returned object should be freed with `describeResultFree()` once no longer needed.
|
/// Returned object should be freed with `describeResultFree()` once no longer
|
||||||
|
/// needed.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
Pointer<git_describe_result> commit({
|
Pointer<git_describe_result> commit({
|
||||||
|
|
|
@ -130,11 +130,12 @@ int length(Pointer<git_diff> diff) => libgit2.git_diff_num_deltas(diff);
|
||||||
|
|
||||||
/// Merge one diff into another.
|
/// Merge one diff into another.
|
||||||
///
|
///
|
||||||
/// This merges items from the "from" list into the "onto" list. The resulting diff
|
/// This merges items from the "from" list into the "onto" list. The resulting
|
||||||
/// will have all items that appear in either list. If an item appears in both lists,
|
/// diff will have all items that appear in either list. If an item appears in
|
||||||
/// then it will be "merged" to appear as if the old version was from the "onto" list
|
/// both lists, then it will be "merged" to appear as if the old version was
|
||||||
/// and the new version is from the "from" list (with the exception that if the item
|
/// from the "onto" list and the new version is from the "from" list (with the
|
||||||
/// has a pending DELETE in the middle, then it will show as deleted).
|
/// exception that if the item has a pending DELETE in the middle, then it will
|
||||||
|
/// show as deleted).
|
||||||
void merge({
|
void merge({
|
||||||
required Pointer<git_diff> ontoPointer,
|
required Pointer<git_diff> ontoPointer,
|
||||||
required Pointer<git_diff> fromPointer,
|
required Pointer<git_diff> fromPointer,
|
||||||
|
@ -144,13 +145,15 @@ void merge({
|
||||||
|
|
||||||
/// Read the contents of a git patch file into a git diff object.
|
/// Read the contents of a git patch file into a git diff object.
|
||||||
///
|
///
|
||||||
/// The diff object produced is similar to the one that would be produced if you actually
|
/// The diff object produced is similar to the one that would be produced if
|
||||||
/// produced it computationally by comparing two trees, however there may be subtle differences.
|
/// you actually produced it computationally by comparing two trees, however
|
||||||
/// For example, a patch file likely contains abbreviated object IDs, so the object IDs in a
|
/// there may be subtle differences. For example, a patch file likely contains
|
||||||
/// diff delta produced by this function will also be abbreviated.
|
/// abbreviated object IDs, so the object IDs in a diff delta produced by this
|
||||||
|
/// function will also be abbreviated.
|
||||||
///
|
///
|
||||||
/// This function will only read patch files created by a git implementation, it will not
|
/// This function will only read patch files created by a git implementation,
|
||||||
/// read unified diffs produced by the `diff` program, nor any other types of patch files.
|
/// it will not read unified diffs produced by the `diff` program, nor any
|
||||||
|
/// other types of patch files.
|
||||||
Pointer<git_diff> parse(String content) {
|
Pointer<git_diff> parse(String content) {
|
||||||
final out = calloc<Pointer<git_diff>>();
|
final out = calloc<Pointer<git_diff>>();
|
||||||
final contentC = content.toNativeUtf8().cast<Int8>();
|
final contentC = content.toNativeUtf8().cast<Int8>();
|
||||||
|
@ -163,9 +166,10 @@ Pointer<git_diff> parse(String content) {
|
||||||
|
|
||||||
/// Transform a diff marking file renames, copies, etc.
|
/// Transform a diff marking file renames, copies, etc.
|
||||||
///
|
///
|
||||||
/// This modifies a diff in place, replacing old entries that look like renames or copies
|
/// This modifies a diff in place, replacing old entries that look like renames
|
||||||
/// with new entries reflecting those changes. This also will, if requested, break modified
|
/// or copies with new entries reflecting those changes. This also will, if
|
||||||
/// files into add/remove pairs if the amount of change is above a threshold.
|
/// requested, break modified files into add/remove pairs if the amount of
|
||||||
|
/// change is above a threshold.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
void findSimilar({
|
void findSimilar({
|
||||||
|
@ -198,12 +202,13 @@ void findSimilar({
|
||||||
|
|
||||||
/// Calculate the patch ID for the given patch.
|
/// Calculate the patch ID for the given patch.
|
||||||
///
|
///
|
||||||
/// Calculate a stable patch ID for the given patch by summing the hash of the file diffs,
|
/// Calculate a stable patch ID for the given patch by summing the hash of the
|
||||||
/// ignoring whitespace and line numbers. This can be used to derive whether two diffs are
|
/// file diffs, ignoring whitespace and line numbers. This can be used to
|
||||||
/// the same with a high probability.
|
/// derive whether two diffs are the same with a high probability.
|
||||||
///
|
///
|
||||||
/// Currently, this function only calculates stable patch IDs, as defined in `git-patch-id(1)`,
|
/// Currently, this function only calculates stable patch IDs, as defined in
|
||||||
/// and should in fact generate the same IDs as the upstream git project does.
|
/// `git-patch-id(1)`, and should in fact generate the same IDs as the upstream
|
||||||
|
/// git project does.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
Pointer<git_oid> patchOid(Pointer<git_diff> diff) {
|
Pointer<git_oid> patchOid(Pointer<git_diff> diff) {
|
||||||
|
@ -228,10 +233,10 @@ Pointer<git_diff_delta> getDeltaByIndex({
|
||||||
|
|
||||||
/// Look up the single character abbreviation for a delta status code.
|
/// Look up the single character abbreviation for a delta status code.
|
||||||
///
|
///
|
||||||
/// When you run `git diff --name-status` it uses single letter codes in the output such as
|
/// When you run `git diff --name-status` it uses single letter codes in the
|
||||||
/// 'A' for added, 'D' for deleted, 'M' for modified, etc. This function converts a [GitDelta]
|
/// output such as 'A' for added, 'D' for deleted, 'M' for modified, etc. This
|
||||||
/// value into these letters for your own purposes. [GitDelta.untracked] will return
|
/// function converts a [GitDelta] value into these letters for your own
|
||||||
/// a space (i.e. ' ').
|
/// purposes. [GitDelta.untracked] will return a space (i.e. ' ').
|
||||||
String statusChar(int status) {
|
String statusChar(int status) {
|
||||||
return String.fromCharCode(libgit2.git_diff_status_char(status));
|
return String.fromCharCode(libgit2.git_diff_status_char(status));
|
||||||
}
|
}
|
||||||
|
@ -294,8 +299,8 @@ Pointer<git_buf> addToBuf({
|
||||||
return bufferPointer;
|
return bufferPointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Apply a diff to the given repository, making changes directly in the working directory,
|
/// Apply a diff to the given repository, making changes directly in the
|
||||||
/// the index, or both.
|
/// working directory, the index, or both.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
bool apply({
|
bool apply({
|
||||||
|
|
|
@ -32,9 +32,10 @@ bool descendantOf({
|
||||||
|
|
||||||
/// Count the number of unique commits between two commit objects.
|
/// Count the number of unique commits between two commit objects.
|
||||||
///
|
///
|
||||||
/// There is no need for branches containing the commits to have any upstream relationship,
|
/// There is no need for branches containing the commits to have any upstream
|
||||||
/// but it helps to think of one as a branch and the other as its upstream, the ahead and
|
/// relationship, but it helps to think of one as a branch and the other as its
|
||||||
/// behind values will be what git would report for the branches.
|
/// upstream, the ahead and behind values will be what git would report for the
|
||||||
|
/// branches.
|
||||||
List<int> aheadBehind({
|
List<int> aheadBehind({
|
||||||
required Pointer<git_repository> repoPointer,
|
required Pointer<git_repository> repoPointer,
|
||||||
required Pointer<git_oid> localPointer,
|
required Pointer<git_oid> localPointer,
|
||||||
|
|
|
@ -6,16 +6,17 @@ import '../error.dart';
|
||||||
import '../util.dart';
|
import '../util.dart';
|
||||||
import 'libgit2_bindings.dart';
|
import 'libgit2_bindings.dart';
|
||||||
|
|
||||||
/// Update the contents of an existing index object in memory by reading from the hard disk.
|
/// Update the contents of an existing index object in memory by reading from
|
||||||
|
/// the hard disk.
|
||||||
///
|
///
|
||||||
/// If force is true, this performs a "hard" read that discards in-memory changes and
|
/// If force is true, this performs a "hard" read that discards in-memory
|
||||||
/// always reloads the on-disk index data. If there is no on-disk version,
|
/// changes and always reloads the on-disk index data. If there is no on-disk
|
||||||
/// the index will be cleared.
|
/// version, the index will be cleared.
|
||||||
///
|
///
|
||||||
/// If force is false, this does a "soft" read that reloads the index data from disk only
|
/// If force is false, this does a "soft" read that reloads the index data from
|
||||||
/// if it has changed since the last time it was loaded. Purely in-memory index data
|
/// disk only if it has changed since the last time it was loaded. Purely
|
||||||
/// will be untouched. Be aware: if there are changes on disk, unwritten in-memory changes
|
/// in-memory index data will be untouched. Be aware: if there are changes on
|
||||||
/// are discarded.
|
/// disk, unwritten in-memory changes are discarded.
|
||||||
void read({required Pointer<git_index> indexPointer, required bool force}) {
|
void read({required Pointer<git_index> indexPointer, required bool force}) {
|
||||||
final forceC = force == true ? 1 : 0;
|
final forceC = force == true ? 1 : 0;
|
||||||
libgit2.git_index_read(indexPointer, forceC);
|
libgit2.git_index_read(indexPointer, forceC);
|
||||||
|
@ -33,11 +34,13 @@ void readTree({
|
||||||
|
|
||||||
/// Write the index as a tree.
|
/// Write the index as a tree.
|
||||||
///
|
///
|
||||||
/// This method will scan the index and write a representation of its current state back to disk;
|
/// This method will scan the index and write a representation of its current
|
||||||
/// it recursively creates tree objects for each of the subtrees stored in the index, but only
|
/// state back to disk; it recursively creates tree objects for each of the
|
||||||
/// returns the OID of the root tree. This is the OID that can be used e.g. to create a commit.
|
/// subtrees stored in the index, but only returns the OID of the root tree.
|
||||||
|
/// This is the OID that can be used e.g. to create a commit.
|
||||||
///
|
///
|
||||||
/// The index instance cannot be bare, and needs to be associated to an existing repository.
|
/// The index instance cannot be bare, and needs to be associated to an
|
||||||
|
/// existing repository.
|
||||||
///
|
///
|
||||||
/// The index must not contain any file in conflict.
|
/// The index must not contain any file in conflict.
|
||||||
///
|
///
|
||||||
|
@ -56,8 +59,8 @@ Pointer<git_oid> writeTree(Pointer<git_index> index) {
|
||||||
|
|
||||||
/// Write the index as a tree to the given repository.
|
/// Write the index as a tree to the given repository.
|
||||||
///
|
///
|
||||||
/// This method will do the same as [writeTree], but letting the user choose the repository
|
/// This method will do the same as [writeTree], but letting the user choose
|
||||||
/// where the tree will be written.
|
/// the repository where the tree will be written.
|
||||||
///
|
///
|
||||||
/// The index must not contain any file in conflict.
|
/// The index must not contain any file in conflict.
|
||||||
///
|
///
|
||||||
|
@ -77,7 +80,8 @@ Pointer<git_oid> writeTreeTo({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Find the first position of any entries which point to given path in the Git index.
|
/// Find the first position of any entries which point to given path in the Git
|
||||||
|
/// index.
|
||||||
bool find({required Pointer<git_index> indexPointer, required String path}) {
|
bool find({required Pointer<git_index> indexPointer, required String path}) {
|
||||||
final pathC = path.toNativeUtf8().cast<Int8>();
|
final pathC = path.toNativeUtf8().cast<Int8>();
|
||||||
final result = libgit2.git_index_find(nullptr, indexPointer, pathC);
|
final result = libgit2.git_index_find(nullptr, indexPointer, pathC);
|
||||||
|
@ -132,8 +136,8 @@ Pointer<git_index_entry> getByPath({
|
||||||
|
|
||||||
/// Clear the contents (all the entries) of an index object.
|
/// Clear the contents (all the entries) of an index object.
|
||||||
///
|
///
|
||||||
/// This clears the index object in memory; changes must be explicitly written to
|
/// This clears the index object in memory; changes must be explicitly written
|
||||||
/// disk for them to take effect persistently.
|
/// to disk for them to take effect persistently.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
void clear(Pointer<git_index> index) {
|
void clear(Pointer<git_index> index) {
|
||||||
|
@ -146,8 +150,9 @@ void clear(Pointer<git_index> index) {
|
||||||
|
|
||||||
/// Add or update an index entry from an in-memory struct.
|
/// Add or update an index entry from an in-memory struct.
|
||||||
///
|
///
|
||||||
/// If a previous index entry exists that has the same path and stage as the given `sourceEntry`,
|
/// If a previous index entry exists that has the same path and stage as the
|
||||||
/// it will be replaced. Otherwise, the `sourceEntry` will be added.
|
/// given `sourceEntry`, it will be replaced. Otherwise, the `sourceEntry` will
|
||||||
|
/// be added.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
void add({
|
void add({
|
||||||
|
@ -163,15 +168,17 @@ void add({
|
||||||
|
|
||||||
/// Add or update an index entry from a file on disk.
|
/// Add or update an index entry from a file on disk.
|
||||||
///
|
///
|
||||||
/// The file path must be relative to the repository's working folder and must be readable.
|
/// The file path must be relative to the repository's working folder and must
|
||||||
|
/// be readable.
|
||||||
///
|
///
|
||||||
/// This method will fail in bare index instances.
|
/// This method will fail in bare index instances.
|
||||||
///
|
///
|
||||||
/// This forces the file to be added to the index, not looking at gitignore rules.
|
/// This forces the file to be added to the index, not looking at gitignore
|
||||||
|
/// rules.
|
||||||
///
|
///
|
||||||
/// If this file currently is the result of a merge conflict, this file will no longer be
|
/// If this file currently is the result of a merge conflict, this file will no
|
||||||
/// marked as conflicting. The data about the conflict will be moved to the "resolve undo"
|
/// longer be marked as conflicting. The data about the conflict will be moved
|
||||||
/// (REUC) section.
|
/// to the "resolve undo" (REUC) section.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
void addByPath({
|
void addByPath({
|
||||||
|
@ -192,9 +199,10 @@ void addByPath({
|
||||||
///
|
///
|
||||||
/// This method will fail in bare index instances.
|
/// This method will fail in bare index instances.
|
||||||
///
|
///
|
||||||
/// The `pathspec` is a list of file names or shell glob patterns that will be matched
|
/// The `pathspec` is a list of file names or shell glob patterns that will be
|
||||||
/// against files in the repository's working directory. Each file that matches will be
|
/// matched against files in the repository's working directory. Each file that
|
||||||
/// added to the index (either updating an existing entry or adding a new entry).
|
/// matches will be added to the index (either updating an existing entry or
|
||||||
|
/// adding a new entry).
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
void addAll({
|
void addAll({
|
||||||
|
@ -232,7 +240,8 @@ void addAll({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Write an existing index object from memory back to disk using an atomic file lock.
|
/// Write an existing index object from memory back to disk using an atomic
|
||||||
|
/// file lock.
|
||||||
void write(Pointer<git_index> index) => libgit2.git_index_write(index);
|
void write(Pointer<git_index> index) => libgit2.git_index_write(index);
|
||||||
|
|
||||||
/// Remove an entry from the index.
|
/// Remove an entry from the index.
|
||||||
|
|
|
@ -25,8 +25,8 @@ Pointer<git_oid> mergeBase({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Analyzes the given branch(es) and determines the opportunities for merging them
|
/// Analyzes the given branch(es) and determines the opportunities for merging
|
||||||
/// into a reference.
|
/// them into a reference.
|
||||||
List<int> analysis({
|
List<int> analysis({
|
||||||
required Pointer<git_repository> repoPointer,
|
required Pointer<git_repository> repoPointer,
|
||||||
required Pointer<git_reference> ourRefPointer,
|
required Pointer<git_reference> ourRefPointer,
|
||||||
|
@ -52,10 +52,10 @@ List<int> analysis({
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Merges the given commit(s) into HEAD, writing the results into the working directory.
|
/// Merges the given commit(s) into HEAD, writing the results into the working
|
||||||
/// Any changes are staged for commit and any conflicts are written to the index. Callers
|
/// directory. Any changes are staged for commit and any conflicts are written
|
||||||
/// should inspect the repository's index after this completes, resolve any conflicts and
|
/// to the index. Callers should inspect the repository's index after this
|
||||||
/// prepare a commit.
|
/// completes, resolve any conflicts and prepare a commit.
|
||||||
void merge({
|
void merge({
|
||||||
required Pointer<git_repository> repoPointer,
|
required Pointer<git_repository> repoPointer,
|
||||||
required Pointer<Pointer<git_annotated_commit>> theirHeadsPointer,
|
required Pointer<Pointer<git_annotated_commit>> theirHeadsPointer,
|
||||||
|
@ -84,8 +84,8 @@ void merge({
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Merge two files as they exist in the index, using the given common ancestor
|
/// Merge two files as they exist in the index, using the given common ancestor
|
||||||
/// as the baseline, producing a string that reflects the merge result containing
|
/// as the baseline, producing a string that reflects the merge result
|
||||||
/// possible conflicts.
|
/// containing possible conflicts.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
String mergeFileFromIndex({
|
String mergeFileFromIndex({
|
||||||
|
@ -114,10 +114,10 @@ String mergeFileFromIndex({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Merge two commits, producing a git_index that reflects the result of the merge.
|
/// Merge two commits, producing a git_index that reflects the result of the
|
||||||
/// The index may be written as-is to the working directory or checked out. If the index
|
/// merge. The index may be written as-is to the working directory or checked
|
||||||
/// is to be converted to a tree, the caller should resolve any conflicts that arose as
|
/// out. If the index is to be converted to a tree, the caller should resolve
|
||||||
/// part of the merge.
|
/// any conflicts that arose as part of the merge.
|
||||||
///
|
///
|
||||||
/// The returned index must be freed explicitly.
|
/// The returned index must be freed explicitly.
|
||||||
///
|
///
|
||||||
|
@ -155,10 +155,10 @@ Pointer<git_index> mergeCommits({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Merge two trees, producing a git_index that reflects the result of the merge.
|
/// Merge two trees, producing a git_index that reflects the result of the
|
||||||
/// The index may be written as-is to the working directory or checked out. If the index
|
/// merge. The index may be written as-is to the working directory or checked
|
||||||
/// is to be converted to a tree, the caller should resolve any conflicts that arose as part
|
/// out. If the index is to be converted to a tree, the caller should resolve
|
||||||
/// of the merge.
|
/// any conflicts that arose as part of the merge.
|
||||||
///
|
///
|
||||||
/// The returned index must be freed explicitly.
|
/// The returned index must be freed explicitly.
|
||||||
///
|
///
|
||||||
|
@ -198,7 +198,8 @@ Pointer<git_index> mergeTrees({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Cherry-pick the given commit, producing changes in the index and working directory.
|
/// Cherry-pick the given commit, producing changes in the index and working
|
||||||
|
/// directory.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
void cherryPick({
|
void cherryPick({
|
||||||
|
|
|
@ -14,9 +14,9 @@ int type(Pointer<git_object> obj) => libgit2.git_object_type(obj);
|
||||||
/// The generated reference is owned by the repository and should be closed with
|
/// The generated reference is owned by the repository and should be closed with
|
||||||
/// the `free()` method instead of free'd manually.
|
/// the `free()` method instead of free'd manually.
|
||||||
///
|
///
|
||||||
/// The 'type' parameter must match the type of the object in the odb; the method will
|
/// The 'type' parameter must match the type of the object in the odb; the
|
||||||
/// fail otherwise. The special value 'GIT_OBJECT_ANY' may be passed to let the method
|
/// method will fail otherwise. The special value 'GIT_OBJECT_ANY' may be
|
||||||
/// guess the object's type.
|
/// passed to let the method guess the object's type.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
Pointer<git_object> lookup({
|
Pointer<git_object> lookup({
|
||||||
|
@ -37,8 +37,8 @@ Pointer<git_object> lookup({
|
||||||
|
|
||||||
/// Close an open object to release memory.
|
/// Close an open object to release memory.
|
||||||
///
|
///
|
||||||
/// This method instructs the library to close an existing object; note that git_objects
|
/// This method instructs the library to close an existing object; note that
|
||||||
/// are owned and cached by the repository so the object may or may not be freed after
|
/// git_objects are owned and cached by the repository so the object may or may
|
||||||
/// this library call, depending on how aggressive is the caching mechanism used by
|
/// not be freed after this library call, depending on how aggressive is the
|
||||||
/// the repository.
|
/// caching mechanism used by the repository.
|
||||||
void free(Pointer<git_object> object) => libgit2.git_object_free(object);
|
void free(Pointer<git_object> object) => libgit2.git_object_free(object);
|
||||||
|
|
|
@ -20,11 +20,11 @@ Pointer<git_odb> create() {
|
||||||
|
|
||||||
/// Add an on-disk alternate to an existing Object DB.
|
/// Add an on-disk alternate to an existing Object DB.
|
||||||
///
|
///
|
||||||
/// Note that the added path must point to an `objects`, not to a full repository,
|
/// Note that the added path must point to an `objects`, not to a full
|
||||||
/// to use it as an alternate store.
|
/// repository, to use it as an alternate store.
|
||||||
///
|
///
|
||||||
/// Alternate backends are always checked for objects after all the main backends
|
/// Alternate backends are always checked for objects after all the main
|
||||||
/// have been exhausted.
|
/// backends have been exhausted.
|
||||||
///
|
///
|
||||||
/// Writing is disabled on alternate backends.
|
/// Writing is disabled on alternate backends.
|
||||||
void addDiskAlternate({
|
void addDiskAlternate({
|
||||||
|
@ -36,7 +36,8 @@ void addDiskAlternate({
|
||||||
calloc.free(pathC);
|
calloc.free(pathC);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Determine if an object can be found in the object database by an abbreviated object ID.
|
/// Determine if an object can be found in the object database by an
|
||||||
|
/// abbreviated object ID.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
Pointer<git_oid> existsPrefix({
|
Pointer<git_oid> existsPrefix({
|
||||||
|
@ -108,8 +109,8 @@ List<Oid> objects(Pointer<git_odb> odb) {
|
||||||
///
|
///
|
||||||
/// This method queries all available ODB backends trying to read the given OID.
|
/// This method queries all available ODB backends trying to read the given OID.
|
||||||
///
|
///
|
||||||
/// The returned object is reference counted and internally cached, so it should be
|
/// The returned object is reference counted and internally cached, so it
|
||||||
/// closed by the user once it's no longer in use.
|
/// should be closed by the user once it's no longer in use.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
Pointer<git_odb_object> read({
|
Pointer<git_odb_object> read({
|
||||||
|
@ -141,14 +142,16 @@ int objectType(Pointer<git_odb_object> object) {
|
||||||
|
|
||||||
/// Return the data of an ODB object.
|
/// Return the data of an ODB object.
|
||||||
///
|
///
|
||||||
/// This is the uncompressed, raw data as read from the ODB, without the leading header.
|
/// This is the uncompressed, raw data as read from the ODB, without the
|
||||||
|
/// leading header.
|
||||||
String objectData(Pointer<git_odb_object> object) {
|
String objectData(Pointer<git_odb_object> object) {
|
||||||
return libgit2.git_odb_object_data(object).cast<Utf8>().toDartString();
|
return libgit2.git_odb_object_data(object).cast<Utf8>().toDartString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the size of an ODB object.
|
/// Return the size of an ODB object.
|
||||||
///
|
///
|
||||||
/// This is the real size of the `data` buffer, not the actual size of the object.
|
/// This is the real size of the `data` buffer, not the actual size of the
|
||||||
|
/// object.
|
||||||
int objectSize(Pointer<git_odb_object> object) {
|
int objectSize(Pointer<git_odb_object> object) {
|
||||||
return libgit2.git_odb_object_size(object);
|
return libgit2.git_odb_object_size(object);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,8 @@ import 'libgit2_bindings.dart';
|
||||||
|
|
||||||
/// Directly generate a patch from the difference between two buffers.
|
/// Directly generate a patch from the difference between two buffers.
|
||||||
///
|
///
|
||||||
/// You can use the standard patch accessor functions to read the patch data, and
|
/// You can use the standard patch accessor functions to read the patch data,
|
||||||
/// you must free the patch when done.
|
/// and you must free the patch when done.
|
||||||
Map<String, Pointer?> fromBuffers({
|
Map<String, Pointer?> fromBuffers({
|
||||||
String? oldBuffer,
|
String? oldBuffer,
|
||||||
String? oldAsPath,
|
String? oldAsPath,
|
||||||
|
@ -47,16 +47,16 @@ Map<String, Pointer?> fromBuffers({
|
||||||
calloc.free(newAsPathC);
|
calloc.free(newAsPathC);
|
||||||
calloc.free(opts);
|
calloc.free(opts);
|
||||||
|
|
||||||
// Returning map with pointers to patch and buffers because patch object does not
|
// Returning map with pointers to patch and buffers because patch object does
|
||||||
// have refenrece to underlying buffers or blobs. So if the buffer or blob is freed/removed
|
// not have refenrece to underlying buffers or blobs. So if the buffer or blob is freed/removed
|
||||||
// the patch text becomes corrupted.
|
// the patch text becomes corrupted.
|
||||||
return {'patch': out.value, 'a': oldBufferC, 'b': newBufferC};
|
return {'patch': out.value, 'a': oldBufferC, 'b': newBufferC};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Directly generate a patch from the difference between two blobs.
|
/// Directly generate a patch from the difference between two blobs.
|
||||||
///
|
///
|
||||||
/// You can use the standard patch accessor functions to read the patch data, and you
|
/// You can use the standard patch accessor functions to read the patch data,
|
||||||
/// must free the patch when done.
|
/// and you must free the patch when done.
|
||||||
Map<String, Pointer?> fromBlobs({
|
Map<String, Pointer?> fromBlobs({
|
||||||
required Pointer<git_blob> oldBlobPointer,
|
required Pointer<git_blob> oldBlobPointer,
|
||||||
String? oldAsPath,
|
String? oldAsPath,
|
||||||
|
@ -88,16 +88,16 @@ Map<String, Pointer?> fromBlobs({
|
||||||
calloc.free(newAsPathC);
|
calloc.free(newAsPathC);
|
||||||
calloc.free(opts);
|
calloc.free(opts);
|
||||||
|
|
||||||
// Returning map with pointers to patch and blobs because patch object does not
|
// Returning map with pointers to patch and blobs because patch object does
|
||||||
// have reference to underlying blobs. So if the blob is freed/removed the patch
|
// not have reference to underlying blobs. So if the blob is freed/removed the
|
||||||
// text becomes corrupted.
|
// patch text becomes corrupted.
|
||||||
return {'patch': out.value, 'a': oldBlobPointer, 'b': newBlobPointer};
|
return {'patch': out.value, 'a': oldBlobPointer, 'b': newBlobPointer};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Directly generate a patch from the difference between a blob and a buffer.
|
/// Directly generate a patch from the difference between a blob and a buffer.
|
||||||
///
|
///
|
||||||
/// You can use the standard patch accessor functions to read the patch data, and you must
|
/// You can use the standard patch accessor functions to read the patch data,
|
||||||
/// free the patch when done.
|
/// and you must free the patch when done.
|
||||||
Map<String, Pointer?> fromBlobAndBuffer({
|
Map<String, Pointer?> fromBlobAndBuffer({
|
||||||
Pointer<git_blob>? oldBlobPointer,
|
Pointer<git_blob>? oldBlobPointer,
|
||||||
String? oldAsPath,
|
String? oldAsPath,
|
||||||
|
@ -132,17 +132,17 @@ Map<String, Pointer?> fromBlobAndBuffer({
|
||||||
calloc.free(bufferAsPathC);
|
calloc.free(bufferAsPathC);
|
||||||
calloc.free(opts);
|
calloc.free(opts);
|
||||||
|
|
||||||
// Returning map with pointers to patch and buffers because patch object does not
|
// Returning map with pointers to patch and buffers because patch object does
|
||||||
// have reference to underlying buffers or blobs. So if the buffer or blob is freed/removed
|
// not have reference to underlying buffers or blobs. So if the buffer or
|
||||||
// the patch text becomes corrupted.
|
// blob is freed/removed the patch text becomes corrupted.
|
||||||
return {'patch': out.value, 'a': oldBlobPointer, 'b': bufferC};
|
return {'patch': out.value, 'a': oldBlobPointer, 'b': bufferC};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return a patch for an entry in the diff list.
|
/// Return a patch for an entry in the diff list.
|
||||||
///
|
///
|
||||||
/// The newly created patch object contains the text diffs for the delta. You have to call
|
/// The newly created patch object contains the text diffs for the delta. You
|
||||||
/// `free()` when you are done with it. You can use the patch object to loop over all the
|
/// have to call [free] when you are done with it. You can use the patch object
|
||||||
/// hunks and lines in the diff of the one delta.
|
/// to loop over all the hunks and lines in the diff of the one delta.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
Pointer<git_patch> fromDiff({
|
Pointer<git_patch> fromDiff({
|
||||||
|
@ -169,8 +169,8 @@ int numHunks(Pointer<git_patch> patch) => libgit2.git_patch_num_hunks(patch);
|
||||||
|
|
||||||
/// Get the information about a hunk in a patch.
|
/// Get the information about a hunk in a patch.
|
||||||
///
|
///
|
||||||
/// Given a patch and a hunk index into the patch, this returns detailed information
|
/// Given a patch and a hunk index into the patch, this returns detailed
|
||||||
/// about that hunk.
|
/// information about that hunk.
|
||||||
Map<String, Object> hunk({
|
Map<String, Object> hunk({
|
||||||
required Pointer<git_patch> patchPointer,
|
required Pointer<git_patch> patchPointer,
|
||||||
required int hunkIndex,
|
required int hunkIndex,
|
||||||
|
@ -215,12 +215,12 @@ String text(Pointer<git_patch> patch) {
|
||||||
|
|
||||||
/// Look up size of patch diff data in bytes.
|
/// Look up size of patch diff data in bytes.
|
||||||
///
|
///
|
||||||
/// This returns the raw size of the patch data. This only includes the actual data from
|
/// This returns the raw size of the patch data. This only includes the actual
|
||||||
/// the lines of the diff, not the file or hunk headers.
|
/// data from the lines of the diff, not the file or hunk headers.
|
||||||
///
|
///
|
||||||
/// If you pass `includeContext` as true, this will be the size of all of the diff output;
|
/// If you pass `includeContext` as true, this will be the size of all of the
|
||||||
/// if you pass it as false, this will only include the actual changed lines (as if
|
/// diff output; if you pass it as false, this will only include the actual
|
||||||
/// contextLines was 0).
|
/// changed lines (as if contextLines was 0).
|
||||||
int size({
|
int size({
|
||||||
required Pointer<git_patch> patchPointer,
|
required Pointer<git_patch> patchPointer,
|
||||||
required bool includeContext,
|
required bool includeContext,
|
||||||
|
|
|
@ -6,16 +6,19 @@ import '../error.dart';
|
||||||
import '../util.dart';
|
import '../util.dart';
|
||||||
import 'libgit2_bindings.dart';
|
import 'libgit2_bindings.dart';
|
||||||
|
|
||||||
/// Initializes a rebase operation to rebase the changes in [branchPointer] relative
|
/// Initializes a rebase operation to rebase the changes in [branchPointer]
|
||||||
/// to [upstreamPointer] onto [ontoPointer] another branch. To begin the rebase process, call
|
/// relative to [upstreamPointer] onto [ontoPointer] another branch. To begin
|
||||||
/// `next()`. When you have finished with this object, call `free()`.
|
/// the rebase process, call [next]. When you have finished with this object,
|
||||||
|
/// call [free].
|
||||||
///
|
///
|
||||||
/// [branchPointer] is the terminal commit to rebase, or null to rebase the current branch.
|
/// [branchPointer] is the terminal commit to rebase, or null to rebase the
|
||||||
|
/// current branch.
|
||||||
///
|
///
|
||||||
/// [upstreamPointer] is the commit to begin rebasing from, or null to rebase all
|
/// [upstreamPointer] is the commit to begin rebasing from, or null to rebase
|
||||||
/// reachable commits.
|
/// all reachable commits.
|
||||||
///
|
///
|
||||||
/// [ontoPointer] is the branch to rebase onto, or null to rebase onto the given upstream.
|
/// [ontoPointer] is the branch to rebase onto, or null to rebase onto the
|
||||||
|
/// given upstream.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
Pointer<git_rebase> init({
|
Pointer<git_rebase> init({
|
||||||
|
@ -102,12 +105,13 @@ void commit({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Finishes a rebase that is currently in progress once all patches have been applied.
|
/// Finishes a rebase that is currently in progress once all patches have been
|
||||||
|
/// applied.
|
||||||
void finish(Pointer<git_rebase> rebase) =>
|
void finish(Pointer<git_rebase> rebase) =>
|
||||||
libgit2.git_rebase_finish(rebase, nullptr);
|
libgit2.git_rebase_finish(rebase, nullptr);
|
||||||
|
|
||||||
/// Aborts a rebase that is currently in progress, resetting the repository and working
|
/// Aborts a rebase that is currently in progress, resetting the repository and
|
||||||
/// directory to their state before rebase began.
|
/// working directory to their state before rebase began.
|
||||||
void abort(Pointer<git_rebase> rebase) => libgit2.git_rebase_abort(rebase);
|
void abort(Pointer<git_rebase> rebase) => libgit2.git_rebase_abort(rebase);
|
||||||
|
|
||||||
/// Free memory allocated for rebase object.
|
/// Free memory allocated for rebase object.
|
||||||
|
|
|
@ -14,7 +14,8 @@ int referenceType(Pointer<git_reference> ref) =>
|
||||||
|
|
||||||
/// Get the OID pointed to by a direct reference.
|
/// Get the OID pointed to by a direct reference.
|
||||||
///
|
///
|
||||||
/// Only available if the reference is direct (i.e. an object id reference, not a symbolic one).
|
/// Only available if the reference is direct (i.e. an object id reference, not
|
||||||
|
/// a symbolic one).
|
||||||
Pointer<git_oid> target(Pointer<git_reference> ref) =>
|
Pointer<git_oid> target(Pointer<git_reference> ref) =>
|
||||||
libgit2.git_reference_target(ref);
|
libgit2.git_reference_target(ref);
|
||||||
|
|
||||||
|
@ -25,8 +26,8 @@ Pointer<git_oid> target(Pointer<git_reference> ref) =>
|
||||||
///
|
///
|
||||||
/// The peeled reference must be freed manually once it's no longer needed.
|
/// The peeled reference must be freed manually once it's no longer needed.
|
||||||
///
|
///
|
||||||
/// If a direct reference is passed as an argument, a copy of that reference is returned.
|
/// If a direct reference is passed as an argument, a copy of that reference is
|
||||||
/// This copy must be manually freed too.
|
/// returned. This copy must be manually freed too.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
Pointer<git_reference> resolve(Pointer<git_reference> ref) {
|
Pointer<git_reference> resolve(Pointer<git_reference> ref) {
|
||||||
|
@ -85,11 +86,11 @@ String shorthand(Pointer<git_reference> ref) {
|
||||||
///
|
///
|
||||||
/// The new name will be checked for validity.
|
/// The new name will be checked for validity.
|
||||||
///
|
///
|
||||||
/// If the force flag is not enabled, and there's already a reference with the given name,
|
/// If the force flag is not enabled, and there's already a reference with the
|
||||||
/// the renaming will fail.
|
/// given name, the renaming will fail.
|
||||||
///
|
///
|
||||||
/// IMPORTANT: The user needs to write a proper reflog entry if the reflog is enabled for
|
/// IMPORTANT: The user needs to write a proper reflog entry if the reflog is
|
||||||
/// the repository. We only rename the reflog if it exists.
|
/// enabled for the repository. We only rename the reflog if it exists.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
Pointer<git_reference> rename({
|
Pointer<git_reference> rename({
|
||||||
|
@ -179,25 +180,29 @@ bool isTag(Pointer<git_reference> ref) {
|
||||||
/// Create a new direct reference.
|
/// Create a new direct reference.
|
||||||
///
|
///
|
||||||
/// A direct reference (also called an object id reference) refers directly to a
|
/// A direct reference (also called an object id reference) refers directly to a
|
||||||
/// specific object id (a.k.a. OID or SHA) in the repository. The id permanently refers to
|
/// specific object id (a.k.a. OID or SHA) in the repository. The id
|
||||||
/// the object (although the reference itself can be moved). For example, in libgit2
|
/// permanently refers to the object (although the reference itself can be
|
||||||
/// the direct ref "refs/tags/v0.17.0" refers to OID 5b9fac39d8a76b9139667c26a63e6b3f204b3977.
|
/// moved). For example, in libgit2 the direct ref "refs/tags/v0.17.0" refers
|
||||||
|
/// to OID 5b9fac39d8a76b9139667c26a63e6b3f204b3977.
|
||||||
///
|
///
|
||||||
/// The direct reference will be created in the repository and written to the disk.
|
/// The direct reference will be created in the repository and written to the
|
||||||
/// The generated reference object must be freed by the user.
|
/// disk. The generated reference object must be freed by the user.
|
||||||
///
|
///
|
||||||
/// Valid reference names must follow one of two patterns:
|
/// Valid reference names must follow one of two patterns:
|
||||||
///
|
///
|
||||||
/// Top-level names must contain only capital letters and underscores, and must begin and end
|
/// Top-level names must contain only capital letters and underscores, and
|
||||||
/// with a letter. (e.g. "HEAD", "ORIG_HEAD").
|
/// must begin and end with a letter. (e.g. "HEAD", "ORIG_HEAD").
|
||||||
/// Names prefixed with "refs/" can be almost anything. You must avoid the characters
|
/// Names prefixed with "refs/" can be almost anything. You must avoid the
|
||||||
/// '~', '^', ':', '\', '?', '[', and '*', and the sequences ".." and "@{" which have
|
/// characters '~', '^', ':', '\', '?', '[', and '*', and the sequences ".."
|
||||||
/// special meaning to revparse.
|
/// and "@{" which have special meaning to revparse.
|
||||||
/// This function will throw a [LibGit2Error] if a reference already exists with the given name
|
|
||||||
/// unless force is true, in which case it will be overwritten.
|
|
||||||
///
|
///
|
||||||
/// The message for the reflog will be ignored if the reference does not belong in the
|
/// This function will throw a [LibGit2Error] if a reference already exists
|
||||||
/// standard set (HEAD, branches and remote-tracking branches) and it does not have a reflog.
|
/// with the given name unless force is true, in which case it will be
|
||||||
|
/// overwritten.
|
||||||
|
///
|
||||||
|
/// The message for the reflog will be ignored if the reference does not belong
|
||||||
|
/// in the standard set (HEAD, branches and remote-tracking branches) and it
|
||||||
|
/// does not have a reflog.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
Pointer<git_reference> createDirect({
|
Pointer<git_reference> createDirect({
|
||||||
|
@ -233,26 +238,29 @@ Pointer<git_reference> createDirect({
|
||||||
|
|
||||||
/// Create a new symbolic reference.
|
/// Create a new symbolic reference.
|
||||||
///
|
///
|
||||||
/// A symbolic reference is a reference name that refers to another reference name.
|
/// A symbolic reference is a reference name that refers to another reference
|
||||||
/// If the other name moves, the symbolic name will move, too. As a simple example,
|
/// name. If the other name moves, the symbolic name will move, too. As a
|
||||||
/// the "HEAD" reference might refer to "refs/heads/master" while on the "master" branch
|
/// simple example, the "HEAD" reference might refer to "refs/heads/master"
|
||||||
/// of a repository.
|
/// while on the "master" branch of a repository.
|
||||||
///
|
///
|
||||||
/// The symbolic reference will be created in the repository and written to the disk.
|
/// The symbolic reference will be created in the repository and written to the
|
||||||
/// The generated reference object must be freed by the user.
|
/// disk. The generated reference object must be freed by the user.
|
||||||
///
|
///
|
||||||
/// Valid reference names must follow one of two patterns:
|
/// Valid reference names must follow one of two patterns:
|
||||||
///
|
///
|
||||||
/// Top-level names must contain only capital letters and underscores, and must begin and end
|
/// Top-level names must contain only capital letters and underscores, and must
|
||||||
/// with a letter. (e.g. "HEAD", "ORIG_HEAD").
|
/// begin and end with a letter. (e.g. "HEAD", "ORIG_HEAD").
|
||||||
/// Names prefixed with "refs/" can be almost anything. You must avoid the characters
|
/// Names prefixed with "refs/" can be almost anything. You must avoid the
|
||||||
/// '~', '^', ':', '\', '?', '[', and '*', and the sequences ".." and "@{" which have special
|
/// characters '~', '^', ':', '\', '?', '[', and '*', and the sequences ".." and
|
||||||
/// meaning to revparse.
|
/// "@{" which have special meaning to revparse.
|
||||||
/// This function will throw an [LibGit2Error] if a reference already exists with the given
|
|
||||||
/// name unless force is true, in which case it will be overwritten.
|
|
||||||
///
|
///
|
||||||
/// The message for the reflog will be ignored if the reference does not belong in the standard
|
/// This function will throw an [LibGit2Error] if a reference already exists
|
||||||
/// set (HEAD, branches and remote-tracking branches) and it does not have a reflog.
|
/// with the given name unless force is true, in which case it will be
|
||||||
|
/// overwritten.
|
||||||
|
///
|
||||||
|
/// The message for the reflog will be ignored if the reference does not belong
|
||||||
|
/// in the standard set (HEAD, branches and remote-tracking branches) and it
|
||||||
|
/// does not have a reflog.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
Pointer<git_reference> createSymbolic({
|
Pointer<git_reference> createSymbolic({
|
||||||
|
@ -291,7 +299,8 @@ Pointer<git_reference> createSymbolic({
|
||||||
/// Delete an existing reference.
|
/// Delete an existing reference.
|
||||||
///
|
///
|
||||||
/// This method works for both direct and symbolic references.
|
/// This method works for both direct and symbolic references.
|
||||||
/// The reference will be immediately removed on disk but the memory will not be freed.
|
/// The reference will be immediately removed on disk but the memory will not
|
||||||
|
/// be freed.
|
||||||
void delete(Pointer<git_reference> ref) => libgit2.git_reference_delete(ref);
|
void delete(Pointer<git_reference> ref) => libgit2.git_reference_delete(ref);
|
||||||
|
|
||||||
/// Get the repository where a reference resides.
|
/// Get the repository where a reference resides.
|
||||||
|
@ -299,8 +308,9 @@ Pointer<git_repository> owner(Pointer<git_reference> ref) {
|
||||||
return libgit2.git_reference_owner(ref);
|
return libgit2.git_reference_owner(ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Conditionally create a new reference with the same name as the given reference
|
/// Conditionally create a new reference with the same name as the given
|
||||||
/// but a different OID target. The reference must be a direct reference, otherwise this will fail.
|
/// reference but a different OID target. The reference must be a direct
|
||||||
|
/// reference, otherwise this will fail.
|
||||||
///
|
///
|
||||||
/// The new reference will be written to disk, overwriting the given reference.
|
/// The new reference will be written to disk, overwriting the given reference.
|
||||||
///
|
///
|
||||||
|
@ -329,15 +339,17 @@ Pointer<git_reference> setTarget({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a new reference with the same name as the given reference but a different
|
/// Create a new reference with the same name as the given reference but a
|
||||||
/// symbolic target. The reference must be a symbolic reference, otherwise this will fail.
|
/// different symbolic target. The reference must be a symbolic reference,
|
||||||
|
/// otherwise this will fail.
|
||||||
///
|
///
|
||||||
/// The new reference will be written to disk, overwriting the given reference.
|
/// The new reference will be written to disk, overwriting the given reference.
|
||||||
///
|
///
|
||||||
/// The target name will be checked for validity.
|
/// The target name will be checked for validity.
|
||||||
///
|
///
|
||||||
/// The message for the reflog will be ignored if the reference does not belong in the
|
/// The message for the reflog will be ignored if the reference does not belong
|
||||||
/// standard set (HEAD, branches and remote-tracking branches) and and it does not have a reflog.
|
/// in the standard set (HEAD, branches and remote-tracking branches) and and
|
||||||
|
/// it does not have a reflog.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
Pointer<git_reference> setTargetSymbolic({
|
Pointer<git_reference> setTargetSymbolic({
|
||||||
|
@ -378,10 +390,11 @@ bool compare({
|
||||||
|
|
||||||
/// Recursively peel reference until object of the specified type is found.
|
/// Recursively peel reference until object of the specified type is found.
|
||||||
///
|
///
|
||||||
/// The retrieved peeled object is owned by the repository and should be closed to release memory.
|
/// The retrieved peeled object is owned by the repository and should be closed
|
||||||
|
/// to release memory.
|
||||||
///
|
///
|
||||||
/// If you pass GIT_OBJECT_ANY as the target type, then the object will be peeled until a
|
/// If you pass GIT_OBJECT_ANY as the target type, then the object will be
|
||||||
/// non-tag object is met.
|
/// peeled until a non-tag object is met.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
Pointer<git_object> peel({
|
Pointer<git_object> peel({
|
||||||
|
|
|
@ -79,7 +79,8 @@ String transform({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Transform a target reference to its source reference following the refspec's rules.
|
/// Transform a target reference to its source reference following the
|
||||||
|
/// refspec's rules.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
String rTransform({
|
String rTransform({
|
||||||
|
|
|
@ -47,7 +47,8 @@ Pointer<git_remote> lookup({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add a remote with the default fetch refspec to the repository's configuration.
|
/// Add a remote with the default fetch refspec to the repository's
|
||||||
|
/// configuration.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
Pointer<git_remote> create({
|
Pointer<git_remote> create({
|
||||||
|
@ -71,7 +72,8 @@ Pointer<git_remote> create({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add a remote with the provided fetch refspec to the repository's configuration.
|
/// Add a remote with the provided fetch refspec to the repository's
|
||||||
|
/// configuration.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
Pointer<git_remote> createWithFetchSpec({
|
Pointer<git_remote> createWithFetchSpec({
|
||||||
|
@ -106,7 +108,8 @@ Pointer<git_remote> createWithFetchSpec({
|
||||||
|
|
||||||
/// Delete an existing persisted remote.
|
/// Delete an existing persisted remote.
|
||||||
///
|
///
|
||||||
/// All remote-tracking branches and configuration settings for the remote will be removed.
|
/// All remote-tracking branches and configuration settings for the remote will
|
||||||
|
/// be removed.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
void delete({
|
void delete({
|
||||||
|
@ -127,12 +130,13 @@ void delete({
|
||||||
///
|
///
|
||||||
/// Returns list of non-default refspecs that cannot be renamed.
|
/// Returns list of non-default refspecs that cannot be renamed.
|
||||||
///
|
///
|
||||||
/// All remote-tracking branches and configuration settings for the remote are updated.
|
/// All remote-tracking branches and configuration settings for the remote are
|
||||||
|
/// updated.
|
||||||
///
|
///
|
||||||
/// The new name will be checked for validity.
|
/// The new name will be checked for validity.
|
||||||
///
|
///
|
||||||
/// No loaded instances of a the remote with the old name will change their name or
|
/// No loaded instances of a the remote with the old name will change their
|
||||||
/// their list of refspecs.
|
/// name or their list of refspecs.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
List<String> rename({
|
List<String> rename({
|
||||||
|
@ -163,8 +167,8 @@ List<String> rename({
|
||||||
|
|
||||||
/// Set the remote's url in the configuration.
|
/// Set the remote's url in the configuration.
|
||||||
///
|
///
|
||||||
/// Remote objects already in memory will not be affected. This assumes the common
|
/// Remote objects already in memory will not be affected. This assumes the
|
||||||
/// case of a single-url remote and will otherwise return an error.
|
/// common case of a single-url remote and will otherwise return an error.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
void setUrl({
|
void setUrl({
|
||||||
|
@ -186,8 +190,8 @@ void setUrl({
|
||||||
|
|
||||||
/// Set the remote's url for pushing in the configuration.
|
/// Set the remote's url for pushing in the configuration.
|
||||||
///
|
///
|
||||||
/// Remote objects already in memory will not be affected. This assumes the common
|
/// Remote objects already in memory will not be affected. This assumes the
|
||||||
/// case of a single-url remote and will otherwise return an error.
|
/// common case of a single-url remote and will otherwise return an error.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
void setPushUrl({
|
void setPushUrl({
|
||||||
|
@ -266,8 +270,8 @@ List<String> pushRefspecs(Pointer<git_remote> remote) {
|
||||||
|
|
||||||
/// Add a fetch refspec to the remote's configuration.
|
/// Add a fetch refspec to the remote's configuration.
|
||||||
///
|
///
|
||||||
/// Add the given refspec to the fetch list in the configuration. No loaded remote
|
/// Add the given refspec to the fetch list in the configuration. No loaded
|
||||||
/// instances will be affected.
|
/// remote instances will be affected.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
void addFetch({
|
void addFetch({
|
||||||
|
@ -289,8 +293,8 @@ void addFetch({
|
||||||
|
|
||||||
/// Add a push refspec to the remote's configuration.
|
/// Add a push refspec to the remote's configuration.
|
||||||
///
|
///
|
||||||
/// Add the given refspec to the push list in the configuration. No loaded remote
|
/// Add the given refspec to the push list in the configuration. No loaded
|
||||||
/// instances will be affected.
|
/// remote instances will be affected.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
void addPush({
|
void addPush({
|
||||||
|
@ -312,9 +316,9 @@ void addPush({
|
||||||
|
|
||||||
/// Open a connection to a remote.
|
/// Open a connection to a remote.
|
||||||
///
|
///
|
||||||
/// The transport is selected based on the URL. The direction argument is due to a
|
/// The transport is selected based on the URL. The direction argument is due
|
||||||
/// limitation of the git protocol (over TCP or SSH) which starts up a specific binary
|
/// to a limitation of the git protocol (over TCP or SSH) which starts up a
|
||||||
/// which can only do the one or the other.
|
/// specific binary which can only do the one or the other.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
void connect({
|
void connect({
|
||||||
|
@ -355,11 +359,12 @@ void connect({
|
||||||
|
|
||||||
/// Get the remote repository's reference advertisement list.
|
/// Get the remote repository's reference advertisement list.
|
||||||
///
|
///
|
||||||
/// Get the list of references with which the server responds to a new connection.
|
/// Get the list of references with which the server responds to a new
|
||||||
|
/// connection.
|
||||||
///
|
///
|
||||||
/// The remote (or more exactly its transport) must have connected to the remote repository.
|
/// The remote (or more exactly its transport) must have connected to the
|
||||||
/// This list is available as soon as the connection to the remote is initiated and it
|
/// remote repository. This list is available as soon as the connection to the
|
||||||
/// remains available after disconnecting.
|
/// remote is initiated and it remains available after disconnecting.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
List<Map<String, Object?>> lsRemotes(Pointer<git_remote> remote) {
|
List<Map<String, Object?>> lsRemotes(Pointer<git_remote> remote) {
|
||||||
|
@ -395,8 +400,8 @@ List<Map<String, Object?>> lsRemotes(Pointer<git_remote> remote) {
|
||||||
|
|
||||||
/// Download new data and update tips.
|
/// Download new data and update tips.
|
||||||
///
|
///
|
||||||
/// Convenience function to connect to a remote, download the data, disconnect and
|
/// Convenience function to connect to a remote, download the data, disconnect
|
||||||
/// update the remote-tracking branches.
|
/// and update the remote-tracking branches.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
void fetch({
|
void fetch({
|
||||||
|
|
|
@ -16,8 +16,8 @@ class RemoteCallbacks {
|
||||||
/// Callback function that reports transfer progress.
|
/// Callback function that reports transfer progress.
|
||||||
static void Function(TransferProgress)? transferProgress;
|
static void Function(TransferProgress)? transferProgress;
|
||||||
|
|
||||||
/// A callback that will be regularly called with the current count of progress
|
/// A callback that will be regularly called with the current count of
|
||||||
/// done by the indexer during the download of new data.
|
/// progress done by the indexer during the download of new data.
|
||||||
static int transferProgressCb(
|
static int transferProgressCb(
|
||||||
Pointer<git_indexer_progress> stats,
|
Pointer<git_indexer_progress> stats,
|
||||||
Pointer<Void> payload,
|
Pointer<Void> payload,
|
||||||
|
@ -70,12 +70,14 @@ class RemoteCallbacks {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A function matching the `Remote Function(Repository repo, String name, String url)` signature
|
/// A function matching the
|
||||||
/// to override the remote creation and customization process during a clone operation.
|
/// `Remote Function(Repository repo, String name, String url)` signature to
|
||||||
|
/// override the remote creation and customization process during a clone
|
||||||
|
/// operation.
|
||||||
static Remote Function(Repository, String, String)? remoteFunction;
|
static Remote Function(Repository, String, String)? remoteFunction;
|
||||||
|
|
||||||
/// A callback used to create the git remote, prior to its being used to perform
|
/// A callback used to create the git remote, prior to its being used to
|
||||||
/// the clone operation.
|
/// perform the clone operation.
|
||||||
static int remoteCb(
|
static int remoteCb(
|
||||||
Pointer<Pointer<git_remote>> remote,
|
Pointer<Pointer<git_remote>> remote,
|
||||||
Pointer<git_repository> repo,
|
Pointer<git_repository> repo,
|
||||||
|
@ -92,8 +94,9 @@ class RemoteCallbacks {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A function matching the `Repository Function(String path, bool bare)` signature to override
|
/// A function matching the `Repository Function(String path, bool bare)`
|
||||||
/// the repository creation and customization process during a clone operation.
|
/// signature to override the repository creation and customization process
|
||||||
|
/// during a clone operation.
|
||||||
static Repository Function(String, bool)? repositoryFunction;
|
static Repository Function(String, bool)? repositoryFunction;
|
||||||
|
|
||||||
/// A callback used to create the new repository into which to clone.
|
/// A callback used to create the new repository into which to clone.
|
||||||
|
@ -111,11 +114,12 @@ class RemoteCallbacks {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// [Credentials] object used for authentication in order to connect to remote.
|
/// [Credentials] object used for authentication in order to connect to
|
||||||
|
/// remote.
|
||||||
static Credentials? credentials;
|
static Credentials? credentials;
|
||||||
|
|
||||||
/// Credential acquisition callback that will be called if the remote host requires
|
/// Credential acquisition callback that will be called if the remote host
|
||||||
/// authentication in order to connect to it.
|
/// requires authentication in order to connect to it.
|
||||||
static int credentialsCb(
|
static int credentialsCb(
|
||||||
Pointer<Pointer<git_credential>> credPointer,
|
Pointer<Pointer<git_credential>> credPointer,
|
||||||
Pointer<Int8> url,
|
Pointer<Int8> url,
|
||||||
|
|
|
@ -30,11 +30,13 @@ Pointer<git_repository> open(String path) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Look for a git repository and return its path. The lookup start from [startPath]
|
/// Look for a git repository and return its path. The lookup start from
|
||||||
/// and walk across parent directories if nothing has been found. The lookup ends when
|
/// [startPath] and walk across parent directories if nothing has been found.
|
||||||
/// the first repository is found, or when reaching a directory referenced in [ceilingDirs].
|
/// The lookup ends when the first repository is found, or when reaching a
|
||||||
|
/// directory referenced in [ceilingDirs].
|
||||||
///
|
///
|
||||||
/// The method will automatically detect if the repository is bare (if there is a repository).
|
/// The method will automatically detect if the repository is bare (if there is
|
||||||
|
/// a repository).
|
||||||
String discover({
|
String discover({
|
||||||
required String startPath,
|
required String startPath,
|
||||||
String? ceilingDirs,
|
String? ceilingDirs,
|
||||||
|
@ -201,10 +203,11 @@ String getNamespace(Pointer<git_repository> repo) {
|
||||||
|
|
||||||
/// Sets the active namespace for this repository.
|
/// Sets the active namespace for this repository.
|
||||||
///
|
///
|
||||||
/// This namespace affects all reference operations for the repo. See `man gitnamespaces`
|
/// 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
|
/// The [namespace] should not include the refs folder, e.g. to namespace all
|
||||||
/// under refs/namespaces/foo/, use foo as the namespace.
|
/// references under refs/namespaces/foo/, use foo as the namespace.
|
||||||
void setNamespace({
|
void setNamespace({
|
||||||
required Pointer<git_repository> repoPointer,
|
required Pointer<git_repository> repoPointer,
|
||||||
String? namespace,
|
String? namespace,
|
||||||
|
@ -255,7 +258,8 @@ Pointer<git_reference> head(Pointer<git_repository> repo) {
|
||||||
|
|
||||||
/// Check if a repository's HEAD is detached.
|
/// Check if a repository's HEAD is detached.
|
||||||
///
|
///
|
||||||
/// A repository's HEAD is detached when it points directly to a commit instead of a branch.
|
/// A repository's HEAD is detached when it points directly to a commit instead
|
||||||
|
/// of a branch.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
bool isHeadDetached(Pointer<git_repository> repo) {
|
bool isHeadDetached(Pointer<git_repository> repo) {
|
||||||
|
@ -270,8 +274,8 @@ bool isHeadDetached(Pointer<git_repository> repo) {
|
||||||
|
|
||||||
/// Check if the current branch is unborn.
|
/// Check if the current branch is unborn.
|
||||||
///
|
///
|
||||||
/// An unborn branch is one named from HEAD but which doesn't exist in the refs namespace,
|
/// An unborn branch is one named from HEAD but which doesn't exist in the refs
|
||||||
/// because it doesn't have any commit to point to.
|
/// namespace, because it doesn't have any commit to point to.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
bool isBranchUnborn(Pointer<git_repository> repo) {
|
bool isBranchUnborn(Pointer<git_repository> repo) {
|
||||||
|
@ -287,7 +291,8 @@ bool isBranchUnborn(Pointer<git_repository> repo) {
|
||||||
/// Set the identity to be used for writing reflogs.
|
/// Set the identity to be used for writing reflogs.
|
||||||
///
|
///
|
||||||
/// If both are set, this name and email will be used to write to the reflog.
|
/// If both are set, this name and email will be used to write to the reflog.
|
||||||
/// Pass NULL to unset. When unset, the identity will be taken from the repository's configuration.
|
/// Pass NULL to unset. When unset, the identity will be taken from the
|
||||||
|
/// repository's configuration.
|
||||||
void setIdentity({
|
void setIdentity({
|
||||||
required Pointer<git_repository> repoPointer,
|
required Pointer<git_repository> repoPointer,
|
||||||
String? name,
|
String? name,
|
||||||
|
@ -324,10 +329,12 @@ Map<String, String> identity(Pointer<git_repository> repo) {
|
||||||
|
|
||||||
/// Get the configuration file for this repository.
|
/// Get the configuration file for this repository.
|
||||||
///
|
///
|
||||||
/// If a configuration file has not been set, the default config set for the repository
|
/// If a configuration file has not been set, the default config set for the
|
||||||
/// will be returned, including global and system configurations (if they are available).
|
/// repository will be returned, including global and system configurations (if
|
||||||
|
/// they are available).
|
||||||
///
|
///
|
||||||
/// The configuration file must be freed once it's no longer being used by the user.
|
/// The configuration file must be freed once it's no longer being used by the
|
||||||
|
/// user.
|
||||||
Pointer<git_config> config(Pointer<git_repository> repo) {
|
Pointer<git_config> config(Pointer<git_repository> repo) {
|
||||||
final out = calloc<Pointer<git_config>>();
|
final out = calloc<Pointer<git_config>>();
|
||||||
libgit2.git_repository_config(out, repo);
|
libgit2.git_repository_config(out, repo);
|
||||||
|
@ -337,9 +344,11 @@ Pointer<git_config> config(Pointer<git_repository> repo) {
|
||||||
/// Get a snapshot of the repository's configuration.
|
/// Get a snapshot of the repository's configuration.
|
||||||
///
|
///
|
||||||
/// Convenience function to take a snapshot from the repository's configuration.
|
/// Convenience function to take a snapshot from the repository's configuration.
|
||||||
/// The contents of this snapshot will not change, even if the underlying config files are modified.
|
/// The contents of this snapshot will not change, even if the underlying
|
||||||
|
/// config files are modified.
|
||||||
///
|
///
|
||||||
/// The configuration file must be freed once it's no longer being used by the user.
|
/// The configuration file must be freed once it's no longer being used by the
|
||||||
|
/// user.
|
||||||
Pointer<git_config> configSnapshot(Pointer<git_repository> repo) {
|
Pointer<git_config> configSnapshot(Pointer<git_repository> repo) {
|
||||||
final out = calloc<Pointer<git_config>>();
|
final out = calloc<Pointer<git_config>>();
|
||||||
libgit2.git_repository_config_snapshot(out, repo);
|
libgit2.git_repository_config_snapshot(out, repo);
|
||||||
|
@ -376,7 +385,8 @@ bool isWorktree(Pointer<git_repository> repo) {
|
||||||
/// can present it to the user for them to amend if they wish.
|
/// can present it to the user for them to amend if they wish.
|
||||||
///
|
///
|
||||||
/// Use this function to get the contents of this file.
|
/// Use this function to get the contents of this file.
|
||||||
/// Don't forget to remove the file with [removeMessage] after you create the commit.
|
/// Don't forget to remove the file with [removeMessage] after you create the
|
||||||
|
/// commit.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
String message(Pointer<git_repository> repo) {
|
String message(Pointer<git_repository> repo) {
|
||||||
|
@ -443,10 +453,11 @@ Pointer<git_refdb> refdb(Pointer<git_repository> repo) {
|
||||||
///
|
///
|
||||||
/// If the provided reference points to a Tree or a Blob, the HEAD is unaltered.
|
/// If the provided reference points to a Tree or a Blob, the HEAD is unaltered.
|
||||||
///
|
///
|
||||||
/// If the provided reference points to a branch, the HEAD will point to that branch,
|
/// If the provided reference points to a branch, the HEAD will point to that
|
||||||
/// staying attached, or become attached if it isn't yet.
|
/// branch, staying attached, or become attached if it isn't yet.
|
||||||
///
|
///
|
||||||
/// If the branch doesn't exist yet, the HEAD will be attached to an unborn branch.
|
/// If the branch doesn't exist yet, the HEAD will be attached to an unborn
|
||||||
|
/// branch.
|
||||||
///
|
///
|
||||||
/// Otherwise, the HEAD will be detached and will directly point to the Commit.
|
/// Otherwise, the HEAD will be detached and will directly point to the Commit.
|
||||||
///
|
///
|
||||||
|
@ -467,11 +478,14 @@ void setHead({
|
||||||
|
|
||||||
/// Make the repository HEAD directly point to the commit.
|
/// Make the repository HEAD directly point to the commit.
|
||||||
///
|
///
|
||||||
/// If the provided committish cannot be found in the repository, the HEAD is unaltered.
|
/// If the provided committish cannot be found in the repository, the HEAD is
|
||||||
|
/// unaltered.
|
||||||
///
|
///
|
||||||
/// If the provided commitish cannot be peeled into a commit, the HEAD is unaltered.
|
/// If the provided commitish cannot be peeled into a commit, the HEAD is
|
||||||
|
/// unaltered.
|
||||||
///
|
///
|
||||||
/// Otherwise, the HEAD will eventually be detached and will directly point to the peeled commit.
|
/// Otherwise, the HEAD will eventually be detached and will directly point to
|
||||||
|
/// the peeled commit.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
void setHeadDetached({
|
void setHeadDetached({
|
||||||
|
@ -493,8 +507,8 @@ void setHeadDetached({
|
||||||
/// The working directory doesn't need to be the same one that contains the
|
/// The working directory doesn't need to be the same one that contains the
|
||||||
/// `.git` folder for this repository.
|
/// `.git` folder for this repository.
|
||||||
///
|
///
|
||||||
/// If this repository is bare, setting its working directory will turn it into a
|
/// If this repository is bare, setting its working directory will turn it into
|
||||||
/// normal repository, capable of performing all the common workdir operations
|
/// a normal repository, capable of performing all the common workdir operations
|
||||||
/// (checkout, status, index manipulation, etc).
|
/// (checkout, status, index manipulation, etc).
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
|
|
|
@ -3,16 +3,17 @@ import 'dart:ffi';
|
||||||
import '../util.dart';
|
import '../util.dart';
|
||||||
import 'libgit2_bindings.dart';
|
import 'libgit2_bindings.dart';
|
||||||
|
|
||||||
/// Sets the current head to the specified commit oid and optionally resets the index
|
/// Sets the current head to the specified commit oid and optionally resets the
|
||||||
/// and working tree to match.
|
/// index and working tree to match.
|
||||||
///
|
///
|
||||||
/// SOFT reset means the Head will be moved to the commit.
|
/// SOFT reset means the Head will be moved to the commit.
|
||||||
///
|
///
|
||||||
/// MIXED reset will trigger a SOFT reset, plus the index will be replaced with the
|
/// MIXED reset will trigger a SOFT reset, plus the index will be replaced with
|
||||||
/// content of the commit tree.
|
/// the content of the commit tree.
|
||||||
///
|
///
|
||||||
/// HARD reset will trigger a MIXED reset and the working directory will be replaced
|
/// HARD reset will trigger a MIXED reset and the working directory will be
|
||||||
/// with the content of the index. (Untracked and ignored files will be left alone, however.)
|
/// replaced with the content of the index. (Untracked and ignored files will
|
||||||
|
/// be left alone, however.)
|
||||||
void reset({
|
void reset({
|
||||||
required Pointer<git_repository> repoPointer,
|
required Pointer<git_repository> repoPointer,
|
||||||
required Pointer<git_object> targetPointer,
|
required Pointer<git_object> targetPointer,
|
||||||
|
|
|
@ -62,9 +62,9 @@ Pointer<git_object> revParseSingle({
|
||||||
/// See `man gitrevisions`, or https://git-scm.com/docs/git-rev-parse.html#_specifying_revisions
|
/// See `man gitrevisions`, or https://git-scm.com/docs/git-rev-parse.html#_specifying_revisions
|
||||||
/// for information on the syntax accepted.
|
/// for information on the syntax accepted.
|
||||||
///
|
///
|
||||||
/// In some cases (@{<-n>} or <branchname>@{upstream}), the expression may point to an
|
/// In some cases (@{<-n>} or <branchname>@{upstream}), the expression may
|
||||||
/// intermediate reference. When such expressions are being passed in, reference_out will be
|
/// point to an intermediate reference. When such expressions are being passed
|
||||||
/// valued as well.
|
/// in, reference_out will be valued as well.
|
||||||
///
|
///
|
||||||
/// The returned object and reference should be released when no longer needed.
|
/// The returned object and reference should be released when no longer needed.
|
||||||
///
|
///
|
||||||
|
|
|
@ -12,11 +12,12 @@ import 'libgit2_bindings.dart';
|
||||||
/// This revision walker uses a custom memory pool and an internal commit cache,
|
/// This revision walker uses a custom memory pool and an internal commit cache,
|
||||||
/// so it is relatively expensive to allocate.
|
/// so it is relatively expensive to allocate.
|
||||||
///
|
///
|
||||||
/// For maximum performance, this revision walker should be reused for different walks.
|
/// For maximum performance, this revision walker should be reused for
|
||||||
|
/// different walks.
|
||||||
///
|
///
|
||||||
/// This revision walker is not thread safe: it may only be used to walk a repository
|
/// This revision walker is not thread safe: it may only be used to walk a
|
||||||
/// on a single thread; however, it is possible to have several revision walkers in several
|
/// repository on a single thread; however, it is possible to have several
|
||||||
/// different threads walking the same repository.
|
/// revision walkers in several different threads walking the same repository.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
Pointer<git_revwalk> create(Pointer<git_repository> repo) {
|
Pointer<git_revwalk> create(Pointer<git_repository> repo) {
|
||||||
|
@ -43,10 +44,11 @@ void sorting({
|
||||||
|
|
||||||
/// Add a new root for the traversal.
|
/// Add a new root for the traversal.
|
||||||
///
|
///
|
||||||
/// The pushed commit will be marked as one of the roots from which to start the walk.
|
/// The pushed commit will be marked as one of the roots from which to start
|
||||||
/// This commit may not be walked if it or a child is hidden.
|
/// the walk. This commit may not be walked if it or a child is hidden.
|
||||||
///
|
///
|
||||||
/// At least one commit must be pushed onto the walker before a walk can be started.
|
/// At least one commit must be pushed onto the walker before a walk can be
|
||||||
|
/// started.
|
||||||
///
|
///
|
||||||
/// The given id must belong to a committish on the walked repository.
|
/// The given id must belong to a committish on the walked repository.
|
||||||
///
|
///
|
||||||
|
@ -64,12 +66,13 @@ void push({
|
||||||
|
|
||||||
/// Get the list of commits from the revision walk.
|
/// Get the list of commits from the revision walk.
|
||||||
///
|
///
|
||||||
/// The initial call to this method is not blocking when iterating through a repo
|
/// The initial call to this method is not blocking when iterating through a
|
||||||
/// with a time-sorting mode.
|
/// repo with a time-sorting mode.
|
||||||
///
|
///
|
||||||
/// Iterating with Topological or inverted modes makes the initial call blocking to
|
/// Iterating with Topological or inverted modes makes the initial call
|
||||||
/// preprocess the commit list, but this block should be mostly unnoticeable on most
|
/// blocking to preprocess the commit list, but this block should be mostly
|
||||||
/// repositories (topological preprocessing times at 0.3s on the git.git repo).
|
/// unnoticeable on most repositories (topological preprocessing times at 0.3s
|
||||||
|
/// on the git.git repo).
|
||||||
///
|
///
|
||||||
/// The revision walker is reset when the walk is over.
|
/// The revision walker is reset when the walk is over.
|
||||||
List<Pointer<git_commit>> walk({
|
List<Pointer<git_commit>> walk({
|
||||||
|
@ -101,7 +104,8 @@ List<Pointer<git_commit>> walk({
|
||||||
///
|
///
|
||||||
/// The given id must belong to a committish on the walked repository.
|
/// The given id must belong to a committish on the walked repository.
|
||||||
///
|
///
|
||||||
/// The resolved commit and all its parents will be hidden from the output on the revision walk.
|
/// The resolved commit and all its parents will be hidden from the output on
|
||||||
|
/// the revision walk.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
void hide({
|
void hide({
|
||||||
|
@ -117,8 +121,9 @@ void hide({
|
||||||
|
|
||||||
/// Reset the revision walker for reuse.
|
/// Reset the revision walker for reuse.
|
||||||
///
|
///
|
||||||
/// This will clear all the pushed and hidden commits, and leave the walker in a blank state
|
/// This will clear all the pushed and hidden commits, and leave the walker in
|
||||||
/// (just like at creation) ready to receive new commit pushes and start a new walk.
|
/// a blank state (just like at creation) ready to receive new commit pushes
|
||||||
|
/// and start a new walk.
|
||||||
///
|
///
|
||||||
/// The revision walk is automatically reset when a walk is over.
|
/// The revision walk is automatically reset when a walk is over.
|
||||||
void reset(Pointer<git_revwalk> walker) => libgit2.git_revwalk_reset(walker);
|
void reset(Pointer<git_revwalk> walker) => libgit2.git_revwalk_reset(walker);
|
||||||
|
|
|
@ -56,8 +56,9 @@ Pointer<git_signature> now({required String name, required String email}) {
|
||||||
|
|
||||||
/// Create a new action signature with default user and now timestamp.
|
/// Create a new action signature with default user and now timestamp.
|
||||||
///
|
///
|
||||||
/// This looks up the user.name and user.email from the configuration and uses the
|
/// This looks up the user.name and user.email from the configuration and uses
|
||||||
/// current time as the timestamp, and creates a new signature based on that information.
|
/// the current time as the timestamp, and creates a new signature based on
|
||||||
|
/// that information.
|
||||||
Pointer<git_signature> defaultSignature(Pointer<git_repository> repo) {
|
Pointer<git_signature> defaultSignature(Pointer<git_repository> repo) {
|
||||||
final out = calloc<Pointer<git_signature>>();
|
final out = calloc<Pointer<git_signature>>();
|
||||||
libgit2.git_signature_default(out, repo);
|
libgit2.git_signature_default(out, repo);
|
||||||
|
|
|
@ -92,7 +92,8 @@ void drop({required Pointer<git_repository> repoPointer, required int index}) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Apply a single stashed state from the stash list and remove it from the list if successful.
|
/// Apply a single stashed state from the stash list and remove it from the
|
||||||
|
/// list if successful.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
void pop({
|
void pop({
|
||||||
|
|
|
@ -42,17 +42,20 @@ Pointer<git_status_entry> getByIndex({
|
||||||
|
|
||||||
/// Get file status for a single file.
|
/// Get file status for a single file.
|
||||||
///
|
///
|
||||||
/// This tries to get status for the filename that you give. If no files match that name
|
/// This tries to get status for the filename that you give. If no files match
|
||||||
/// (in either the HEAD, index, or working directory), this returns GIT_ENOTFOUND.
|
/// that name (in either the HEAD, index, or working directory), this returns
|
||||||
|
/// GIT_ENOTFOUND.
|
||||||
///
|
///
|
||||||
/// If the name matches multiple files (for example, if the path names a directory or if
|
/// If the name matches multiple files (for example, if the path names a
|
||||||
/// running on a case- insensitive filesystem and yet the HEAD has two entries that both
|
/// directory or if running on a case- insensitive filesystem and yet the HEAD
|
||||||
/// match the path), then this returns GIT_EAMBIGUOUS because it cannot give correct results.
|
/// has two entries that both match the path), then this returns GIT_EAMBIGUOUS
|
||||||
|
/// because it cannot give correct results.
|
||||||
///
|
///
|
||||||
/// This does not do any sort of rename detection. Renames require a set of targets and because
|
/// This does not do any sort of rename detection. Renames require a set of
|
||||||
/// of the path filtering, there is not enough information to check renames correctly. To check
|
/// targets and because of the path filtering, there is not enough information
|
||||||
/// file status with rename detection, there is no choice but to do a full listNew
|
/// to check renames correctly. To check file status with rename detection,
|
||||||
/// and scan through looking for the path that you are interested in.
|
/// there is no choice but to do a full listNew and scan through looking for
|
||||||
|
/// the path that you are interested in.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
int file({required Pointer<git_repository> repoPointer, required String path}) {
|
int file({required Pointer<git_repository> repoPointer, required String path}) {
|
||||||
|
|
|
@ -69,8 +69,8 @@ Pointer<git_submodule> lookup({
|
||||||
/// Just like `git submodule init`, this copies information about the
|
/// Just like `git submodule init`, this copies information about the
|
||||||
/// submodule into `.git/config`.
|
/// submodule into `.git/config`.
|
||||||
///
|
///
|
||||||
/// By default, existing entries will not be overwritten, but setting [overwrite]
|
/// By default, existing entries will not be overwritten, but setting
|
||||||
/// to true forces them to be updated.
|
/// [overwrite] to true forces them to be updated.
|
||||||
void init({
|
void init({
|
||||||
required Pointer<git_submodule> submodulePointer,
|
required Pointer<git_submodule> submodulePointer,
|
||||||
bool overwrite = false,
|
bool overwrite = false,
|
||||||
|
@ -80,14 +80,14 @@ void init({
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Update a submodule. This will clone a missing submodule and checkout the
|
/// Update a submodule. This will clone a missing submodule and checkout the
|
||||||
/// subrepository to the commit specified in the index of the containing repository.
|
/// subrepository to the commit specified in the index of the containing
|
||||||
/// If the submodule repository doesn't contain the target commit (e.g. because
|
/// repository. If the submodule repository doesn't contain the target commit
|
||||||
/// fetchRecurseSubmodules isn't set), then the submodule is fetched using the fetch
|
/// (e.g. because fetchRecurseSubmodules isn't set), then the submodule is
|
||||||
/// options supplied in [callbacks].
|
/// fetched using the fetch options supplied in [callbacks].
|
||||||
///
|
///
|
||||||
/// If the submodule is not initialized, setting [init] to true will initialize the
|
/// If the submodule is not initialized, setting [init] to true will initialize
|
||||||
/// submodule before updating. Otherwise, this will return an error if attempting
|
/// the submodule before updating. Otherwise, this will return an error if
|
||||||
/// to update an uninitialzed repository.
|
/// attempting to update an uninitialzed repository.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
void update({
|
void update({
|
||||||
|
@ -119,10 +119,10 @@ void update({
|
||||||
|
|
||||||
/// Open the repository for a submodule.
|
/// Open the repository for a submodule.
|
||||||
///
|
///
|
||||||
/// This is a newly opened repository object. The caller is responsible for calling
|
/// This is a newly opened repository object. The caller is responsible for
|
||||||
/// `free()` on it when done. Multiple calls to this function will return distinct
|
/// calling free on it when done. Multiple calls to this function will return
|
||||||
/// git repository objects. This will only work if the submodule is checked out into
|
/// distinct git repository objects. This will only work if the submodule is
|
||||||
/// the working directory.
|
/// checked out into the working directory.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
Pointer<git_repository> open(Pointer<git_submodule> submodule) {
|
Pointer<git_repository> open(Pointer<git_submodule> submodule) {
|
||||||
|
@ -139,10 +139,11 @@ Pointer<git_repository> open(Pointer<git_submodule> submodule) {
|
||||||
|
|
||||||
/// Set up a new git submodule for checkout.
|
/// Set up a new git submodule for checkout.
|
||||||
///
|
///
|
||||||
/// This does `git submodule add` up to the fetch and checkout of the submodule contents.
|
/// This does `git submodule add` up to the fetch and checkout of the submodule
|
||||||
/// It preps a new submodule, creates an entry in `.gitmodules` and creates an empty
|
/// contents. It preps a new submodule, creates an entry in `.gitmodules` and
|
||||||
/// initialized repository either at the given path in the working directory or in
|
/// creates an empty initialized repository either at the given path in the
|
||||||
/// `.git/modules` with a gitlink from the working directory to the new repo.
|
/// working directory or in `.git/modules` with a gitlink from the working
|
||||||
|
/// directory to the new repo.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
Pointer<git_submodule> addSetup({
|
Pointer<git_submodule> addSetup({
|
||||||
|
@ -208,16 +209,16 @@ void clone({
|
||||||
///
|
///
|
||||||
/// This should be called on a submodule once you have called add setup and done
|
/// This should be called on a submodule once you have called add setup and done
|
||||||
/// the clone of the submodule. This adds the `.gitmodules` file and the newly
|
/// the clone of the submodule. This adds the `.gitmodules` file and the newly
|
||||||
/// cloned submodule to the index to be ready to be committed (but doesn't actually
|
/// cloned submodule to the index to be ready to be committed (but doesn't
|
||||||
/// do the commit).
|
/// actually do the commit).
|
||||||
void addFinalize(Pointer<git_submodule> submodule) {
|
void addFinalize(Pointer<git_submodule> submodule) {
|
||||||
libgit2.git_submodule_add_finalize(submodule);
|
libgit2.git_submodule_add_finalize(submodule);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the status for a submodule.
|
/// Get the status for a submodule.
|
||||||
///
|
///
|
||||||
/// This looks at a submodule and tries to determine the status. How deeply it examines
|
/// This looks at a submodule and tries to determine the status. How deeply it
|
||||||
/// the working directory to do this will depend on the [ignore] value.
|
/// examines the working directory to do this will depend on the [ignore] value.
|
||||||
int status({
|
int status({
|
||||||
required Pointer<git_repository> repoPointer,
|
required Pointer<git_repository> repoPointer,
|
||||||
required String name,
|
required String name,
|
||||||
|
@ -236,17 +237,17 @@ int status({
|
||||||
|
|
||||||
/// Copy submodule remote info into submodule repo.
|
/// Copy submodule remote info into submodule repo.
|
||||||
///
|
///
|
||||||
/// This copies the information about the submodules URL into the checked out submodule
|
/// This copies the information about the submodules URL into the checked out
|
||||||
/// config, acting like `git submodule sync`. This is useful if you have altered the URL
|
/// submodule config, acting like `git submodule sync`. This is useful if you
|
||||||
/// for the submodule (or it has been altered by a fetch of upstream changes) and you
|
/// have altered the URL for the submodule (or it has been altered by a fetch
|
||||||
/// need to update your local repo.
|
/// of upstream changes) and you need to update your local repo.
|
||||||
void sync(Pointer<git_submodule> submodule) =>
|
void sync(Pointer<git_submodule> submodule) =>
|
||||||
libgit2.git_submodule_sync(submodule);
|
libgit2.git_submodule_sync(submodule);
|
||||||
|
|
||||||
/// Reread submodule info from config, index, and HEAD.
|
/// Reread submodule info from config, index, and HEAD.
|
||||||
///
|
///
|
||||||
/// Call this to reread cached submodule information for this submodule if you have
|
/// Call this to reread cached submodule information for this submodule if you
|
||||||
/// reason to believe that it has changed.
|
/// have reason to believe that it has changed.
|
||||||
///
|
///
|
||||||
/// Set [force] to true to reload even if the data doesn't seem out of date.
|
/// Set [force] to true to reload even if the data doesn't seem out of date.
|
||||||
void reload({
|
void reload({
|
||||||
|
@ -335,10 +336,10 @@ Pointer<git_oid>? indexId(Pointer<git_submodule> submodule) {
|
||||||
|
|
||||||
/// Get the OID for the submodule in the current working directory.
|
/// Get the OID for the submodule in the current working directory.
|
||||||
///
|
///
|
||||||
/// This returns the OID that corresponds to looking up `HEAD` in the checked out
|
/// This returns the OID that corresponds to looking up `HEAD` in the checked
|
||||||
/// submodule. If there are pending changes in the index or anything else, this
|
/// out submodule. If there are pending changes in the index or anything else,
|
||||||
/// won't notice that. You should call [status] for a more complete picture about
|
/// this won't notice that. You should call [status] for a more complete
|
||||||
/// the state of the working directory.
|
/// picture about the state of the working directory.
|
||||||
///
|
///
|
||||||
/// Returns null if submodule is not checked out.
|
/// Returns null if submodule is not checked out.
|
||||||
Pointer<git_oid>? workdirId(Pointer<git_submodule> submodule) {
|
Pointer<git_oid>? workdirId(Pointer<git_submodule> submodule) {
|
||||||
|
@ -388,8 +389,8 @@ void setUpdateRule({
|
||||||
///
|
///
|
||||||
/// This returns a pointer to the repository that contains the submodule.
|
/// This returns a pointer to the repository that contains the submodule.
|
||||||
/// This is a just a reference to the repository that was passed to the original
|
/// This is a just a reference to the repository that was passed to the original
|
||||||
/// [lookup] call, so if that repository has been freed, then this may be a dangling
|
/// [lookup] call, so if that repository has been freed, then this may be a
|
||||||
/// reference.
|
/// dangling reference.
|
||||||
Pointer<git_repository> owner(Pointer<git_submodule> submodule) {
|
Pointer<git_repository> owner(Pointer<git_submodule> submodule) {
|
||||||
return libgit2.git_submodule_owner(submodule);
|
return libgit2.git_submodule_owner(submodule);
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,8 @@ Pointer<git_tag> lookup({
|
||||||
|
|
||||||
/// Get the tagged object of a tag.
|
/// Get the tagged object of a tag.
|
||||||
///
|
///
|
||||||
/// This method performs a repository lookup for the given object and returns it.
|
/// This method performs a repository lookup for the given object and returns
|
||||||
|
/// it.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
Pointer<git_object> target(Pointer<git_tag> tag) {
|
Pointer<git_object> target(Pointer<git_tag> tag) {
|
||||||
|
@ -82,8 +83,9 @@ Pointer<git_signature> tagger(Pointer<git_tag> tag) =>
|
||||||
|
|
||||||
/// Create a new tag in the repository from an object.
|
/// Create a new tag in the repository from an object.
|
||||||
///
|
///
|
||||||
/// A new reference will also be created pointing to this tag object. If force is true
|
/// A new reference will also be created pointing to this tag object. If force
|
||||||
/// and a reference already exists with the given name, it'll be replaced.
|
/// is true and a reference already exists with the given name, it'll be
|
||||||
|
/// replaced.
|
||||||
///
|
///
|
||||||
/// The message will not be cleaned up.
|
/// The message will not be cleaned up.
|
||||||
///
|
///
|
||||||
|
|
|
@ -33,8 +33,8 @@ Pointer<git_repository> owner(Pointer<git_tree> tree) =>
|
||||||
|
|
||||||
/// Lookup a tree entry by its position in the tree.
|
/// Lookup a tree entry by its position in the tree.
|
||||||
///
|
///
|
||||||
/// This returns a tree entry that is owned by the tree. You don't have to free it,
|
/// This returns a tree entry that is owned by the tree. You don't have to free
|
||||||
/// but you must not use it after the tree is released.
|
/// it, but you must not use it after the tree is released.
|
||||||
///
|
///
|
||||||
/// Throws [RangeError] when provided index is outside of valid range.
|
/// Throws [RangeError] when provided index is outside of valid range.
|
||||||
Pointer<git_tree_entry> getByIndex({
|
Pointer<git_tree_entry> getByIndex({
|
||||||
|
@ -52,8 +52,8 @@ Pointer<git_tree_entry> getByIndex({
|
||||||
|
|
||||||
/// Lookup a tree entry by its filename.
|
/// Lookup a tree entry by its filename.
|
||||||
///
|
///
|
||||||
/// This returns a tree entry that is owned by the tree. You don't have to free it,
|
/// This returns a tree entry that is owned by the tree. You don't have to free
|
||||||
/// but you must not use it after the tree is released.
|
/// it, but you must not use it after the tree is released.
|
||||||
///
|
///
|
||||||
/// Throws [ArgumentError] if nothing found for provided filename.
|
/// Throws [ArgumentError] if nothing found for provided filename.
|
||||||
Pointer<git_tree_entry> getByName({
|
Pointer<git_tree_entry> getByName({
|
||||||
|
@ -72,10 +72,11 @@ Pointer<git_tree_entry> getByName({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Retrieve a tree entry contained in a tree or in any of its subtrees, given its relative path.
|
/// Retrieve a tree entry contained in a tree or in any of its subtrees, given
|
||||||
|
/// its relative path.
|
||||||
///
|
///
|
||||||
/// Unlike the other lookup functions, the returned tree entry is owned by the user and must be
|
/// Unlike the other lookup functions, the returned tree entry is owned by the
|
||||||
/// freed explicitly with [entryFree].
|
/// user and must be freed explicitly with [entryFree].
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
Pointer<git_tree_entry> getByPath({
|
Pointer<git_tree_entry> getByPath({
|
||||||
|
|
|
@ -8,11 +8,11 @@ import 'libgit2_bindings.dart';
|
||||||
|
|
||||||
/// Create a new tree builder.
|
/// Create a new tree builder.
|
||||||
///
|
///
|
||||||
/// The tree builder can be used to create or modify trees in memory and write them
|
/// The tree builder can be used to create or modify trees in memory and write
|
||||||
/// as tree objects to the database.
|
/// them as tree objects to the database.
|
||||||
///
|
///
|
||||||
/// If the source parameter is not null, the tree builder will be initialized with
|
/// If the source parameter is not null, the tree builder will be initialized
|
||||||
/// the entries of the given tree.
|
/// with the entries of the given tree.
|
||||||
///
|
///
|
||||||
/// If the source parameter is null, the tree builder will start with no entries
|
/// If the source parameter is null, the tree builder will start with no entries
|
||||||
/// and will have to be filled manually.
|
/// and will have to be filled manually.
|
||||||
|
@ -72,8 +72,8 @@ Pointer<git_tree_entry> getByFilename({
|
||||||
///
|
///
|
||||||
/// Insert a new entry for filename in the builder with the given attributes.
|
/// Insert a new entry for filename in the builder with the given attributes.
|
||||||
///
|
///
|
||||||
/// If an entry named filename already exists, its attributes will be updated with
|
/// If an entry named filename already exists, its attributes will be updated
|
||||||
/// the given ones.
|
/// with the given ones.
|
||||||
///
|
///
|
||||||
/// By default the entry that you are inserting will be checked for validity;
|
/// By default the entry that you are inserting will be checked for validity;
|
||||||
/// that it exists in the object database and is of the correct type.
|
/// that it exists in the object database and is of the correct type.
|
||||||
|
|
|
@ -10,7 +10,8 @@ import 'libgit2_bindings.dart';
|
||||||
/// Add a new working tree.
|
/// Add a new working tree.
|
||||||
///
|
///
|
||||||
/// Add a new working tree for the repository, that is create the required
|
/// Add a new working tree for the repository, that is create the required
|
||||||
/// data structures inside the repository and check out the current HEAD at path.
|
/// data structures inside the repository and check out the current HEAD at
|
||||||
|
/// path.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
Pointer<git_worktree> create({
|
Pointer<git_worktree> create({
|
||||||
|
@ -136,8 +137,8 @@ void unlock(Pointer<git_worktree> wt) => libgit2.git_worktree_unlock(wt);
|
||||||
|
|
||||||
/// Check if worktree is valid.
|
/// Check if worktree is valid.
|
||||||
///
|
///
|
||||||
/// A valid worktree requires both the git data structures inside the linked parent
|
/// A valid worktree requires both the git data structures inside the linked
|
||||||
/// repository and the linked working copy to be present.
|
/// parent repository and the linked working copy to be present.
|
||||||
bool isValid(Pointer<git_worktree> wt) {
|
bool isValid(Pointer<git_worktree> wt) {
|
||||||
return libgit2.git_worktree_validate(wt) == 0 ? true : false;
|
return libgit2.git_worktree_validate(wt) == 0 ? true : false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,18 +14,20 @@ class Blame with IterableMixin<BlameHunk> {
|
||||||
///
|
///
|
||||||
/// [path] is the path to file to consider.
|
/// [path] is the path to file to consider.
|
||||||
///
|
///
|
||||||
/// [flags] is a combination of [GitBlameFlag]s. Defaults to [GitBlameFlag.normal].
|
/// [flags] is a combination of [GitBlameFlag]s. Defaults to
|
||||||
|
/// [GitBlameFlag.normal].
|
||||||
///
|
///
|
||||||
/// [minMatchCharacters] is the lower bound on the number of alphanumeric
|
/// [minMatchCharacters] is the lower bound on the number of alphanumeric
|
||||||
/// characters that must be detected as moving/copying within a file for
|
/// characters that must be detected as moving/copying within a file for
|
||||||
/// it to associate those lines with the parent commit. The default value is 20.
|
/// it to associate those lines with the parent commit. The default value is
|
||||||
/// This value only takes effect if any of the [GitBlameFlag.trackCopies*]
|
/// 20. This value only takes effect if any of the [GitBlameFlag.trackCopies*]
|
||||||
/// flags are specified.
|
/// flags are specified.
|
||||||
///
|
///
|
||||||
/// [newestCommit] is the id of the newest commit to consider. The default is HEAD.
|
/// [newestCommit] is the id of the newest commit to consider. The default is
|
||||||
|
/// HEAD.
|
||||||
///
|
///
|
||||||
/// [oldestCommit] is the id of the oldest commit to consider. The default is the
|
/// [oldestCommit] is the id of the oldest commit to consider. The default is
|
||||||
/// first commit encountered with no parent.
|
/// the first commit encountered with no parent.
|
||||||
///
|
///
|
||||||
/// [minLine] is the first line in the file to blame. The default is 1
|
/// [minLine] is the first line in the file to blame. The default is 1
|
||||||
/// (line numbers start with 1).
|
/// (line numbers start with 1).
|
||||||
|
@ -71,7 +73,8 @@ class Blame with IterableMixin<BlameHunk> {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the hunk that relates to the given line number (1-based) in the newest commit.
|
/// Returns the hunk that relates to the given line number (1-based) in the
|
||||||
|
/// newest commit.
|
||||||
///
|
///
|
||||||
/// Throws [RangeError] if [lineNumber] is out of range.
|
/// Throws [RangeError] if [lineNumber] is out of range.
|
||||||
BlameHunk forLine(int lineNumber) {
|
BlameHunk forLine(int lineNumber) {
|
||||||
|
@ -105,7 +108,8 @@ class BlameHunk {
|
||||||
return _blameHunkPointer.ref.boundary == 1 ? true : false;
|
return _blameHunkPointer.ref.boundary == 1 ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 1-based line number where this hunk begins, in the final version of the file.
|
/// 1-based line number where this hunk begins, in the final version of the
|
||||||
|
/// file.
|
||||||
int get finalStartLineNumber => _blameHunkPointer.ref.final_start_line_number;
|
int get finalStartLineNumber => _blameHunkPointer.ref.final_start_line_number;
|
||||||
|
|
||||||
/// Author of [finalCommitOid]. If [GitBlameFlag.useMailmap] has been
|
/// Author of [finalCommitOid]. If [GitBlameFlag.useMailmap] has been
|
||||||
|
@ -116,8 +120,8 @@ class BlameHunk {
|
||||||
/// [Oid] of the commit where this line was last changed.
|
/// [Oid] of the commit where this line was last changed.
|
||||||
Oid get finalCommitOid => Oid.fromRaw(_blameHunkPointer.ref.final_commit_id);
|
Oid get finalCommitOid => Oid.fromRaw(_blameHunkPointer.ref.final_commit_id);
|
||||||
|
|
||||||
/// 1-based line number where this hunk begins, in the file named by [originPath]
|
/// 1-based line number where this hunk begins, in the file named by
|
||||||
/// in the commit specified by [originCommitId].
|
/// [originPath] in the commit specified by [originCommitId].
|
||||||
int get originStartLineNumber => _blameHunkPointer.ref.orig_start_line_number;
|
int get originStartLineNumber => _blameHunkPointer.ref.orig_start_line_number;
|
||||||
|
|
||||||
/// Author of [originCommitOid]. If [GitBlameFlag.useMailmap] has been
|
/// Author of [originCommitOid]. If [GitBlameFlag.useMailmap] has been
|
||||||
|
@ -125,9 +129,9 @@ class BlameHunk {
|
||||||
Signature get originCommitter =>
|
Signature get originCommitter =>
|
||||||
Signature(_blameHunkPointer.ref.orig_signature);
|
Signature(_blameHunkPointer.ref.orig_signature);
|
||||||
|
|
||||||
/// [Oid] of the commit where this hunk was found. This will usually be the same
|
/// [Oid] of the commit where this hunk was found. This will usually be the
|
||||||
/// as [finalCommitOid], except when [GitBlameFlag.trackCopiesAnyCommitCopies]
|
/// same as [finalCommitOid], except when
|
||||||
/// been specified.
|
/// [GitBlameFlag.trackCopiesAnyCommitCopies] been specified.
|
||||||
Oid get originCommitOid => Oid.fromRaw(_blameHunkPointer.ref.orig_commit_id);
|
Oid get originCommitOid => Oid.fromRaw(_blameHunkPointer.ref.orig_commit_id);
|
||||||
|
|
||||||
/// Path to the file where this hunk originated, as of the commit specified by
|
/// Path to the file where this hunk originated, as of the commit specified by
|
||||||
|
@ -138,8 +142,9 @@ class BlameHunk {
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'BlameHunk{linesCount: $linesCount, isBoundary: $isBoundary, '
|
return 'BlameHunk{linesCount: $linesCount, isBoundary: $isBoundary, '
|
||||||
'finalStartLineNumber: $finalStartLineNumber, finalCommitter: $finalCommitter, '
|
'finalStartLineNumber: $finalStartLineNumber, '
|
||||||
'finalCommitOid: $finalCommitOid, originStartLineNumber: $originStartLineNumber, '
|
'finalCommitter: $finalCommitter, finalCommitOid: $finalCommitOid, '
|
||||||
|
'originStartLineNumber: $originStartLineNumber, '
|
||||||
'originCommitter: $originCommitter, originCommitOid: $originCommitOid, '
|
'originCommitter: $originCommitter, originCommitOid: $originCommitOid, '
|
||||||
'originPath: $originPath}';
|
'originPath: $originPath}';
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,8 +39,9 @@ class Blob {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new blob from the file in working directory of a repository and writes
|
/// Creates a new blob from the file in working directory of a repository and
|
||||||
/// it to the ODB. Provided [relativePath] should be relative to the working directory.
|
/// writes it to the ODB. Provided [relativePath] should be relative to the
|
||||||
|
/// working directory.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
static Oid createFromWorkdir({
|
static Oid createFromWorkdir({
|
||||||
|
@ -120,7 +121,8 @@ class Blob {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Directly generates a [Patch] from the difference between the blob and a buffer.
|
/// Directly generates a [Patch] from the difference between the blob and a
|
||||||
|
/// buffer.
|
||||||
///
|
///
|
||||||
/// [buffer] is the raw data for new side of diff, or null for empty.
|
/// [buffer] is the raw data for new side of diff, or null for empty.
|
||||||
///
|
///
|
||||||
|
|
|
@ -69,11 +69,11 @@ class Branch {
|
||||||
/// Pointer to memory address for allocated branch object.
|
/// Pointer to memory address for allocated branch object.
|
||||||
Pointer<git_reference> get pointer => _branchPointer;
|
Pointer<git_reference> get pointer => _branchPointer;
|
||||||
|
|
||||||
/// Returns a list of branches that can be found in a [repo]sitory for provided [type].
|
/// Returns a list of branches that can be found in a [repo]sitory for
|
||||||
/// Default is all branches (local and remote).
|
/// provided [type]. Default is all branches (local and remote).
|
||||||
///
|
///
|
||||||
/// **IMPORTANT**: Branches must be freed manually when no longer needed to prevent
|
/// **IMPORTANT**: Branches must be freed manually when no longer needed to
|
||||||
/// memory leak.
|
/// prevent memory leak.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
static List<Branch> list({
|
static List<Branch> list({
|
||||||
|
@ -133,8 +133,9 @@ class Branch {
|
||||||
|
|
||||||
/// Whether any HEAD points to the current branch.
|
/// Whether any HEAD points to the current branch.
|
||||||
///
|
///
|
||||||
/// This will iterate over all known linked repositories (usually in the form of worktrees)
|
/// This will iterate over all known linked repositories (usually in the form
|
||||||
/// and report whether any HEAD is pointing at the current branch.
|
/// of worktrees) and report whether any HEAD is pointing at the current
|
||||||
|
/// branch.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
bool get isCheckedOut => bindings.isCheckedOut(_branchPointer);
|
bool get isCheckedOut => bindings.isCheckedOut(_branchPointer);
|
||||||
|
@ -152,6 +153,7 @@ class Branch {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'Branch{name: $name, target: $target, isHead: $isHead, isCheckedOut: $isCheckedOut}';
|
return 'Branch{name: $name, target: $target, isHead: $isHead, '
|
||||||
|
'isCheckedOut: $isCheckedOut}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,24 @@
|
||||||
import 'package:libgit2dart/libgit2dart.dart';
|
import 'package:libgit2dart/libgit2dart.dart';
|
||||||
|
|
||||||
class Callbacks {
|
class Callbacks {
|
||||||
/// Callback functions used in various methods of [Remote] and with [Repository.clone].
|
/// Callback functions used in various methods of [Remote] and with
|
||||||
|
/// [Repository.clone].
|
||||||
///
|
///
|
||||||
/// [credentials] is the [Credentials] object used for authentication.
|
/// [credentials] is the [Credentials] object used for authentication.
|
||||||
///
|
///
|
||||||
/// [transferProgress] is the callback function that reports transfer progress.
|
/// [transferProgress] is the callback function that reports transfer
|
||||||
|
/// progress.
|
||||||
///
|
///
|
||||||
/// [sidebandProgress] is the callback function that reports textual progress from the remote.
|
/// [sidebandProgress] is the callback function that reports textual progress
|
||||||
|
/// from the remote.
|
||||||
///
|
///
|
||||||
/// [updateTips] is the callback function matching the
|
/// [updateTips] is the callback function matching the
|
||||||
/// `void Function(String refname, Oid old, Oid new)` that report reference updates.
|
/// `void Function(String refname, Oid old, Oid new)` that report reference
|
||||||
|
/// updates.
|
||||||
///
|
///
|
||||||
/// [pushUpdateReference] is the callback function matching the
|
/// [pushUpdateReference] is the callback function matching the
|
||||||
/// `void Function(String refname, String message)` used to inform of the update status
|
/// `void Function(String refname, String message)` used to inform of the
|
||||||
/// from the remote.
|
/// update status from the remote.
|
||||||
const Callbacks({
|
const Callbacks({
|
||||||
this.credentials,
|
this.credentials,
|
||||||
this.transferProgress,
|
this.transferProgress,
|
||||||
|
@ -32,11 +36,13 @@ class Callbacks {
|
||||||
/// Callback function that reports textual progress from the remote.
|
/// Callback function that reports textual progress from the remote.
|
||||||
final void Function(String)? sidebandProgress;
|
final void Function(String)? sidebandProgress;
|
||||||
|
|
||||||
/// Callback function matching the `void Function(String refname, Oid old, Oid new)`
|
/// Callback function matching the
|
||||||
/// that report reference updates.
|
/// `void Function(String refname, Oid old, Oid new)` that report reference
|
||||||
|
/// updates.
|
||||||
final void Function(String, Oid, Oid)? updateTips;
|
final void Function(String, Oid, Oid)? updateTips;
|
||||||
|
|
||||||
/// Callback function matching the `void Function(String refname, String message)`
|
/// Callback function matching the
|
||||||
/// used to inform of the update status from the remote.
|
/// `void Function(String refname, String message)` used to inform of the
|
||||||
|
/// update status from the remote.
|
||||||
final void Function(String, String)? pushUpdateReference;
|
final void Function(String, String)? pushUpdateReference;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,28 +32,29 @@ class Commit {
|
||||||
///
|
///
|
||||||
/// [repo] is the repository where to store the commit.
|
/// [repo] is the repository where to store the commit.
|
||||||
///
|
///
|
||||||
/// [updateRef] is the name of the reference that will be updated to point to this commit.
|
/// [updateRef] is the name of the reference that will be updated to point to
|
||||||
/// If the reference is not direct, it will be resolved to a direct reference. Use "HEAD"
|
/// this commit. If the reference is not direct, it will be resolved to a
|
||||||
/// to update the HEAD of the current branch and make it point to this commit. If the
|
/// direct reference. Use "HEAD" to update the HEAD of the current branch and
|
||||||
/// reference doesn't exist yet, it will be created. If it does exist, the first parent
|
/// make it point to this commit. If the reference doesn't exist yet, it will
|
||||||
/// must be the tip of this branch.
|
/// be created. If it does exist, the first parent must be the tip of this
|
||||||
|
/// branch.
|
||||||
///
|
///
|
||||||
/// [author] is the signature with author and author time of commit.
|
/// [author] is the signature with author and author time of commit.
|
||||||
///
|
///
|
||||||
/// [committer] is the signature with committer and commit time of commit.
|
/// [committer] is the signature with committer and commit time of commit.
|
||||||
///
|
///
|
||||||
/// [messageEncoding] is the encoding for the message in the commit, represented with
|
/// [messageEncoding] is the encoding for the message in the commit,
|
||||||
/// a standard encoding name. E.g. "UTF-8". If null, no encoding header is written and
|
/// represented with a standard encoding name. E.g. "UTF-8". If null, no
|
||||||
/// UTF-8 is assumed.
|
/// encoding header is written and UTF-8 is assumed.
|
||||||
///
|
///
|
||||||
/// [message] is the full message for this commit.
|
/// [message] is the full message for this commit.
|
||||||
///
|
///
|
||||||
/// [tree] is an instance of a [Tree] object that will be used as the tree for the commit.
|
/// [tree] is an instance of a [Tree] object that will be used as the tree
|
||||||
/// This tree object must also be owned by the given [repo].
|
/// for the commit. This tree object must also be owned by the given [repo].
|
||||||
///
|
///
|
||||||
/// [parents] is a list of [Commit] objects that will be used as the parents for this commit.
|
/// [parents] is a list of [Commit] objects that will be used as the parents
|
||||||
/// This array may be empty if parent count is 0 (root commit). All the given commits must
|
/// for this commit. This array may be empty if parent count is 0
|
||||||
/// be owned by the [repo].
|
/// (root commit). All the given commits must be owned by the [repo].
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
static Oid create({
|
static Oid create({
|
||||||
|
@ -81,17 +82,19 @@ class Commit {
|
||||||
|
|
||||||
/// Amends an existing commit by replacing only non-null values.
|
/// Amends an existing commit by replacing only non-null values.
|
||||||
///
|
///
|
||||||
/// This creates a new commit that is exactly the same as the old commit, except that
|
/// This creates a new commit that is exactly the same as the old commit,
|
||||||
/// any non-null values will be updated. The new commit has the same parents as the old commit.
|
/// except that any non-null values will be updated. The new commit has the
|
||||||
|
/// same parents as the old commit.
|
||||||
///
|
///
|
||||||
/// The [updateRef] value works as in the regular [create], updating the ref to point to
|
/// The [updateRef] value works as in the regular [create], updating the ref
|
||||||
/// the newly rewritten commit. If you want to amend a commit that is not currently
|
/// to point to the newly rewritten commit. If you want to amend a commit
|
||||||
/// the tip of the branch and then rewrite the following commits to reach a ref, pass
|
/// that is not currently the tip of the branch and then rewrite the
|
||||||
/// this as null and update the rest of the commit chain and ref separately.
|
/// following commits to reach a ref, pass this as null and update the rest
|
||||||
|
/// of the commit chain and ref separately.
|
||||||
///
|
///
|
||||||
/// Unlike [create], the [author], [committer], [message], [messageEncoding], and
|
/// Unlike [create], the [author], [committer], [message], [messageEncoding],
|
||||||
/// [tree] arguments can be null in which case this will use the values from the original
|
/// and [tree] arguments can be null in which case this will use the values
|
||||||
/// [commit].
|
/// from the original [commit].
|
||||||
///
|
///
|
||||||
/// All arguments have the same meanings as in [create].
|
/// All arguments have the same meanings as in [create].
|
||||||
///
|
///
|
||||||
|
@ -169,14 +172,16 @@ class Commit {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'Commit{oid: $oid, message: $message, messageEncoding: $messageEncoding, '
|
return 'Commit{oid: $oid, message: $message, '
|
||||||
'time: $time, committer: $committer, author: $author}';
|
'messageEncoding: $messageEncoding, time: $time, committer: $committer,'
|
||||||
|
' author: $author}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An annotated commit contains information about how it was looked up, which may be useful
|
/// An annotated commit contains information about how it was looked up, which
|
||||||
/// for functions like merge or rebase to provide context to the operation. For example, conflict
|
/// may be useful for functions like merge or rebase to provide context to the
|
||||||
/// files will include the name of the source or target branches being merged.
|
/// operation. For example, conflict files will include the name of the source
|
||||||
|
/// or target branches being merged.
|
||||||
///
|
///
|
||||||
/// Note: for internal use.
|
/// Note: for internal use.
|
||||||
class AnnotatedCommit {
|
class AnnotatedCommit {
|
||||||
|
|
|
@ -21,7 +21,8 @@ class Config with IterableMixin<ConfigEntry> {
|
||||||
/// If [path] isn't provided, opens global, XDG and system config files.
|
/// If [path] isn't provided, opens global, XDG and system config files.
|
||||||
///
|
///
|
||||||
/// [path] should point to single on-disk file; it's expected to be a native
|
/// [path] should point to single on-disk file; it's expected to be a native
|
||||||
/// Git config file following the default Git config syntax (see man git-config).
|
/// Git config file following the default Git config syntax (see
|
||||||
|
/// `man git-config`).
|
||||||
///
|
///
|
||||||
/// **IMPORTANT**: Should be freed to release allocated memory.
|
/// **IMPORTANT**: Should be freed to release allocated memory.
|
||||||
///
|
///
|
||||||
|
@ -76,9 +77,9 @@ class Config with IterableMixin<ConfigEntry> {
|
||||||
/// Pointer to memory address for allocated config object.
|
/// Pointer to memory address for allocated config object.
|
||||||
late final Pointer<git_config> _configPointer;
|
late final Pointer<git_config> _configPointer;
|
||||||
|
|
||||||
/// The snapshot of the current state of a configuration, which allows you to look
|
/// The snapshot of the current state of a configuration, which allows you to
|
||||||
/// into a consistent view of the configuration for looking up complex values
|
/// look into a consistent view of the configuration for looking up complex
|
||||||
/// (e.g. a remote, submodule).
|
/// values (e.g. a remote, submodule).
|
||||||
Config get snapshot => Config(bindings.snapshot(_configPointer));
|
Config get snapshot => Config(bindings.snapshot(_configPointer));
|
||||||
|
|
||||||
/// Returns the [ConfigEntry] of a [variable].
|
/// Returns the [ConfigEntry] of a [variable].
|
||||||
|
@ -153,8 +154,8 @@ class Config with IterableMixin<ConfigEntry> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Deletes one or several values from a multivar [variable] in the config file
|
/// Deletes one or several values from a multivar [variable] in the config
|
||||||
/// with the highest level (usually the local one).
|
/// file with the highest level (usually the local one).
|
||||||
///
|
///
|
||||||
/// The [regexp] is applied case-sensitively on the value.
|
/// The [regexp] is applied case-sensitively on the value.
|
||||||
/// Empty [regexp] deletes all values of a multivar [variable].
|
/// Empty [regexp] deletes all values of a multivar [variable].
|
||||||
|
@ -205,7 +206,8 @@ class ConfigEntry {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'ConfigEntry{name: $name, value: $value, includeDepth: $includeDepth, level: $level}';
|
return 'ConfigEntry{name: $name, value: $value, '
|
||||||
|
'includeDepth: $includeDepth, level: $level}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,8 +50,8 @@ class Keypair implements Credentials {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'Keypair{username: $username, pubKey: $pubKey, privateKey: $privateKey, '
|
return 'Keypair{username: $username, pubKey: $pubKey, '
|
||||||
'passPhrase: $passPhrase}';
|
'privateKey: $privateKey, passPhrase: $passPhrase}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ class KeypairFromMemory implements Credentials {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'KeypairFromMemory{username: $username, pubKey: $pubKey, privateKey: $privateKey, '
|
return 'KeypairFromMemory{username: $username, pubKey: $pubKey, '
|
||||||
'passPhrase: $passPhrase}';
|
'privateKey: $privateKey, passPhrase: $passPhrase}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,13 +17,15 @@ class Diff {
|
||||||
|
|
||||||
/// Reads the [content]s of a git patch file into a git diff object.
|
/// Reads the [content]s of a git patch file into a git diff object.
|
||||||
///
|
///
|
||||||
/// The diff object produced is similar to the one that would be produced if you actually
|
/// The diff object produced is similar to the one that would be produced if
|
||||||
/// produced it computationally by comparing two trees, however there may be subtle differences.
|
/// you actually produced it computationally by comparing two trees, however
|
||||||
/// For example, a patch file likely contains abbreviated object IDs, so the object IDs in a
|
/// there may be subtle differences. For example, a patch file likely
|
||||||
/// diff delta produced by this function will also be abbreviated.
|
/// contains abbreviated object IDs, so the object IDs in a diff delta
|
||||||
|
/// produced by this function will also be abbreviated.
|
||||||
///
|
///
|
||||||
/// This function will only read patch files created by a git implementation, it will not
|
/// This function will only read patch files created by a git implementation,
|
||||||
/// read unified diffs produced by the `diff` program, nor any other types of patch files.
|
/// it will not read unified diffs produced by the `diff` program, nor any
|
||||||
|
/// other types of patch files.
|
||||||
Diff.parse(String content) {
|
Diff.parse(String content) {
|
||||||
libgit2.git_libgit2_init();
|
libgit2.git_libgit2_init();
|
||||||
_diffPointer = bindings.parse(content);
|
_diffPointer = bindings.parse(content);
|
||||||
|
@ -37,7 +39,8 @@ class Diff {
|
||||||
/// How many diff records are there in a diff.
|
/// How many diff records are there in a diff.
|
||||||
int get length => bindings.length(_diffPointer);
|
int get length => bindings.length(_diffPointer);
|
||||||
|
|
||||||
/// Returns a list of [DiffDelta]s containing file pairs with and old and new revisions.
|
/// Returns a list of [DiffDelta]s containing file pairs with and old and new
|
||||||
|
/// revisions.
|
||||||
List<DiffDelta> get deltas {
|
List<DiffDelta> get deltas {
|
||||||
final length = bindings.length(_diffPointer);
|
final length = bindings.length(_diffPointer);
|
||||||
var deltas = <DiffDelta>[];
|
var deltas = <DiffDelta>[];
|
||||||
|
@ -96,28 +99,32 @@ class Diff {
|
||||||
|
|
||||||
/// Transforms a diff marking file renames, copies, etc.
|
/// Transforms a diff marking file renames, copies, etc.
|
||||||
///
|
///
|
||||||
/// This modifies a diff in place, replacing old entries that look like renames or copies
|
/// This modifies a diff in place, replacing old entries that look like
|
||||||
/// with new entries reflecting those changes. This also will, if requested, break modified
|
/// renames or copies with new entries reflecting those changes. This also
|
||||||
/// files into add/remove pairs if the amount of change is above a threshold.
|
/// will, if requested, break modified files into add/remove pairs if the
|
||||||
|
/// amount of change is above a threshold.
|
||||||
///
|
///
|
||||||
/// [flags] is a combination of [GitDiffFind] flags. Defaults to [GitDiffFind.byConfig].
|
/// [flags] is a combination of [GitDiffFind] flags. Defaults to
|
||||||
|
/// [GitDiffFind.byConfig].
|
||||||
///
|
///
|
||||||
/// [renameThreshold] is the threshold above which similar files will be considered renames.
|
/// [renameThreshold] is the threshold above which similar files will be
|
||||||
/// This is equivalent to the -M option. Defaults to 50.
|
/// considered renames. This is equivalent to the -M option. Defaults to 50.
|
||||||
///
|
///
|
||||||
/// [copyThreshold] is the threshold above which similar files will be considered copies.
|
/// [copyThreshold] is the threshold above which similar files will be
|
||||||
/// This is equivalent to the -C option. Defaults to 50.
|
/// considered copies. This is equivalent to the -C option. Defaults to 50.
|
||||||
///
|
///
|
||||||
/// [renameFromRewriteThreshold] is the threshold below which similar files will be
|
/// [renameFromRewriteThreshold] is the threshold below which similar files
|
||||||
/// eligible to be a rename source. This is equivalent to the first part of the -B option.
|
/// will be eligible to be a rename source. This is equivalent to the first
|
||||||
/// Defaults to 50.
|
/// part of the -B option. Defaults to 50.
|
||||||
///
|
///
|
||||||
/// [breakRewriteThreshold] is the treshold below which similar files will be split into
|
/// [breakRewriteThreshold] is the treshold below which similar files will be
|
||||||
/// a delete/add pair. This is equivalent to the last part of the -B option. Defaults to 60.
|
/// split into a delete/add pair. This is equivalent to the last part of the -B
|
||||||
|
/// option. Defaults to 60.
|
||||||
///
|
///
|
||||||
/// [renameLimit] is the maximum number of matches to consider for a particular file.
|
/// [renameLimit] is the maximum number of matches to consider for a
|
||||||
/// This is a little different from the -l option from Git because we will still process
|
/// particular file. This is a little different from the -l option from Git
|
||||||
/// up to this many matches before abandoning the search. Defaults to 200.
|
/// because we will still process up to this many matches before abandoning
|
||||||
|
/// the search. Defaults to 200.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
void findSimilar({
|
void findSimilar({
|
||||||
|
@ -139,12 +146,13 @@ class Diff {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Calculates a stable patch [Oid] for the given patch by summing the hash of the file diffs,
|
/// Calculates a stable patch [Oid] for the given patch by summing the hash
|
||||||
/// ignoring whitespace and line numbers. This can be used to derive whether two diffs are
|
/// of the file diffs, ignoring whitespace and line numbers. This can be used
|
||||||
/// the same with a high probability.
|
/// to derive whether two diffs are the same with a high probability.
|
||||||
///
|
///
|
||||||
/// Currently, this function only calculates stable patch IDs, as defined in `git-patch-id(1)`,
|
/// Currently, this function only calculates stable patch IDs, as defined in
|
||||||
/// and should in fact generate the same IDs as the upstream git project does.
|
/// `git-patch-id(1)`, and should in fact generate the same IDs as the
|
||||||
|
/// upstream git project does.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
Oid get patchOid => Oid(bindings.patchOid(_diffPointer));
|
Oid get patchOid => Oid(bindings.patchOid(_diffPointer));
|
||||||
|
@ -175,10 +183,10 @@ class DiffDelta {
|
||||||
|
|
||||||
/// Single character abbreviation for a delta status code.
|
/// Single character abbreviation for a delta status code.
|
||||||
///
|
///
|
||||||
/// When you run `git diff --name-status` it uses single letter codes in the output such as
|
/// When you run `git diff --name-status` it uses single letter codes in the
|
||||||
/// 'A' for added, 'D' for deleted, 'M' for modified, etc. This function converts a [GitDelta]
|
/// output such as 'A' for added, 'D' for deleted, 'M' for modified, etc.
|
||||||
/// value into these letters for your own purposes. [GitDelta.untracked] will return
|
/// This function converts a [GitDelta] value into these letters for your own
|
||||||
/// a space (i.e. ' ').
|
/// purposes. [GitDelta.untracked] will return a space (i.e. ' ').
|
||||||
String get statusChar => bindings.statusChar(_diffDeltaPointer.ref.status);
|
String get statusChar => bindings.statusChar(_diffDeltaPointer.ref.status);
|
||||||
|
|
||||||
/// Flags for the delta object.
|
/// Flags for the delta object.
|
||||||
|
@ -214,7 +222,8 @@ class DiffDelta {
|
||||||
/// link, a submodule commit id, or even a tree (although that only if you
|
/// link, a submodule commit id, or even a tree (although that only if you
|
||||||
/// are tracking type changes or ignored/untracked directories).
|
/// are tracking type changes or ignored/untracked directories).
|
||||||
class DiffFile {
|
class DiffFile {
|
||||||
/// Initializes a new instance of [DiffFile] class from provided diff file object.
|
/// Initializes a new instance of [DiffFile] class from provided diff file
|
||||||
|
/// object.
|
||||||
const DiffFile(this._diffFile);
|
const DiffFile(this._diffFile);
|
||||||
|
|
||||||
final git_diff_file _diffFile;
|
final git_diff_file _diffFile;
|
||||||
|
@ -243,7 +252,8 @@ class DiffFile {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'DiffFile{oid: $oid, path: $path, size: $size, flags: $flags, mode: $mode}';
|
return 'DiffFile{oid: $oid, path: $path, size: $size, flags: $flags, '
|
||||||
|
'mode: $mode}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,13 +294,15 @@ class DiffStats {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'DiffStats{insertions: $insertions, deletions: $deletions, filesChanged: $filesChanged}';
|
return 'DiffStats{insertions: $insertions, deletions: $deletions, '
|
||||||
|
'filesChanged: $filesChanged}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class DiffHunk {
|
class DiffHunk {
|
||||||
/// Initializes a new instance of [DiffHunk] class from provided
|
/// Initializes a new instance of [DiffHunk] class from provided
|
||||||
/// pointers to patch object and diff hunk object in memory and number of lines in hunk.
|
/// pointers to patch object and diff hunk object in memory and number of
|
||||||
|
/// lines in hunk.
|
||||||
const DiffHunk(
|
const DiffHunk(
|
||||||
this._patchPointer,
|
this._patchPointer,
|
||||||
this._diffHunkPointer,
|
this._diffHunkPointer,
|
||||||
|
@ -346,8 +358,9 @@ class DiffHunk {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'DiffHunk{linesCount: $linesCount, index: $index, oldStart: $oldStart, '
|
return 'DiffHunk{linesCount: $linesCount, index: $index, '
|
||||||
'oldLines: $oldLines, newStart: $newStart, newLines: $newLines, header: $header}';
|
'oldStart: $oldStart, oldLines: $oldLines, newStart: $newStart, '
|
||||||
|
'newLines: $newLines, header: $header}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -384,7 +397,8 @@ class DiffLine {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'DiffLine{oldLineNumber: $oldLineNumber, newLineNumber: $newLineNumber, '
|
return 'DiffLine{oldLineNumber: $oldLineNumber, '
|
||||||
'numLines: $numLines, contentOffset: $contentOffset, content: $content}';
|
'newLineNumber: $newLineNumber, numLines: $numLines, '
|
||||||
|
'contentOffset: $contentOffset, content: $content}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,8 +70,8 @@ class GitSort {
|
||||||
/// this sorting mode can be combined with topological sorting.
|
/// this sorting mode can be combined with topological sorting.
|
||||||
static const time = GitSort._(2, 'time');
|
static const time = GitSort._(2, 'time');
|
||||||
|
|
||||||
/// Iterate through the repository contents in reverse order; this sorting mode
|
/// Iterate through the repository contents in reverse order; this sorting
|
||||||
/// can be combined with any of the above.
|
/// mode can be combined with any of the above.
|
||||||
static const reverse = GitSort._(4, 'reverse');
|
static const reverse = GitSort._(4, 'reverse');
|
||||||
|
|
||||||
static const List<GitSort> values = [none, topological, time, reverse];
|
static const List<GitSort> values = [none, topological, time, reverse];
|
||||||
|
@ -1336,8 +1336,8 @@ class GitFeature {
|
||||||
final int _value;
|
final int _value;
|
||||||
final String _name;
|
final String _name;
|
||||||
|
|
||||||
/// If set, libgit2 was built thread-aware and can be safely used from multiple
|
/// If set, libgit2 was built thread-aware and can be safely used from
|
||||||
/// threads.
|
/// multiple threads.
|
||||||
static const threads = GitFeature._(1, 'threads');
|
static const threads = GitFeature._(1, 'threads');
|
||||||
|
|
||||||
/// If set, libgit2 was built with and linked against a TLS implementation.
|
/// If set, libgit2 was built with and linked against a TLS implementation.
|
||||||
|
@ -1596,7 +1596,8 @@ class GitSubmoduleUpdate {
|
||||||
/// out branch of the submodule.
|
/// out branch of the submodule.
|
||||||
static const merge = GitSubmoduleUpdate._(3, 'merge');
|
static const merge = GitSubmoduleUpdate._(3, 'merge');
|
||||||
|
|
||||||
/// Do not update this submodule even when the commit in the superproject is updated.
|
/// Do not update this submodule even when the commit in the superproject is
|
||||||
|
/// updated.
|
||||||
static const none = GitSubmoduleUpdate._(4, 'none');
|
static const none = GitSubmoduleUpdate._(4, 'none');
|
||||||
|
|
||||||
static const List<GitSubmoduleUpdate> values = [
|
static const List<GitSubmoduleUpdate> values = [
|
||||||
|
|
|
@ -84,18 +84,20 @@ class Index with IterableMixin<IndexEntry> {
|
||||||
|
|
||||||
/// Clears the contents (all the entries) of an index object.
|
/// Clears the contents (all the entries) of an index object.
|
||||||
///
|
///
|
||||||
/// This clears the index object in memory; changes must be explicitly written to
|
/// This clears the index object in memory; changes must be explicitly
|
||||||
/// disk for them to take effect persistently.
|
/// written to disk for them to take effect persistently.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
void clear() => bindings.clear(_indexPointer);
|
void clear() => bindings.clear(_indexPointer);
|
||||||
|
|
||||||
/// Adds or updates an index entry from an [IndexEntry] or from a file on disk.
|
/// Adds or updates an index entry from an [IndexEntry] or from a file on
|
||||||
|
/// disk.
|
||||||
///
|
///
|
||||||
/// If a previous index entry exists that has the same path and stage as the given `entry`,
|
/// If a previous index entry exists that has the same path and stage as the
|
||||||
/// it will be replaced. Otherwise, the `entry` will be added.
|
/// given [entry], it will be replaced. Otherwise, the [entry] will be added.
|
||||||
///
|
///
|
||||||
/// The file path must be relative to the repository's working folder and must be readable.
|
/// The file path must be relative to the repository's working folder and
|
||||||
|
/// must be readable.
|
||||||
///
|
///
|
||||||
/// This method will fail in bare index instances.
|
/// This method will fail in bare index instances.
|
||||||
///
|
///
|
||||||
|
@ -115,47 +117,51 @@ class Index with IterableMixin<IndexEntry> {
|
||||||
///
|
///
|
||||||
/// This method will fail in bare index instances.
|
/// This method will fail in bare index instances.
|
||||||
///
|
///
|
||||||
/// The [pathspec] is a list of file names or shell glob patterns that will be matched
|
/// The [pathspec] is a list of file names or shell glob patterns that will
|
||||||
/// against files in the repository's working directory. Each file that matches will be
|
/// be matched against files in the repository's working directory. Each file
|
||||||
/// added to the index (either updating an existing entry or adding a new entry).
|
/// that matches will be added to the index (either updating an existing
|
||||||
|
/// entry or adding a new entry).
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
void addAll(List<String> pathspec) {
|
void addAll(List<String> pathspec) {
|
||||||
bindings.addAll(indexPointer: _indexPointer, pathspec: pathspec);
|
bindings.addAll(indexPointer: _indexPointer, pathspec: pathspec);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Updates the contents of an existing index object in memory by reading from the hard disk.
|
/// Updates the contents of an existing index object in memory by reading
|
||||||
|
/// from the hard disk.
|
||||||
///
|
///
|
||||||
/// If [force] is true (default), this performs a "hard" read that discards in-memory changes and
|
/// If [force] is true (default), this performs a "hard" read that discards
|
||||||
/// always reloads the on-disk index data. If there is no on-disk version,
|
/// in-memory changes and always reloads the on-disk index data. If there is
|
||||||
/// the index will be cleared.
|
/// no on-disk version, the index will be cleared.
|
||||||
///
|
///
|
||||||
/// If [force] is false, this does a "soft" read that reloads the index data from disk only
|
/// If [force] is false, this does a "soft" read that reloads the index data
|
||||||
/// if it has changed since the last time it was loaded. Purely in-memory index data
|
/// from disk only if it has changed since the last time it was loaded.
|
||||||
/// will be untouched. Be aware: if there are changes on disk, unwritten in-memory changes
|
/// Purely in-memory index data will be untouched. Be aware: if there are
|
||||||
/// are discarded.
|
/// changes on disk, unwritten in-memory changes are discarded.
|
||||||
void read({bool force = true}) =>
|
void read({bool force = true}) =>
|
||||||
bindings.read(indexPointer: _indexPointer, force: force);
|
bindings.read(indexPointer: _indexPointer, force: force);
|
||||||
|
|
||||||
/// Updates the contents of an existing index object in memory by reading from the
|
/// Updates the contents of an existing index object in memory by reading
|
||||||
/// specified [tree].
|
/// from the specified [tree].
|
||||||
void readTree(Tree tree) {
|
void readTree(Tree tree) {
|
||||||
bindings.readTree(indexPointer: _indexPointer, treePointer: tree.pointer);
|
bindings.readTree(indexPointer: _indexPointer, treePointer: tree.pointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Writes an existing index object from memory back to disk using an atomic file lock.
|
/// Writes an existing index object from memory back to disk using an atomic
|
||||||
|
/// file lock.
|
||||||
void write() => bindings.write(_indexPointer);
|
void write() => bindings.write(_indexPointer);
|
||||||
|
|
||||||
/// Writes the index as a tree.
|
/// Writes the index as a tree.
|
||||||
///
|
///
|
||||||
/// This method will scan the index and write a representation of its current state back to disk;
|
/// This method will scan the index and write a representation of its current
|
||||||
/// it recursively creates tree objects for each of the subtrees stored in the index, but only
|
/// state back to disk; it recursively creates tree objects for each of the
|
||||||
/// returns the [Oid] of the root tree. This is the oid that can be used e.g. to create a commit.
|
/// subtrees stored in the index, but only returns the [Oid] of the root
|
||||||
|
/// tree. This is the oid that can be used e.g. to create a commit.
|
||||||
///
|
///
|
||||||
/// The index must not contain any file in conflict.
|
/// The index must not contain any file in conflict.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured or there is no associated repository
|
/// Throws a [LibGit2Error] if error occured or there is no associated
|
||||||
/// and no [repo] passed.
|
/// repository and no [repo] passed.
|
||||||
Oid writeTree([Repository? repo]) {
|
Oid writeTree([Repository? repo]) {
|
||||||
if (repo == null) {
|
if (repo == null) {
|
||||||
return Oid(bindings.writeTree(_indexPointer));
|
return Oid(bindings.writeTree(_indexPointer));
|
||||||
|
@ -167,15 +173,15 @@ class Index with IterableMixin<IndexEntry> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Removes an entry from the index at provided [path] relative to repository working
|
/// Removes an entry from the index at provided [path] relative to repository
|
||||||
/// directory with optional [stage].
|
/// working directory with optional [stage].
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
void remove(String path, [int stage = 0]) =>
|
void remove(String path, [int stage = 0]) =>
|
||||||
bindings.remove(indexPointer: _indexPointer, path: path, stage: stage);
|
bindings.remove(indexPointer: _indexPointer, path: path, stage: stage);
|
||||||
|
|
||||||
/// Removes all matching index entries at provided list of [path]s relative to repository
|
/// Removes all matching index entries at provided list of [path]s relative
|
||||||
/// working directory.
|
/// to repository working directory.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
void removeAll(List<String> path) =>
|
void removeAll(List<String> path) =>
|
||||||
|
@ -310,7 +316,8 @@ class ConflictEntry {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() =>
|
String toString() =>
|
||||||
'ConflictEntry{ancestor: $ancestor, our: $our, their: $their, path: $_path}';
|
'ConflictEntry{ancestor: $ancestor, our: $our, their: $their, '
|
||||||
|
'path: $_path}';
|
||||||
}
|
}
|
||||||
|
|
||||||
class _IndexIterator implements Iterator<IndexEntry> {
|
class _IndexIterator implements Iterator<IndexEntry> {
|
||||||
|
|
|
@ -31,7 +31,8 @@ class Mailmap {
|
||||||
///
|
///
|
||||||
/// Mailmaps are loaded in the following order:
|
/// Mailmaps are loaded in the following order:
|
||||||
///
|
///
|
||||||
/// 1. `.mailmap` in the root of the repository's working directory, if present.
|
/// 1. `.mailmap` in the root of the repository's working directory, if
|
||||||
|
/// present.
|
||||||
/// 2. The blob object identified by the `mailmap.blob` config entry, if set.
|
/// 2. The blob object identified by the `mailmap.blob` config entry, if set.
|
||||||
/// NOTE: `mailmap.blob` defaults to `HEAD:.mailmap` in bare repositories
|
/// NOTE: `mailmap.blob` defaults to `HEAD:.mailmap` in bare repositories
|
||||||
/// 3. The path in the `mailmap.file` config entry, if set.
|
/// 3. The path in the `mailmap.file` config entry, if set.
|
||||||
|
@ -46,8 +47,8 @@ class Mailmap {
|
||||||
/// Pointer to memory address for allocated mailmap object.
|
/// Pointer to memory address for allocated mailmap object.
|
||||||
late final Pointer<git_mailmap> _mailmapPointer;
|
late final Pointer<git_mailmap> _mailmapPointer;
|
||||||
|
|
||||||
/// Returns list containing resolved [name] and [email] to the corresponding real name
|
/// Returns list containing resolved [name] and [email] to the corresponding
|
||||||
/// and real email respectively.
|
/// real name and real email respectively.
|
||||||
List<String> resolve({
|
List<String> resolve({
|
||||||
required String name,
|
required String name,
|
||||||
required String email,
|
required String email,
|
||||||
|
@ -67,8 +68,8 @@ class Mailmap {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds a single entry to the given mailmap object. If the entry already exists,
|
/// Adds a single entry to the given mailmap object. If the entry already
|
||||||
/// it will be replaced with the new entry.
|
/// exists, it will be replaced with the new entry.
|
||||||
///
|
///
|
||||||
/// Throws a [ArgumentError] if [replaceEmail] is empty string.
|
/// Throws a [ArgumentError] if [replaceEmail] is empty string.
|
||||||
void addEntry({
|
void addEntry({
|
||||||
|
|
|
@ -30,11 +30,11 @@ class Odb {
|
||||||
|
|
||||||
/// Adds an on-disk alternate to an existing Object DB.
|
/// Adds an on-disk alternate to an existing Object DB.
|
||||||
///
|
///
|
||||||
/// Note that the added [path] must point to an `objects`, not to a full repository,
|
/// Note that the added [path] must point to an `objects`, not to a full
|
||||||
/// to use it as an alternate store.
|
/// repository, to use it as an alternate store.
|
||||||
///
|
///
|
||||||
/// Alternate backends are always checked for objects after all the main backends
|
/// Alternate backends are always checked for objects after all the main
|
||||||
/// have been exhausted.
|
/// backends have been exhausted.
|
||||||
///
|
///
|
||||||
/// Writing is disabled on alternate backends.
|
/// Writing is disabled on alternate backends.
|
||||||
void addDiskAlternate(String path) {
|
void addDiskAlternate(String path) {
|
||||||
|
@ -56,9 +56,11 @@ class Odb {
|
||||||
|
|
||||||
/// Reads an object from the database.
|
/// Reads an object from the database.
|
||||||
///
|
///
|
||||||
/// This method queries all available ODB backends trying to read the given [oid].
|
/// This method queries all available ODB backends trying to read the given
|
||||||
|
/// [oid].
|
||||||
///
|
///
|
||||||
/// **IMPORTANT**: Returned object should be freed to release allocated memory.
|
/// **IMPORTANT**: Returned object should be freed to release allocated
|
||||||
|
/// memory.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
OdbObject read(Oid oid) {
|
OdbObject read(Oid oid) {
|
||||||
|
@ -70,10 +72,11 @@ class Odb {
|
||||||
|
|
||||||
/// Writes raw [data] to into the object database.
|
/// Writes raw [data] to into the object database.
|
||||||
///
|
///
|
||||||
/// [type] should be one of [GitObject.blob], [GitObject.commit], [GitObject.tag] or
|
/// [type] should be one of [GitObject.blob], [GitObject.commit],
|
||||||
/// [GitObject.tree].
|
/// [GitObject.tag] or [GitObject.tree].
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured or [ArgumentError] if provided type is invalid.
|
/// Throws a [LibGit2Error] if error occured or [ArgumentError] if provided
|
||||||
|
/// type is invalid.
|
||||||
Oid write({required GitObject type, required String data}) {
|
Oid write({required GitObject type, required String data}) {
|
||||||
if (type == GitObject.any ||
|
if (type == GitObject.any ||
|
||||||
type == GitObject.invalid ||
|
type == GitObject.invalid ||
|
||||||
|
|
|
@ -12,9 +12,9 @@ class Oid {
|
||||||
/// pointer to Oid object in memory.
|
/// pointer to Oid object in memory.
|
||||||
Oid(this._oidPointer);
|
Oid(this._oidPointer);
|
||||||
|
|
||||||
/// Initializes a new instance of [Oid] class by determining if an object can be found
|
/// Initializes a new instance of [Oid] class by determining if an object can
|
||||||
/// in the ODB of [repo]sitory with provided hexadecimal [sha] string that is 40 characters
|
/// be found in the ODB of [repo]sitory with provided hexadecimal [sha]
|
||||||
/// long or shorter.
|
/// string that is 40 characters long or shorter.
|
||||||
///
|
///
|
||||||
/// Throws [ArgumentError] if provided [sha] hex string is not valid.
|
/// Throws [ArgumentError] if provided [sha] hex string is not valid.
|
||||||
///
|
///
|
||||||
|
@ -37,7 +37,8 @@ class Oid {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Initializes a new instance of [Oid] class from provided raw git_oid structure.
|
/// Initializes a new instance of [Oid] class from provided raw git_oid
|
||||||
|
/// structure.
|
||||||
Oid.fromRaw(git_oid raw) {
|
Oid.fromRaw(git_oid raw) {
|
||||||
_oidPointer = bindings.fromRaw(raw.id);
|
_oidPointer = bindings.fromRaw(raw.id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,8 @@ class Patch {
|
||||||
/// **IMPORTANT**: Should be freed to release allocated memory.
|
/// **IMPORTANT**: Should be freed to release allocated memory.
|
||||||
Patch(this._patchPointer, this._aPointer, this._bPointer);
|
Patch(this._patchPointer, this._aPointer, this._bPointer);
|
||||||
|
|
||||||
/// Directly generates a patch from the difference between two blobs, buffers or
|
/// Directly generates a patch from the difference between two blobs, buffers
|
||||||
/// blob and a buffer.
|
/// or blob and a buffer.
|
||||||
///
|
///
|
||||||
/// [a] and [b] can be [Blob], [String] or null.
|
/// [a] and [b] can be [Blob], [String] or null.
|
||||||
///
|
///
|
||||||
|
@ -117,15 +117,15 @@ class Patch {
|
||||||
|
|
||||||
/// Size of patch diff data in bytes.
|
/// Size of patch diff data in bytes.
|
||||||
///
|
///
|
||||||
/// This returns the raw size of the patch data. This only includes the actual data from
|
/// This returns the raw size of the patch data. This only includes the
|
||||||
/// the lines of the diff, not the file or hunk headers.
|
/// actual data from the lines of the diff, not the file or hunk headers.
|
||||||
///
|
///
|
||||||
/// If you pass `includeContext` as true, this will be the size of all of the diff output;
|
/// If you pass `includeContext` as true, this will be the size of all of the
|
||||||
/// if you pass it as false, this will only include the actual changed lines (as if
|
/// diff output; if you pass it as false, this will only include the actual
|
||||||
/// contextLines was 0).
|
/// changed lines (as if contextLines was 0).
|
||||||
///
|
///
|
||||||
/// If [includeHunkHeaders] and [includeFileHeaders] are set to true, they will be included
|
/// If [includeHunkHeaders] and [includeFileHeaders] are set to true, they
|
||||||
/// in the total size.
|
/// will be included in the total size.
|
||||||
int size({
|
int size({
|
||||||
bool includeContext = false,
|
bool includeContext = false,
|
||||||
bool includeHunkHeaders = false,
|
bool includeHunkHeaders = false,
|
||||||
|
|
|
@ -4,16 +4,18 @@ import 'bindings/libgit2_bindings.dart';
|
||||||
import 'bindings/rebase.dart' as bindings;
|
import 'bindings/rebase.dart' as bindings;
|
||||||
|
|
||||||
class Rebase {
|
class Rebase {
|
||||||
/// Initializes a rebase operation to rebase the changes in [branch] relative to [upstream]
|
/// Initializes a rebase operation to rebase the changes in [branch] relative
|
||||||
/// [onto] another branch. To begin the rebase process, call [next].
|
/// to [upstream] [onto] another branch. To begin the rebase process,
|
||||||
|
/// call [next].
|
||||||
///
|
///
|
||||||
/// [branch] is the terminal commit to rebase, default is to rebase the current branch.
|
/// [branch] is the terminal commit to rebase, default is to rebase the
|
||||||
|
/// current branch.
|
||||||
///
|
///
|
||||||
/// [upstream] is the commit to begin rebasing from, default is to rebase all
|
/// [upstream] is the commit to begin rebasing from, default is to rebase all
|
||||||
/// reachable commits.
|
/// reachable commits.
|
||||||
///
|
///
|
||||||
/// [onto] is the branch to rebase onto, default is to rebase onto the given [upstream]
|
/// [onto] is the branch to rebase onto, default is to rebase onto the given
|
||||||
/// (throws if [upstream] is not provided).
|
/// [upstream] (throws if [upstream] is not provided).
|
||||||
///
|
///
|
||||||
/// **IMPORTANT**: Should be freed to release allocated memory.
|
/// **IMPORTANT**: Should be freed to release allocated memory.
|
||||||
///
|
///
|
||||||
|
@ -62,10 +64,11 @@ class Rebase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Performs the next rebase operation and returns the information about it.
|
/// Performs the next rebase operation and returns the information about it.
|
||||||
/// If the operation is one that applies a patch (which is any operation except
|
/// If the operation is one that applies a patch (which is any operation
|
||||||
/// [GitRebaseOperation.exec]) then the patch will be applied and the index and
|
/// except [GitRebaseOperation.exec]) then the patch will be applied and the
|
||||||
/// working directory will be updated with the changes. If there are conflicts,
|
/// index and working directory will be updated with the changes. If there
|
||||||
/// you will need to address those before committing the changes.
|
/// are conflicts, you will need to address those before committing the
|
||||||
|
/// changes.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
RebaseOperation next() {
|
RebaseOperation next() {
|
||||||
|
@ -77,11 +80,11 @@ class Rebase {
|
||||||
///
|
///
|
||||||
/// [committer] is the committer of the rebase.
|
/// [committer] is the committer of the rebase.
|
||||||
///
|
///
|
||||||
/// [message] the message for this commit, can be null to use the message from the
|
/// [message] the message for this commit, can be null to use the message
|
||||||
/// original commit.
|
/// from the original commit.
|
||||||
///
|
///
|
||||||
/// [author] is the author of the updated commit, can be null to keep the author from
|
/// [author] is the author of the updated commit, can be null to keep the
|
||||||
/// the original commit.
|
/// author from the original commit.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
void commit({
|
void commit({
|
||||||
|
@ -97,11 +100,12 @@ class Rebase {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Finishes a rebase that is currently in progress once all patches have been applied.
|
/// Finishes a rebase that is currently in progress once all patches have
|
||||||
|
/// been applied.
|
||||||
void finish() => bindings.finish(_rebasePointer);
|
void finish() => bindings.finish(_rebasePointer);
|
||||||
|
|
||||||
/// Aborts a rebase that is currently in progress, resetting the repository and working
|
/// Aborts a rebase that is currently in progress, resetting the repository
|
||||||
/// directory to their state before rebase began.
|
/// and working directory to their state before rebase began.
|
||||||
void abort() => bindings.abort(_rebasePointer);
|
void abort() => bindings.abort(_rebasePointer);
|
||||||
|
|
||||||
/// Releases memory allocated for rebase object.
|
/// Releases memory allocated for rebase object.
|
||||||
|
|
|
@ -22,20 +22,21 @@ class Reference {
|
||||||
/// allocated memory.
|
/// allocated memory.
|
||||||
///
|
///
|
||||||
/// Valid reference [name]s must follow one of two patterns:
|
/// Valid reference [name]s must follow one of two patterns:
|
||||||
/// - Top-level names must contain only capital letters and underscores, and must begin and end
|
/// - Top-level names must contain only capital letters and underscores, and
|
||||||
/// with a letter. (e.g. "HEAD", "ORIG_HEAD").
|
/// must begin and end with a letter. (e.g. "HEAD", "ORIG_HEAD").
|
||||||
/// - Names prefixed with "refs/" can be almost anything. You must avoid the characters
|
/// - Names prefixed with "refs/" can be almost anything. You must avoid the characters
|
||||||
/// '~', '^', ':', '\', '?', '[', and '*', and the sequences ".." and "@{" which have
|
/// '~', '^', ':', '\', '?', '[', and '*', and the sequences ".." and "@{" which have
|
||||||
/// special meaning to revparse.
|
/// special meaning to revparse.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if a reference already exists with the given [name]
|
/// Throws a [LibGit2Error] if a reference already exists with the given
|
||||||
/// unless [force] is true, in which case it will be overwritten.
|
/// [name] unless [force] is true, in which case it will be overwritten.
|
||||||
///
|
///
|
||||||
/// The [logMessage] message for the reflog will be ignored if the reference does not belong in the
|
/// The [logMessage] message for the reflog will be ignored if the reference
|
||||||
/// standard set (HEAD, branches and remote-tracking branches) and it does not have a reflog.
|
/// does not belong in the standard set (HEAD, branches and remote-tracking
|
||||||
|
/// branches) and it does not have a reflog.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured or [ArgumentError] if provided [target]
|
/// Throws a [LibGit2Error] if error occured or [ArgumentError] if provided
|
||||||
/// is not Oid or String reference name.
|
/// [target] is not Oid or String reference name.
|
||||||
Reference.create({
|
Reference.create({
|
||||||
required Repository repo,
|
required Repository repo,
|
||||||
required String name,
|
required String name,
|
||||||
|
@ -96,11 +97,12 @@ class Reference {
|
||||||
///
|
///
|
||||||
/// The [newName] will be checked for validity.
|
/// The [newName] will be checked for validity.
|
||||||
///
|
///
|
||||||
/// If the [force] flag is set to false, and there's already a reference with the given name,
|
/// If the [force] flag is set to false, and there's already a reference with
|
||||||
/// the renaming will fail.
|
/// the given name, the renaming will fail.
|
||||||
///
|
///
|
||||||
/// IMPORTANT: The user needs to write a proper reflog entry [logMessage] if the reflog is
|
/// IMPORTANT: The user needs to write a proper reflog entry [logMessage] if
|
||||||
/// enabled for the repository. We only rename the reflog if it exists.
|
/// the reflog is enabled for the repository. We only rename the reflog if it
|
||||||
|
/// exists.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
static void rename({
|
static void rename({
|
||||||
|
@ -125,9 +127,9 @@ class Reference {
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
static List<String> list(Repository repo) => bindings.list(repo.pointer);
|
static List<String> list(Repository repo) => bindings.list(repo.pointer);
|
||||||
|
|
||||||
/// Suggests that the [repo]sitory's refdb compress or optimize its references.
|
/// Suggests that the [repo]sitory's refdb compress or optimize its
|
||||||
/// This mechanism is implementation specific. For on-disk reference databases,
|
/// references. This mechanism is implementation specific. For on-disk
|
||||||
/// for example, this may pack all loose references.
|
/// reference databases, for example, this may pack all loose references.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
static void compress(Repository repo) {
|
static void compress(Repository repo) {
|
||||||
|
@ -159,11 +161,11 @@ class Reference {
|
||||||
|
|
||||||
/// Updates the [target] of this reference.
|
/// Updates the [target] of this reference.
|
||||||
///
|
///
|
||||||
/// [target] being either Oid for direct reference or string reference name for symbolic
|
/// [target] being either Oid for direct reference or string reference name
|
||||||
/// reference.
|
/// for symbolic reference.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured or [ArgumentError] if [target] is not
|
/// Throws a [LibGit2Error] if error occured or [ArgumentError] if [target]
|
||||||
/// [Oid] or string.
|
/// is not [Oid] or string.
|
||||||
void setTarget({required Object target, String? logMessage}) {
|
void setTarget({required Object target, String? logMessage}) {
|
||||||
if (target is Oid) {
|
if (target is Oid) {
|
||||||
final newPointer = bindings.setTarget(
|
final newPointer = bindings.setTarget(
|
||||||
|
@ -189,11 +191,14 @@ class Reference {
|
||||||
|
|
||||||
/// Recursively peel reference until object of the specified [type] is found.
|
/// Recursively peel reference until object of the specified [type] is found.
|
||||||
///
|
///
|
||||||
/// The retrieved peeled object is owned by the repository and should be closed to release memory.
|
/// The retrieved peeled object is owned by the repository and should be
|
||||||
|
/// freed to release memory.
|
||||||
///
|
///
|
||||||
/// If no [type] is provided, then the object will be peeled until a non-tag object is met.
|
/// If no [type] is provided, then the object will be peeled until a non-tag
|
||||||
|
/// object is met.
|
||||||
///
|
///
|
||||||
/// Returned object should be explicitly downcasted to one of four of git object types.
|
/// Returned object should be explicitly downcasted to one of four of git
|
||||||
|
/// object types.
|
||||||
///
|
///
|
||||||
/// ```dart
|
/// ```dart
|
||||||
/// final commit = ref.peel(GitObject.commit) as Commit;
|
/// final commit = ref.peel(GitObject.commit) as Commit;
|
||||||
|
@ -223,8 +228,8 @@ class Reference {
|
||||||
|
|
||||||
/// Reference's short name.
|
/// Reference's short name.
|
||||||
///
|
///
|
||||||
/// This will transform the reference name into a name "human-readable" version.
|
/// This will transform the reference name into a name "human-readable"
|
||||||
/// If no shortname is appropriate, it will return the full name.
|
/// version. If no shortname is appropriate, it will return the full name.
|
||||||
String get shorthand => bindings.shorthand(_refPointer);
|
String get shorthand => bindings.shorthand(_refPointer);
|
||||||
|
|
||||||
/// Whether reflog exists for the specified reference [name].
|
/// Whether reflog exists for the specified reference [name].
|
||||||
|
@ -272,7 +277,8 @@ class Reference {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'Reference{name: $name, target: $target, type: $type, isBranch: $isBranch, '
|
return 'Reference{name: $name, target: $target, type: $type, '
|
||||||
'isNote: $isNote, isRemote: $isRemote, isTag: $isTag}';
|
'isBranch: $isBranch, isNote: $isNote, isRemote: $isRemote, '
|
||||||
|
'isTag: $isTag}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,8 @@ class Refspec {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Transforms a target reference to its source reference following the refspec's rules.
|
/// Transforms a target reference to its source reference following the
|
||||||
|
/// refspec's rules.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
String rTransform(String name) {
|
String rTransform(String name) {
|
||||||
|
@ -68,6 +69,7 @@ class Refspec {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'Refspec{source: $source, destination: $destination, force: $force, string: $string}';
|
return 'Refspec{source: $source, destination: $destination, force: $force, '
|
||||||
|
'string: $string}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,8 @@ class Remote {
|
||||||
|
|
||||||
/// Deletes an existing persisted remote with provided [name].
|
/// Deletes an existing persisted remote with provided [name].
|
||||||
///
|
///
|
||||||
/// All remote-tracking branches and configuration settings for the remote will be removed.
|
/// All remote-tracking branches and configuration settings for the remote
|
||||||
|
/// will be removed.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
static void delete({required Repository repo, required String name}) {
|
static void delete({required Repository repo, required String name}) {
|
||||||
|
@ -61,12 +62,13 @@ class Remote {
|
||||||
///
|
///
|
||||||
/// Returns list of non-default refspecs that cannot be renamed.
|
/// Returns list of non-default refspecs that cannot be renamed.
|
||||||
///
|
///
|
||||||
/// All remote-tracking branches and configuration settings for the remote are updated.
|
/// All remote-tracking branches and configuration settings for the remote
|
||||||
|
/// are updated.
|
||||||
///
|
///
|
||||||
/// The [newName] will be checked for validity.
|
/// The [newName] will be checked for validity.
|
||||||
///
|
///
|
||||||
/// No loaded instances of a the remote with the old name will change their name or
|
/// No loaded instances of a the remote with the old name will change their
|
||||||
/// their list of refspecs.
|
/// name or their list of refspecs.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
static List<String> rename({
|
static List<String> rename({
|
||||||
|
@ -88,8 +90,8 @@ class Remote {
|
||||||
|
|
||||||
/// Sets the [remote]'s [url] in the configuration.
|
/// Sets the [remote]'s [url] in the configuration.
|
||||||
///
|
///
|
||||||
/// Remote objects already in memory will not be affected. This assumes the common
|
/// Remote objects already in memory will not be affected. This assumes the
|
||||||
/// case of a single-url remote and will otherwise return an error.
|
/// common case of a single-url remote and will otherwise return an error.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
static void setUrl({
|
static void setUrl({
|
||||||
|
@ -106,8 +108,8 @@ class Remote {
|
||||||
|
|
||||||
/// Sets the [remote]'s [url] for pushing in the configuration.
|
/// Sets the [remote]'s [url] for pushing in the configuration.
|
||||||
///
|
///
|
||||||
/// Remote objects already in memory will not be affected. This assumes the common
|
/// Remote objects already in memory will not be affected. This assumes the
|
||||||
/// case of a single-url remote and will otherwise return an error.
|
/// common case of a single-url remote and will otherwise return an error.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
static void setPushUrl({
|
static void setPushUrl({
|
||||||
|
@ -184,17 +186,20 @@ class Remote {
|
||||||
/// List of push refspecs.
|
/// List of push refspecs.
|
||||||
List<String> get pushRefspecs => bindings.pushRefspecs(_remotePointer);
|
List<String> get pushRefspecs => bindings.pushRefspecs(_remotePointer);
|
||||||
|
|
||||||
/// Returns the remote repository's reference list and their associated commit ids.
|
/// Returns the remote repository's reference list and their associated
|
||||||
|
/// commit ids.
|
||||||
///
|
///
|
||||||
/// [proxy] can be 'auto' to try to auto-detect the proxy from the git configuration or some
|
/// [proxy] can be 'auto' to try to auto-detect the proxy from the git
|
||||||
/// specified url. By default connection isn't done through proxy.
|
/// configuration or some specified url. By default connection isn't done
|
||||||
|
/// through proxy.
|
||||||
///
|
///
|
||||||
/// [callbacks] is the combination of callback functions from [Callbacks] object.
|
/// [callbacks] is the combination of callback functions from [Callbacks]
|
||||||
|
/// object.
|
||||||
///
|
///
|
||||||
/// Returned map keys:
|
/// Returned map keys:
|
||||||
/// - `local` is true if remote head is available locally, false otherwise.
|
/// - `local` is true if remote head is available locally, false otherwise.
|
||||||
/// - `loid` is the oid of the object the local copy of the remote head is currently
|
/// - `loid` is the oid of the object the local copy of the remote head is
|
||||||
/// pointing to. null if there is no local copy of the remote head.
|
/// currently pointing to. null if there is no local copy of the remote head.
|
||||||
/// - `name` is the name of the reference.
|
/// - `name` is the name of the reference.
|
||||||
/// - `oid` is the oid of the object the remote head is currently pointing to.
|
/// - `oid` is the oid of the object the remote head is currently pointing to.
|
||||||
/// - `symref` is the target of the symbolic reference or empty string.
|
/// - `symref` is the target of the symbolic reference or empty string.
|
||||||
|
@ -217,16 +222,20 @@ class Remote {
|
||||||
|
|
||||||
/// Downloads new data and updates tips.
|
/// Downloads new data and updates tips.
|
||||||
///
|
///
|
||||||
/// [refspecs] is the list of refspecs to use for this fetch. Defaults to the base refspecs.
|
/// [refspecs] is the list of refspecs to use for this fetch. Defaults to the
|
||||||
|
/// base refspecs.
|
||||||
///
|
///
|
||||||
/// [reflogMessage] is the message to insert into the reflogs. Default is "fetch".
|
/// [reflogMessage] is the message to insert into the reflogs. Default is
|
||||||
|
/// "fetch".
|
||||||
///
|
///
|
||||||
/// [prune] determines whether to perform a prune after the fetch.
|
/// [prune] determines whether to perform a prune after the fetch.
|
||||||
///
|
///
|
||||||
/// [proxy] can be 'auto' to try to auto-detect the proxy from the git configuration or some
|
/// [proxy] can be 'auto' to try to auto-detect the proxy from the git
|
||||||
/// specified url. By default connection isn't done through proxy.
|
/// configuration or some specified url. By default connection isn't done
|
||||||
|
/// through proxy.
|
||||||
///
|
///
|
||||||
/// [callbacks] is the combination of callback functions from [Callbacks] object.
|
/// [callbacks] is the combination of callback functions from [Callbacks]
|
||||||
|
/// object.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
TransferProgress fetch({
|
TransferProgress fetch({
|
||||||
|
@ -249,12 +258,15 @@ class Remote {
|
||||||
|
|
||||||
/// Performs a push.
|
/// Performs a push.
|
||||||
///
|
///
|
||||||
/// [refspecs] is the list of refspecs to use for pushing. Defaults to the configured refspecs.
|
/// [refspecs] is the list of refspecs to use for pushing. Defaults to the
|
||||||
|
/// configured refspecs.
|
||||||
///
|
///
|
||||||
/// [proxy] can be 'auto' to try to auto-detect the proxy from the git configuration or some
|
/// [proxy] can be 'auto' to try to auto-detect the proxy from the git
|
||||||
/// specified url. By default connection isn't done through proxy.
|
/// configuration or some specified url. By default connection isn't done
|
||||||
|
/// through proxy.
|
||||||
///
|
///
|
||||||
/// [callbacks] is the combination of callback functions from [Callbacks] object.
|
/// [callbacks] is the combination of callback functions from [Callbacks]
|
||||||
|
/// object.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
void push({
|
void push({
|
||||||
|
@ -272,7 +284,8 @@ class Remote {
|
||||||
|
|
||||||
/// Prunes tracking refs that are no longer present on remote.
|
/// Prunes tracking refs that are no longer present on remote.
|
||||||
///
|
///
|
||||||
/// [callbacks] is the combination of callback functions from [Callbacks] object.
|
/// [callbacks] is the combination of callback functions from [Callbacks]
|
||||||
|
/// object.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
void prune([Callbacks callbacks = const Callbacks()]) {
|
void prune([Callbacks callbacks = const Callbacks()]) {
|
||||||
|
@ -287,15 +300,16 @@ class Remote {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'Remote{name: $name, url: $url, pushUrl: $pushUrl, refspecCount: $refspecCount}';
|
return 'Remote{name: $name, url: $url, pushUrl: $pushUrl, '
|
||||||
|
'refspecCount: $refspecCount}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Provides callers information about the progress of indexing a packfile, either
|
/// Provides callers information about the progress of indexing a packfile,
|
||||||
/// directly or part of a fetch or clone that downloads a packfile.
|
/// either directly or part of a fetch or clone that downloads a packfile.
|
||||||
class TransferProgress {
|
class TransferProgress {
|
||||||
/// Initializes a new instance of [TransferProgress] class from provided pointer
|
/// Initializes a new instance of [TransferProgress] class from provided
|
||||||
/// to transfer progress object in memory.
|
/// pointer to transfer progress object in memory.
|
||||||
const TransferProgress(this._transferProgressPointer);
|
const TransferProgress(this._transferProgressPointer);
|
||||||
|
|
||||||
/// Pointer to memory address for allocated transfer progress object.
|
/// Pointer to memory address for allocated transfer progress object.
|
||||||
|
@ -324,8 +338,9 @@ class TransferProgress {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'TransferProgress{totalObjects: $totalObjects, indexedObjects: $indexedObjects, '
|
return 'TransferProgress{totalObjects: $totalObjects, '
|
||||||
'receivedObjects: $receivedObjects, localObjects: $localObjects, totalDeltas: $totalDeltas, '
|
'indexedObjects: $indexedObjects, receivedObjects: $receivedObjects, '
|
||||||
|
'localObjects: $localObjects, totalDeltas: $totalDeltas, '
|
||||||
'indexedDeltas: $indexedDeltas, receivedBytes: $receivedBytes}';
|
'indexedDeltas: $indexedDeltas, receivedBytes: $receivedBytes}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,24 +33,26 @@ class Repository {
|
||||||
/// [flags] is a combination of [GitRepositoryInit] flags. Defaults to
|
/// [flags] is a combination of [GitRepositoryInit] flags. Defaults to
|
||||||
/// [GitRepositoryInit.mkdir].
|
/// [GitRepositoryInit.mkdir].
|
||||||
///
|
///
|
||||||
/// [mode] is the permissions for the folder. Default to 0 (permissions configured by
|
/// [mode] is the permissions for the folder. Default to 0 (permissions
|
||||||
/// umask).
|
/// configured by umask).
|
||||||
///
|
///
|
||||||
/// [workdirPath] is the path to the working directory. Can be null for default path.
|
/// [workdirPath] is the path to the working directory. Can be null for
|
||||||
|
/// default path.
|
||||||
///
|
///
|
||||||
/// [description] if set will be used to initialize the "description" file in the
|
/// [description] if set will be used to initialize the "description" file in
|
||||||
/// repository, instead of using the template content.
|
/// the repository, instead of using the template content.
|
||||||
///
|
///
|
||||||
/// [templatePath] is the the path to use for the template directory if
|
/// [templatePath] is the the path to use for the template directory if
|
||||||
/// [GitRepositoryInit.externalTemplate] is set. Defaults to the config or default
|
/// [GitRepositoryInit.externalTemplate] is set. Defaults to the config or
|
||||||
/// directory options.
|
/// default directory options.
|
||||||
///
|
///
|
||||||
/// [initialHead] is the name of the head to point HEAD at. If null, then this will be
|
/// [initialHead] is the name of the head to point HEAD at. If null, then
|
||||||
/// treated as "master" and the HEAD ref will be set to "refs/heads/master". If this
|
/// this will be treated as "master" and the HEAD ref will be set to
|
||||||
/// begins with "refs/" it will be used verbatim, otherwise "refs/heads/" will be prefixed.
|
/// "refs/heads/master". If this begins with "refs/" it will be used
|
||||||
|
/// verbatim, otherwise "refs/heads/" will be prefixed.
|
||||||
///
|
///
|
||||||
/// [originUrl] if set, then after the rest of the repository initialization is completed,
|
/// [originUrl] if set, then after the rest of the repository initialization
|
||||||
/// an "origin" remote will be added pointing to this URL.
|
/// is completed, an "origin" remote will be added pointing to this URL.
|
||||||
///
|
///
|
||||||
/// **IMPORTANT**: Should be freed to release allocated memory.
|
/// **IMPORTANT**: Should be freed to release allocated memory.
|
||||||
///
|
///
|
||||||
|
@ -103,8 +105,9 @@ class Repository {
|
||||||
|
|
||||||
/// Clones a remote repository at provided [url] into [localPath].
|
/// Clones a remote repository at provided [url] into [localPath].
|
||||||
///
|
///
|
||||||
/// By default this creates its repository and initial remote to match git's defaults.
|
/// By default this creates its repository and initial remote to match git's
|
||||||
/// You can use the [remote] and [repository] options to customize how these are created.
|
/// defaults. You can use the [remote] and [repository] options to customize
|
||||||
|
/// how these are created.
|
||||||
///
|
///
|
||||||
/// [url] is the remote repository to clone.
|
/// [url] is the remote repository to clone.
|
||||||
///
|
///
|
||||||
|
@ -112,16 +115,19 @@ class Repository {
|
||||||
///
|
///
|
||||||
/// [bare] whether cloned repo should be bare.
|
/// [bare] whether cloned repo should be bare.
|
||||||
///
|
///
|
||||||
/// [remote] is the callback function with `Remote Function(Repository repo, String name, String url)`
|
/// [remote] is the callback function with
|
||||||
/// signature. The [Remote] it returns will be used instead of default one.
|
/// `Remote Function(Repository repo, String name, String url)` signature.
|
||||||
|
/// The [Remote] it returns will be used instead of default one.
|
||||||
///
|
///
|
||||||
/// [repository] is the callback function matching the `Repository Function(String path, bool bare)`
|
/// [repository] is the callback function matching the
|
||||||
/// signature. The [Repository] it returns will be used instead of creating a new one.
|
/// `Repository Function(String path, bool bare)` signature. The [Repository]
|
||||||
|
/// it returns will be used instead of creating a new one.
|
||||||
///
|
///
|
||||||
/// [checkoutBranch] is the name of the branch to checkout after the clone. Defaults
|
/// [checkoutBranch] is the name of the branch to checkout after the clone.
|
||||||
/// to using the remote's default branch.
|
/// Defaults to using the remote's default branch.
|
||||||
///
|
///
|
||||||
/// [callbacks] is the combination of callback functions from [Callbacks] object.
|
/// [callbacks] is the combination of callback functions from [Callbacks]
|
||||||
|
/// object.
|
||||||
///
|
///
|
||||||
/// **IMPORTANT**: Should be freed to release allocated memory.
|
/// **IMPORTANT**: Should be freed to release allocated memory.
|
||||||
///
|
///
|
||||||
|
@ -153,11 +159,13 @@ class Repository {
|
||||||
/// Pointer to memory address for allocated repository object.
|
/// Pointer to memory address for allocated repository object.
|
||||||
Pointer<git_repository> get pointer => _repoPointer;
|
Pointer<git_repository> get pointer => _repoPointer;
|
||||||
|
|
||||||
/// Looks for a git repository and return its path. The lookup start from [startPath]
|
/// Looks for a git repository and return its path. The lookup start from
|
||||||
/// and walk across parent directories if nothing has been found. The lookup ends when
|
/// [startPath] and walk across parent directories if nothing has been found.
|
||||||
/// the first repository is found, or when reaching a directory referenced in [ceilingDirs].
|
/// The lookup ends when the first repository is found, or when reaching a
|
||||||
|
/// directory referenced in [ceilingDirs].
|
||||||
///
|
///
|
||||||
/// The method will automatically detect if the repository is bare (if there is a repository).
|
/// The method will automatically detect if the repository is bare (if there
|
||||||
|
/// is a repository).
|
||||||
static String discover({required String startPath, String? ceilingDirs}) {
|
static String discover({required String startPath, String? ceilingDirs}) {
|
||||||
return bindings.discover(
|
return bindings.discover(
|
||||||
startPath: startPath,
|
startPath: startPath,
|
||||||
|
@ -174,8 +182,8 @@ class Repository {
|
||||||
return Oid.fromSHA(repo: this, sha: sha);
|
return Oid.fromSHA(repo: this, sha: sha);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Path to the ".git" folder for normal repositories or path to the repository
|
/// Path to the ".git" folder for normal repositories or path to the
|
||||||
/// itself for bare repositories.
|
/// repository itself for bare repositories.
|
||||||
String get path => bindings.path(_repoPointer);
|
String get path => bindings.path(_repoPointer);
|
||||||
|
|
||||||
/// Path of the shared common directory for this repository.
|
/// Path of the shared common directory for this repository.
|
||||||
|
@ -193,10 +201,11 @@ class Repository {
|
||||||
|
|
||||||
/// Sets the active [namespace] for this repository.
|
/// Sets the active [namespace] for this repository.
|
||||||
///
|
///
|
||||||
/// This namespace affects all reference operations for the repo. See `man gitnamespaces`
|
/// 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
|
/// The [namespace] should not include the refs folder, e.g. to namespace all
|
||||||
/// under "refs/namespaces/foo/", use "foo" as the namespace.
|
/// references under "refs/namespaces/foo/", use "foo" as the namespace.
|
||||||
///
|
///
|
||||||
/// Pass null to unset.
|
/// Pass null to unset.
|
||||||
void setNamespace(String? namespace) {
|
void setNamespace(String? namespace) {
|
||||||
|
@ -219,7 +228,8 @@ class Repository {
|
||||||
|
|
||||||
/// Whether repository's HEAD is detached.
|
/// Whether repository's HEAD is detached.
|
||||||
///
|
///
|
||||||
/// A repository's HEAD is detached when it points directly to a commit instead of a branch.
|
/// A repository's HEAD is detached when it points directly to a commit
|
||||||
|
/// instead of a branch.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
bool get isHeadDetached {
|
bool get isHeadDetached {
|
||||||
|
@ -228,17 +238,20 @@ class Repository {
|
||||||
|
|
||||||
/// Makes the repository HEAD point to the specified reference or commit.
|
/// Makes the repository HEAD point to the specified reference or commit.
|
||||||
///
|
///
|
||||||
/// If the provided [target] points to a Tree or a Blob, the HEAD is unaltered.
|
/// If the provided [target] points to a Tree or a Blob, the HEAD is
|
||||||
|
/// unaltered.
|
||||||
///
|
///
|
||||||
/// If the provided [target] points to a branch, the HEAD will point to that branch,
|
/// If the provided [target] points to a branch, the HEAD will point to that
|
||||||
/// staying attached, or become attached if it isn't yet.
|
/// branch, staying attached, or become attached if it isn't yet.
|
||||||
///
|
///
|
||||||
/// If the branch doesn't exist yet, the HEAD will be attached to an unborn branch.
|
/// If the branch doesn't exist yet, the HEAD will be attached to an unborn
|
||||||
|
/// branch.
|
||||||
///
|
///
|
||||||
/// Otherwise, the HEAD will be detached and will directly point to the Commit.
|
/// Otherwise, the HEAD will be detached and will directly point to the
|
||||||
|
/// Commit.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured or [ArgumentError] if provided [target]
|
/// Throws a [LibGit2Error] if error occured or [ArgumentError] if provided
|
||||||
/// is not [Oid] or string.
|
/// [target] is not [Oid] or string.
|
||||||
void setHead(Object target) {
|
void setHead(Object target) {
|
||||||
if (target is Oid) {
|
if (target is Oid) {
|
||||||
bindings.setHeadDetached(
|
bindings.setHeadDetached(
|
||||||
|
@ -255,8 +268,8 @@ class Repository {
|
||||||
|
|
||||||
/// Whether current branch is unborn.
|
/// Whether current branch is unborn.
|
||||||
///
|
///
|
||||||
/// An unborn branch is one named from HEAD but which doesn't exist in the refs namespace,
|
/// An unborn branch is one named from HEAD but which doesn't exist in the
|
||||||
/// because it doesn't have any commit to point to.
|
/// refs namespace, because it doesn't have any commit to point to.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
bool get isBranchUnborn {
|
bool get isBranchUnborn {
|
||||||
|
@ -265,7 +278,8 @@ class Repository {
|
||||||
|
|
||||||
/// Sets the identity to be used for writing reflogs.
|
/// Sets the identity to be used for writing reflogs.
|
||||||
///
|
///
|
||||||
/// If both are set, this [name] and [email] will be used to write to the reflog.
|
/// If both are set, this [name] and [email] will be used to write to the
|
||||||
|
/// reflog.
|
||||||
///
|
///
|
||||||
/// Pass null to unset. When unset, the identity will be taken from the
|
/// Pass null to unset. When unset, the identity will be taken from the
|
||||||
/// repository's configuration.
|
/// repository's configuration.
|
||||||
|
@ -295,7 +309,8 @@ class Repository {
|
||||||
///
|
///
|
||||||
/// Use this function to get the contents of this file.
|
/// Use this function to get the contents of this file.
|
||||||
///
|
///
|
||||||
/// **IMPORTANT**: remove the file with [removeMessage] after you create the commit.
|
/// **IMPORTANT**: remove the file with [removeMessage] after you create the
|
||||||
|
/// commit.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
String get message => bindings.message(_repoPointer);
|
String get message => bindings.message(_repoPointer);
|
||||||
|
@ -303,8 +318,8 @@ class Repository {
|
||||||
/// Removes git's prepared message.
|
/// Removes git's prepared message.
|
||||||
void removeMessage() => bindings.removeMessage(_repoPointer);
|
void removeMessage() => bindings.removeMessage(_repoPointer);
|
||||||
|
|
||||||
/// Status of a git repository - ie, whether an operation (merge, cherry-pick, etc)
|
/// Status of a git repository - ie, whether an operation (merge,
|
||||||
/// is in progress.
|
/// cherry-pick, etc) is in progress.
|
||||||
GitRepositoryState get state {
|
GitRepositoryState get state {
|
||||||
final stateInt = bindings.state(_repoPointer);
|
final stateInt = bindings.state(_repoPointer);
|
||||||
return GitRepositoryState.values.singleWhere(
|
return GitRepositoryState.values.singleWhere(
|
||||||
|
@ -328,9 +343,9 @@ class Repository {
|
||||||
/// The working directory doesn't need to be the same one that contains the
|
/// The working directory doesn't need to be the same one that contains the
|
||||||
/// ".git" folder for this repository.
|
/// ".git" folder for this repository.
|
||||||
///
|
///
|
||||||
/// If this repository is bare, setting its working directory will turn it into a
|
/// If this repository is bare, setting its working directory will turn it
|
||||||
/// normal repository, capable of performing all the common workdir operations
|
/// into a normal repository, capable of performing all the common workdir
|
||||||
/// (checkout, status, index manipulation, etc).
|
/// operations (checkout, status, index manipulation, etc).
|
||||||
///
|
///
|
||||||
/// [updateGitLink] if set creates/updates gitlink in workdir and sets config
|
/// [updateGitLink] if set creates/updates gitlink in workdir and sets config
|
||||||
/// "core.worktree" (if workdir is not the parent of the ".git" directory)
|
/// "core.worktree" (if workdir is not the parent of the ".git" directory)
|
||||||
|
@ -349,24 +364,29 @@ class Repository {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'Repository{path: $path, commonDir: $commonDir, namespace: $namespace, '
|
return 'Repository{path: $path, commonDir: $commonDir, '
|
||||||
'isBare: $isBare, isEmpty: $isEmpty, isHeadDetached: $isHeadDetached, '
|
'namespace: $namespace, isBare: $isBare, isEmpty: $isEmpty, '
|
||||||
'isBranchUnborn: $isBranchUnborn, isShallow: $isShallow, isWorktree: $isWorktree, '
|
'isHeadDetached: $isHeadDetached, isBranchUnborn: $isBranchUnborn, '
|
||||||
'state: $state, workdir: $workdir}';
|
'isShallow: $isShallow, isWorktree: $isWorktree, state: $state, '
|
||||||
|
'workdir: $workdir}';
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Configuration file for this repository.
|
/// Configuration file for this repository.
|
||||||
///
|
///
|
||||||
/// If a configuration file has not been set, the default config set for the repository
|
/// If a configuration file has not been set, the default config set for the
|
||||||
/// will be returned, including global and system configurations (if they are available).
|
/// repository will be returned, including global and system configurations
|
||||||
|
/// (if they are available).
|
||||||
///
|
///
|
||||||
/// **IMPORTANT**: Should be freed to release allocated memory.
|
/// **IMPORTANT**: Should be freed to release allocated memory.
|
||||||
Config get config => Config(bindings.config(_repoPointer));
|
Config get config => Config(bindings.config(_repoPointer));
|
||||||
|
|
||||||
/// Snapshot of the repository's configuration.
|
/// Snapshot of the repository's configuration.
|
||||||
///
|
///
|
||||||
/// Convenience function to take a snapshot from the repository's configuration.
|
/// Convenience function to take a snapshot from the repository's
|
||||||
/// The contents of this snapshot will not change, even if the underlying config files are modified.
|
/// configuration.
|
||||||
|
///
|
||||||
|
/// The contents of this snapshot will not change, even if the underlying
|
||||||
|
/// config files are modified.
|
||||||
///
|
///
|
||||||
/// **IMPORTANT**: Should be freed to release allocated memory.
|
/// **IMPORTANT**: Should be freed to release allocated memory.
|
||||||
Config get configSnapshot => Config(bindings.configSnapshot(_repoPointer));
|
Config get configSnapshot => Config(bindings.configSnapshot(_repoPointer));
|
||||||
|
@ -400,20 +420,21 @@ class Repository {
|
||||||
/// allocated memory.
|
/// allocated memory.
|
||||||
///
|
///
|
||||||
/// Valid reference [name]s must follow one of two patterns:
|
/// Valid reference [name]s must follow one of two patterns:
|
||||||
/// - Top-level names must contain only capital letters and underscores, and must begin and end
|
/// - Top-level names must contain only capital letters and underscores, and
|
||||||
/// with a letter. (e.g. "HEAD", "ORIG_HEAD").
|
/// must begin and end with a letter. (e.g. "HEAD", "ORIG_HEAD").
|
||||||
/// - Names prefixed with "refs/" can be almost anything. You must avoid the characters
|
/// - Names prefixed with "refs/" can be almost anything. You must avoid the characters
|
||||||
/// '~', '^', ':', '\', '?', '[', and '*', and the sequences ".." and "@{" which have
|
/// '~', '^', ':', '\', '?', '[', and '*', and the sequences ".." and "@{" which have
|
||||||
/// special meaning to revparse.
|
/// special meaning to revparse.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if a reference already exists with the given [name]
|
/// Throws a [LibGit2Error] if a reference already exists with the given
|
||||||
/// unless [force] is true, in which case it will be overwritten.
|
/// [name] unless [force] is true, in which case it will be overwritten.
|
||||||
///
|
///
|
||||||
/// The [logMessage] message for the reflog will be ignored if the reference does not belong in the
|
/// The [logMessage] message for the reflog will be ignored if the reference
|
||||||
/// standard set (HEAD, branches and remote-tracking branches) and it does not have a reflog.
|
/// does not belong in the standard set (HEAD, branches and remote-tracking
|
||||||
|
/// branches) and it does not have a reflog.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured or [ArgumentError] if provided [target]
|
/// Throws a [LibGit2Error] if error occured or [ArgumentError] if provided
|
||||||
/// is not Oid or String reference name.
|
/// [target] is not Oid or String reference name.
|
||||||
Reference createReference({
|
Reference createReference({
|
||||||
required String name,
|
required String name,
|
||||||
required Object target,
|
required Object target,
|
||||||
|
@ -442,11 +463,12 @@ class Repository {
|
||||||
///
|
///
|
||||||
/// The [newName] will be checked for validity.
|
/// The [newName] will be checked for validity.
|
||||||
///
|
///
|
||||||
/// If the [force] flag is set to false, and there's already a reference with the given name,
|
/// If the [force] flag is set to false, and there's already a reference with
|
||||||
/// the renaming will fail.
|
/// the given name, the renaming will fail.
|
||||||
///
|
///
|
||||||
/// IMPORTANT: The user needs to write a proper reflog entry [logMessage] if the reflog is
|
/// IMPORTANT: The user needs to write a proper reflog entry [logMessage] if
|
||||||
/// enabled for the repository. We only rename the reflog if it exists.
|
/// the reflog is enabled for the repository. We only rename the reflog if it
|
||||||
|
/// exists.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
void renameReference({
|
void renameReference({
|
||||||
|
@ -485,13 +507,15 @@ class Repository {
|
||||||
|
|
||||||
/// Creates a new action signature with default user and now timestamp.
|
/// Creates a new action signature with default user and now timestamp.
|
||||||
///
|
///
|
||||||
/// This looks up the "user.name" and "user.email" from the configuration and uses the
|
/// This looks up the "user.name" and "user.email" from the configuration and
|
||||||
/// current time as the timestamp, and creates a new signature based on that information.
|
/// uses the current time as the timestamp, and creates a new signature based
|
||||||
|
/// on that information.
|
||||||
Signature get defaultSignature => Signature.defaultSignature(this);
|
Signature get defaultSignature => Signature.defaultSignature(this);
|
||||||
|
|
||||||
/// Returns the list of commits starting from provided commit [oid].
|
/// Returns the list of commits starting from provided commit [oid].
|
||||||
///
|
///
|
||||||
/// If [sorting] isn't provided default will be used (reverse chronological order, like in git).
|
/// If [sorting] isn't provided default will be used (reverse chronological
|
||||||
|
/// order, like in git).
|
||||||
///
|
///
|
||||||
/// **IMPORTANT**: Commits should be freed to release allocated memory.
|
/// **IMPORTANT**: Commits should be freed to release allocated memory.
|
||||||
List<Commit> log({
|
List<Commit> log({
|
||||||
|
@ -529,28 +553,29 @@ class Repository {
|
||||||
|
|
||||||
/// Creates new commit in the repository.
|
/// Creates new commit in the repository.
|
||||||
///
|
///
|
||||||
/// [updateRef] is the name of the reference that will be updated to point to this commit.
|
/// [updateRef] is the name of the reference that will be updated to point to
|
||||||
/// If the reference is not direct, it will be resolved to a direct reference. Use "HEAD"
|
/// this commit. If the reference is not direct, it will be resolved to a
|
||||||
/// to update the HEAD of the current branch and make it point to this commit. If the
|
/// direct reference. Use "HEAD" to update the HEAD of the current branch and
|
||||||
/// reference doesn't exist yet, it will be created. If it does exist, the first parent
|
/// make it point to this commit. If the reference doesn't exist yet, it will
|
||||||
|
/// be created. If it does exist, the first parent
|
||||||
/// must be the tip of this branch.
|
/// must be the tip of this branch.
|
||||||
///
|
///
|
||||||
/// [author] is the signature with author and author time of commit.
|
/// [author] is the signature with author and author time of commit.
|
||||||
///
|
///
|
||||||
/// [committer] is the signature with committer and commit time of commit.
|
/// [committer] is the signature with committer and commit time of commit.
|
||||||
///
|
///
|
||||||
/// [messageEncoding] is the encoding for the message in the commit, represented with
|
/// [messageEncoding] is the encoding for the message in the commit,
|
||||||
/// a standard encoding name. E.g. "UTF-8". If null, no encoding header is written and
|
/// represented with a standard encoding name. E.g. "UTF-8". If null, no
|
||||||
/// UTF-8 is assumed.
|
/// encoding header is written and UTF-8 is assumed.
|
||||||
///
|
///
|
||||||
/// [message] is the full message for this commit.
|
/// [message] is the full message for this commit.
|
||||||
///
|
///
|
||||||
/// [tree] is an instance of a [Tree] object that will be used as the tree for the commit.
|
/// [tree] is an instance of a [Tree] object that will be used as the tree
|
||||||
/// This tree object must also be owned by the given [repo].
|
/// for the commit.
|
||||||
///
|
///
|
||||||
/// [parents] is a list of [Commit] objects that will be used as the parents for this commit.
|
/// [parents] is a list of [Commit] objects that will be used as the parents
|
||||||
/// This array may be empty if parent count is 0 (root commit). All the given commits must
|
/// for this commit. This list may be empty if parent count is 0 (root
|
||||||
/// be owned by the [repo].
|
/// commit). All the given commits must be owned by the repo.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
Oid createCommit({
|
Oid createCommit({
|
||||||
|
@ -574,17 +599,19 @@ class Repository {
|
||||||
|
|
||||||
/// Amends an existing commit by replacing only non-null values.
|
/// Amends an existing commit by replacing only non-null values.
|
||||||
///
|
///
|
||||||
/// This creates a new commit that is exactly the same as the old commit, except that
|
/// This creates a new commit that is exactly the same as the old commit,
|
||||||
/// any non-null values will be updated. The new commit has the same parents as the old commit.
|
/// except that any non-null values will be updated. The new commit has the
|
||||||
|
/// same parents as the old commit.
|
||||||
///
|
///
|
||||||
/// The [updateRef] value works as in the regular [create], updating the ref to point to
|
/// The [updateRef] value works as in the regular [create], updating the ref
|
||||||
/// the newly rewritten commit. If you want to amend a commit that is not currently
|
/// to point to the newly rewritten commit. If you want to amend a commit
|
||||||
/// the tip of the branch and then rewrite the following commits to reach a ref, pass
|
/// that is not currently the tip of the branch and then rewrite the
|
||||||
/// this as null and update the rest of the commit chain and ref separately.
|
/// following commits to reach a ref, pass this as null and update the rest
|
||||||
|
/// of the commit chain and ref separately.
|
||||||
///
|
///
|
||||||
/// Unlike [create], the [author], [committer], [message], [messageEncoding], and
|
/// Unlike [create], the [author], [committer], [message], [messageEncoding],
|
||||||
/// [tree] arguments can be null in which case this will use the values from the original
|
/// and [tree] arguments can be null in which case this will use the values
|
||||||
/// [commit].
|
/// from the original [commit].
|
||||||
///
|
///
|
||||||
/// All arguments have the same meanings as in [create].
|
/// All arguments have the same meanings as in [create].
|
||||||
///
|
///
|
||||||
|
@ -610,8 +637,8 @@ class Repository {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Reverts provided [revertCommit] against provided [ourCommit], producing an index that
|
/// Reverts provided [revertCommit] against provided [ourCommit], producing
|
||||||
/// reflects the result of the revert.
|
/// an index that reflects the result of the revert.
|
||||||
///
|
///
|
||||||
/// [mainline] is parent of the [revertCommit] if it is a merge (i.e. 1, 2).
|
/// [mainline] is parent of the [revertCommit] if it is a merge (i.e. 1, 2).
|
||||||
///
|
///
|
||||||
|
@ -631,16 +658,18 @@ class Repository {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Finds a single object and intermediate reference (if there is one) by a [spec] revision string.
|
/// Finds a single object and intermediate reference (if there is one) by a
|
||||||
|
/// [spec] revision string.
|
||||||
///
|
///
|
||||||
/// See `man gitrevisions`, or https://git-scm.com/docs/git-rev-parse.html#_specifying_revisions
|
/// See `man gitrevisions`, or https://git-scm.com/docs/git-rev-parse.html#_specifying_revisions
|
||||||
/// for information on the syntax accepted.
|
/// for information on the syntax accepted.
|
||||||
///
|
///
|
||||||
/// In some cases (@{<-n>} or <branchname>@{upstream}), the expression may point to an
|
/// In some cases (@{<-n>} or <branchname>@{upstream}), the expression may
|
||||||
/// intermediate reference. When such expressions are being passed in, reference_out will be
|
/// point to an intermediate reference. When such expressions are being
|
||||||
/// valued as well.
|
/// passed in, reference_out will be valued as well.
|
||||||
///
|
///
|
||||||
/// **IMPORTANT**: the returned object and reference should be released when no longer needed.
|
/// **IMPORTANT**: the returned object and reference should be released when
|
||||||
|
/// no longer needed.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
RevParse revParseExt(String spec) {
|
RevParse revParseExt(String spec) {
|
||||||
|
@ -669,8 +698,9 @@ class Repository {
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
Oid createBlob(String content) => Blob.create(repo: this, content: content);
|
Oid createBlob(String content) => Blob.create(repo: this, content: content);
|
||||||
|
|
||||||
/// Creates a new blob from the file in working directory of a repository and writes
|
/// Creates a new blob from the file in working directory of a repository and
|
||||||
/// it to the ODB. Provided [relativePath] should be relative to the working directory.
|
/// writes it to the ODB. Provided [relativePath] should be relative to the
|
||||||
|
/// working directory.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
Oid createBlobFromWorkdir(String relativePath) {
|
Oid createBlobFromWorkdir(String relativePath) {
|
||||||
|
@ -680,8 +710,8 @@ class Repository {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new blob from the file at provided [path] in filesystem and writes
|
/// Creates a new blob from the file at provided [path] in filesystem and
|
||||||
/// it to the ODB.
|
/// writes it to the ODB.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
Oid createBlobFromDisk(String path) {
|
Oid createBlobFromDisk(String path) {
|
||||||
|
@ -700,8 +730,9 @@ class Repository {
|
||||||
|
|
||||||
/// Creates a new tag in the repository for provided [target] object.
|
/// Creates a new tag in the repository for provided [target] object.
|
||||||
///
|
///
|
||||||
/// A new reference will also be created pointing to this tag object. If [force] is true
|
/// A new reference will also be created pointing to this tag object. If
|
||||||
/// and a reference already exists with the given name, it'll be replaced.
|
/// [force] is true and a reference already exists with the given name, it'll
|
||||||
|
/// be replaced.
|
||||||
///
|
///
|
||||||
/// The [message] will not be cleaned up.
|
/// The [message] will not be cleaned up.
|
||||||
///
|
///
|
||||||
|
@ -709,18 +740,23 @@ class Repository {
|
||||||
/// '~', '^', ':', '\', '?', '[', and '*', and the sequences ".." and "@{" which have
|
/// '~', '^', ':', '\', '?', '[', and '*', and the sequences ".." and "@{" which have
|
||||||
/// special meaning to revparse.
|
/// special meaning to revparse.
|
||||||
///
|
///
|
||||||
/// [tagName] is the name for the tag. This name is validated for consistency. It should
|
/// [tagName] is the name for the tag. This name is validated for
|
||||||
/// also not conflict with an already existing tag name.
|
/// 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].
|
/// [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.
|
/// [targetType] is one of the [GitObject] basic types: commit, tree, blob or
|
||||||
|
/// tag.
|
||||||
///
|
///
|
||||||
/// [tagger] is the signature of the tagger for this tag, and of the tagging time.
|
/// [tagger] is the signature of the tagger for this tag, and of the tagging
|
||||||
|
/// time.
|
||||||
///
|
///
|
||||||
/// [message] is the full message for this tag.
|
/// [message] is the full message for this tag.
|
||||||
///
|
///
|
||||||
/// [force] determines whether existing reference with the same [tagName] should be replaced.
|
/// [force] determines whether existing reference with the same [tagName]
|
||||||
|
/// should be replaced.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
Oid createTag({
|
Oid createTag({
|
||||||
|
@ -865,8 +901,8 @@ class Repository {
|
||||||
.toDartString();
|
.toDartString();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skipping GitStatus.current because entry that is in the list can't be without changes
|
// Skipping GitStatus.current because entry that is in the list can't be
|
||||||
// but `&` on `0` value falsly adds it to the set of flags
|
// without changes but `&` on `0` value falsly adds it to the set of flags
|
||||||
result[path] = GitStatus.values
|
result[path] = GitStatus.values
|
||||||
.skip(1)
|
.skip(1)
|
||||||
.where((e) => entry.ref.status & e.value == e.value)
|
.where((e) => entry.ref.status & e.value == e.value)
|
||||||
|
@ -880,10 +916,11 @@ class Repository {
|
||||||
|
|
||||||
/// Returns file status for a single file at provided [path].
|
/// Returns file status for a single file at provided [path].
|
||||||
///
|
///
|
||||||
/// This does not do any sort of rename detection. Renames require a set of targets and because
|
/// This does not do any sort of rename detection. Renames require a set of
|
||||||
/// of the path filtering, there is not enough information to check renames correctly. To check
|
/// targets and because of the path filtering, there is not enough
|
||||||
/// file status with rename detection, there is no choice but to do a full [status] and scan
|
/// information to check renames correctly. To check file status with rename
|
||||||
/// through looking for the path that you are interested in.
|
/// detection, there is no choice but to do a full [status] and scan through
|
||||||
|
/// looking for the path that you are interested in.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
Set<GitStatus> statusFile(String path) {
|
Set<GitStatus> statusFile(String path) {
|
||||||
|
@ -895,7 +932,8 @@ class Repository {
|
||||||
if (statusInt == GitStatus.current.value) {
|
if (statusInt == GitStatus.current.value) {
|
||||||
return {GitStatus.current};
|
return {GitStatus.current};
|
||||||
} else {
|
} else {
|
||||||
// Skipping GitStatus.current because `&` on `0` value falsly adds it to the set of flags
|
// Skipping GitStatus.current because `&` on `0` value falsly adds it to
|
||||||
|
// the set of flags
|
||||||
return GitStatus.values
|
return GitStatus.values
|
||||||
.skip(1)
|
.skip(1)
|
||||||
.where((e) => statusInt & e.value == e.value)
|
.where((e) => statusInt & e.value == e.value)
|
||||||
|
@ -914,11 +952,12 @@ class Repository {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Analyzes the given branch's [theirHead] oid and determines the opportunities for
|
/// Analyzes the given branch's [theirHead] oid and determines the
|
||||||
/// merging them into [ourRef] reference (default is 'HEAD').
|
/// opportunities for merging them into [ourRef] reference (default is
|
||||||
|
/// 'HEAD').
|
||||||
///
|
///
|
||||||
/// Returns list with analysis result and preference for fast forward merge values
|
/// Returns list with analysis result and preference for fast forward merge
|
||||||
/// respectively.
|
/// values respectively.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
List mergeAnalysis({
|
List mergeAnalysis({
|
||||||
|
@ -950,10 +989,10 @@ class Repository {
|
||||||
return [analysisSet, mergePreference];
|
return [analysisSet, mergePreference];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Merges the given commit [oid] into HEAD, writing the results into the working directory.
|
/// Merges the given commit [oid] into HEAD, writing the results into the
|
||||||
/// Any changes are staged for commit and any conflicts are written to the index. Callers
|
/// working directory. Any changes are staged for commit and any conflicts
|
||||||
/// should inspect the repository's index after this completes, resolve any conflicts and
|
/// are written to the index. Callers should inspect the repository's index
|
||||||
/// prepare a commit.
|
/// after this completes, resolve any conflicts and prepare a commit.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
void merge(Oid oid) {
|
void merge(Oid oid) {
|
||||||
|
@ -989,22 +1028,25 @@ class Repository {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Merges two commits, producing an index that reflects the result of the merge.
|
/// Merges two commits, producing an index that reflects the result of the
|
||||||
/// The index may be written as-is to the working directory or checked out. If the index
|
/// merge. The index may be written as-is to the working directory or checked
|
||||||
/// is to be converted to a tree, the caller should resolve any conflicts that arose as
|
/// out. If the index is to be converted to a tree, the caller should resolve
|
||||||
/// part of the merge.
|
/// any conflicts that arose as part of the merge.
|
||||||
///
|
///
|
||||||
/// [ourCommit] is the commit that reflects the destination tree.
|
/// [ourCommit] is the commit that reflects the destination tree.
|
||||||
///
|
///
|
||||||
/// [theirCommit] is the commit to merge into [ourCommit].
|
/// [theirCommit] is the commit to merge into [ourCommit].
|
||||||
///
|
///
|
||||||
/// [favor] is one of the [GitMergeFileFavor] flags for handling conflicting content. Defaults
|
/// [favor] is one of the [GitMergeFileFavor] flags for handling conflicting
|
||||||
/// to [GitMergeFileFavor.normal], recording conflict to the index.
|
/// content. Defaults to [GitMergeFileFavor.normal], recording conflict to t
|
||||||
|
/// he index.
|
||||||
///
|
///
|
||||||
/// [mergeFlags] is a combination of [GitMergeFlag] flags. Defaults to [GitMergeFlag.findRenames]
|
/// [mergeFlags] is a combination of [GitMergeFlag] flags. Defaults to
|
||||||
/// enabling the ability to merge between a modified and renamed file.
|
/// [GitMergeFlag.findRenames] enabling the ability to merge between a
|
||||||
|
/// modified and renamed file.
|
||||||
///
|
///
|
||||||
/// [fileFlags] is a combination of [GitMergeFileFlag] flags. Defaults to [GitMergeFileFlag.defaults].
|
/// [fileFlags] is a combination of [GitMergeFileFlag] flags. Defaults to
|
||||||
|
/// [GitMergeFileFlag.defaults].
|
||||||
///
|
///
|
||||||
/// **IMPORTANT**: returned index should be freed to release allocated memory.
|
/// **IMPORTANT**: returned index should be freed to release allocated memory.
|
||||||
///
|
///
|
||||||
|
@ -1026,10 +1068,10 @@ class Repository {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Merges two trees, producing an index that reflects the result of the merge.
|
/// Merges two trees, producing an index that reflects the result of the
|
||||||
/// The index may be written as-is to the working directory or checked out. If the index
|
/// merge. The index may be written as-is to the working directory or checked
|
||||||
/// is to be converted to a tree, the caller should resolve any conflicts that arose as part
|
/// out. If the index is to be converted to a tree, the caller should resolve
|
||||||
/// of the merge.
|
/// any conflicts that arose as part of the merge.
|
||||||
///
|
///
|
||||||
/// [ancestorTree] is the common ancestor between the trees, or null if none.
|
/// [ancestorTree] is the common ancestor between the trees, or null if none.
|
||||||
///
|
///
|
||||||
|
@ -1037,13 +1079,16 @@ class Repository {
|
||||||
///
|
///
|
||||||
/// [theirTree] is the tree to merge into [ourTree].
|
/// [theirTree] is the tree to merge into [ourTree].
|
||||||
///
|
///
|
||||||
/// [favor] is one of the [GitMergeFileFavor] flags for handling conflicting content. Defaults
|
/// [favor] is one of the [GitMergeFileFavor] flags for handling conflicting
|
||||||
/// to [GitMergeFileFavor.normal], recording conflict to the index.
|
/// content. Defaults to [GitMergeFileFavor.normal], recording conflict to
|
||||||
|
/// the index.
|
||||||
///
|
///
|
||||||
/// [mergeFlags] is a combination of [GitMergeFlag] flags. Defaults to [GitMergeFlag.findRenames]
|
/// [mergeFlags] is a combination of [GitMergeFlag] flags. Defaults to
|
||||||
/// enabling the ability to merge between a modified and renamed file.
|
/// [GitMergeFlag.findRenames] enabling the ability to merge between a
|
||||||
|
/// modified and renamed file.
|
||||||
///
|
///
|
||||||
/// [fileFlags] is a combination of [GitMergeFileFlag] flags. Defaults to [GitMergeFileFlag.defaults].
|
/// [fileFlags] is a combination of [GitMergeFileFlag] flags. Defaults to
|
||||||
|
/// [GitMergeFileFlag.defaults].
|
||||||
///
|
///
|
||||||
/// **IMPORTANT**: returned index should be freed to release allocated memory.
|
/// **IMPORTANT**: returned index should be freed to release allocated memory.
|
||||||
///
|
///
|
||||||
|
@ -1067,11 +1112,12 @@ class Repository {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Cherry-picks the provided [commit], producing changes in the index and working directory.
|
/// Cherry-picks the provided [commit], producing changes in the index and
|
||||||
|
/// working directory.
|
||||||
///
|
///
|
||||||
/// Any changes are staged for commit and any conflicts are written to the index. Callers
|
/// Any changes are staged for commit and any conflicts are written to the
|
||||||
/// should inspect the repository's index after this completes, resolve any conflicts and
|
/// index. Callers should inspect the repository's index after this
|
||||||
/// prepare a commit.
|
/// completes, resolve any conflicts and prepare a commit.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
void cherryPick(Commit commit) {
|
void cherryPick(Commit commit) {
|
||||||
|
@ -1081,7 +1127,8 @@ class Repository {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checkouts the provided reference [refName] using the given strategy, and update the HEAD.
|
/// Checkouts the provided reference [refName] using the given strategy, and
|
||||||
|
/// update the HEAD.
|
||||||
///
|
///
|
||||||
/// If no reference [refName] is given, checkouts from the index.
|
/// If no reference [refName] is given, checkouts from the index.
|
||||||
///
|
///
|
||||||
|
@ -1090,8 +1137,8 @@ class Repository {
|
||||||
///
|
///
|
||||||
/// [directory] is alternative checkout path to workdir.
|
/// [directory] is alternative checkout path to workdir.
|
||||||
///
|
///
|
||||||
/// [paths] is list of files to checkout from provided reference [refName]. If paths are provided
|
/// [paths] is list of files to checkout from provided reference [refName].
|
||||||
/// HEAD will not be set to the reference [refName].
|
/// If paths are provided HEAD will not be set to the reference [refName].
|
||||||
void checkout({
|
void checkout({
|
||||||
String? refName,
|
String? refName,
|
||||||
Set<GitCheckout> strategy = const {
|
Set<GitCheckout> strategy = const {
|
||||||
|
@ -1140,12 +1187,13 @@ class Repository {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the current head to the specified commit [oid] and optionally resets the index
|
/// Sets the current head to the specified commit [oid] and optionally resets
|
||||||
/// and working tree to match.
|
/// the index and working tree to match.
|
||||||
///
|
///
|
||||||
/// [oid] is the committish to which the HEAD should be moved to. This object can either
|
/// [oid] is the committish to which the HEAD should be moved to. This object
|
||||||
/// be a commit or a tag. When a tag oid is being passed, it should be dereferencable to
|
/// can either be a commit or a tag. When a tag oid is being passed, it
|
||||||
/// a commit which oid will be used as the target of the branch.
|
/// should be dereferencable to a commit which oid will be used as the target
|
||||||
|
/// of the branch.
|
||||||
///
|
///
|
||||||
/// [resetType] is one of the [GitReset] flags.
|
/// [resetType] is one of the [GitReset] flags.
|
||||||
///
|
///
|
||||||
|
@ -1167,11 +1215,11 @@ class Repository {
|
||||||
object_bindings.free(object);
|
object_bindings.free(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a [Diff] with changes between the trees, tree and index, tree and workdir or
|
/// Returns a [Diff] with changes between the trees, tree and index, tree and
|
||||||
/// index and workdir.
|
/// workdir or index and workdir.
|
||||||
///
|
///
|
||||||
/// If [b] is null, by default the [a] tree compared to working directory. If [cached] is
|
/// If [b] is null, by default the [a] tree compared to working directory. If
|
||||||
/// set to true the [a] tree compared to index/staging area.
|
/// [cached] is set to true the [a] tree compared to index/staging area.
|
||||||
///
|
///
|
||||||
/// [flags] is a combination of [GitDiff] flags. Defaults to [GitDiff.normal].
|
/// [flags] is a combination of [GitDiff] flags. Defaults to [GitDiff.normal].
|
||||||
///
|
///
|
||||||
|
@ -1268,8 +1316,9 @@ class Repository {
|
||||||
return a.diff(newBlob: b, oldAsPath: aPath, newAsPath: bPath);
|
return a.diff(newBlob: b, oldAsPath: aPath, newAsPath: bPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Applies the [diff] to the repository, making changes in the provided [location]
|
/// Applies the [diff] to the repository, making changes in the provided
|
||||||
/// (directly in the working directory (default), the index or both).
|
/// [location] (directly in the working directory (default), the index or
|
||||||
|
/// both).
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
void apply({
|
void apply({
|
||||||
|
@ -1283,8 +1332,8 @@ class Repository {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks if the [diff] will apply to provided [location] (the working directory (default),
|
/// Checks if the [diff] will apply to provided [location] (the working
|
||||||
/// the index or both).
|
/// directory (default), the index or both).
|
||||||
bool applies({
|
bool applies({
|
||||||
required Diff diff,
|
required Diff diff,
|
||||||
GitApplyLocation location = GitApplyLocation.workdir,
|
GitApplyLocation location = GitApplyLocation.workdir,
|
||||||
|
@ -1306,7 +1355,8 @@ class Repository {
|
||||||
///
|
///
|
||||||
/// [message] is optional description along with the stashed state.
|
/// [message] is optional description along with the stashed state.
|
||||||
///
|
///
|
||||||
/// [flags] is a combination of [GitStash] flags. Defaults to [GitStash.defaults].
|
/// [flags] is a combination of [GitStash] flags. Defaults to
|
||||||
|
/// [GitStash.defaults].
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
Oid createStash({
|
Oid createStash({
|
||||||
|
@ -1324,19 +1374,20 @@ class Repository {
|
||||||
|
|
||||||
/// Applies a single stashed state from the stash list.
|
/// Applies a single stashed state from the stash list.
|
||||||
///
|
///
|
||||||
/// [index] is the position of the stashed state in the list. Defaults to last saved.
|
/// [index] is the position of the stashed state in the list. Defaults to
|
||||||
|
/// last saved.
|
||||||
///
|
///
|
||||||
/// [reinstateIndex] whether to try to reinstate not only the working tree's changes,
|
/// [reinstateIndex] whether to try to reinstate not only the working tree's
|
||||||
/// but also the index's changes.
|
/// changes, but also the index's changes.
|
||||||
///
|
///
|
||||||
/// [strategy] is a combination of [GitCheckout] flags. Defaults to [GitCheckout.safe]
|
/// [strategy] is a combination of [GitCheckout] flags. Defaults to
|
||||||
/// with [GitCheckout.recreateMissing].
|
/// [GitCheckout.safe] with [GitCheckout.recreateMissing].
|
||||||
///
|
///
|
||||||
/// [directory] is the alternative checkout path to workdir, can be null.
|
/// [directory] is the alternative checkout path to workdir, can be null.
|
||||||
///
|
///
|
||||||
/// [paths] is a list of wildmatch patterns or paths. By default, all paths are processed.
|
/// [paths] is a list of wildmatch patterns or paths. By default, all paths
|
||||||
/// If you pass a list of wildmatch patterns, those will be used to filter which paths
|
/// are processed. If you pass a list of wildmatch patterns, those will be
|
||||||
/// should be taken into account.
|
/// used to filter which paths should be taken into account.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
void applyStash({
|
void applyStash({
|
||||||
|
@ -1359,8 +1410,8 @@ class Repository {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Removes a single stashed state from the stash list at provided [index]. Defaults to
|
/// Removes a single stashed state from the stash list at provided [index].
|
||||||
/// the last saved stash.
|
/// Defaults to the last saved stash.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
void dropStash({int index = 0}) {
|
void dropStash({int index = 0}) {
|
||||||
|
@ -1370,19 +1421,20 @@ class Repository {
|
||||||
/// Applies a single stashed state from the stash list and remove it from
|
/// Applies a single stashed state from the stash list and remove it from
|
||||||
/// the list if successful.
|
/// the list if successful.
|
||||||
///
|
///
|
||||||
/// [index] is the position of the stashed state in the list. Defaults to last saved.
|
/// [index] is the position of the stashed state in the list. Defaults to
|
||||||
|
/// last saved.
|
||||||
///
|
///
|
||||||
/// [reinstateIndex] whether to try to reinstate not only the working tree's changes,
|
/// [reinstateIndex] whether to try to reinstate not only the working tree's
|
||||||
/// but also the index's changes.
|
/// changes, but also the index's changes.
|
||||||
///
|
///
|
||||||
/// [strategy] is a combination of [GitCheckout] flags. Defaults to [GitCheckout.safe]
|
/// [strategy] is a combination of [GitCheckout] flags. Defaults to
|
||||||
/// with [GitCheckout.recreateMissing].
|
/// [GitCheckout.safe] with [GitCheckout.recreateMissing].
|
||||||
///
|
///
|
||||||
/// [directory] is the alternative checkout path to workdir, can be null.
|
/// [directory] is the alternative checkout path to workdir, can be null.
|
||||||
///
|
///
|
||||||
/// [paths] is a list of wildmatch patterns or paths. By default, all paths are processed.
|
/// [paths] is a list of wildmatch patterns or paths. By default, all paths
|
||||||
/// If you pass a list of wildmatch patterns, those will be used to filter which paths
|
/// are processed. If you pass a list of wildmatch patterns, those will be
|
||||||
/// should be taken into account.
|
/// used to filter which paths should be taken into account.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
void popStash({
|
void popStash({
|
||||||
|
@ -1435,7 +1487,8 @@ class Repository {
|
||||||
|
|
||||||
/// Deletes an existing persisted remote with provided [name].
|
/// Deletes an existing persisted remote with provided [name].
|
||||||
///
|
///
|
||||||
/// All remote-tracking branches and configuration settings for the remote will be removed.
|
/// All remote-tracking branches and configuration settings for the remote
|
||||||
|
/// will be removed.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
void deleteRemote(String name) => Remote.delete(repo: this, name: name);
|
void deleteRemote(String name) => Remote.delete(repo: this, name: name);
|
||||||
|
@ -1444,12 +1497,13 @@ class Repository {
|
||||||
///
|
///
|
||||||
/// Returns list of non-default refspecs that cannot be renamed.
|
/// Returns list of non-default refspecs that cannot be renamed.
|
||||||
///
|
///
|
||||||
/// All remote-tracking branches and configuration settings for the remote are updated.
|
/// All remote-tracking branches and configuration settings for the remote
|
||||||
|
/// are updated.
|
||||||
///
|
///
|
||||||
/// The [newName] will be checked for validity.
|
/// The [newName] will be checked for validity.
|
||||||
///
|
///
|
||||||
/// No loaded instances of a the remote with the old name will change their name or
|
/// No loaded instances of a the remote with the old name will change their
|
||||||
/// their list of refspecs.
|
/// name or their list of refspecs.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
List<String> renameRemote({
|
List<String> renameRemote({
|
||||||
|
@ -1461,8 +1515,9 @@ class Repository {
|
||||||
|
|
||||||
/// Lookups the value of one git attribute with provided [name] for [path].
|
/// Lookups the value of one git attribute with provided [name] for [path].
|
||||||
///
|
///
|
||||||
/// Returned value can be either `true`, `false`, `null` (if the attribute was not set at all),
|
/// Returned value can be either `true`, `false`, `null` (if the attribute
|
||||||
/// or a [String] value, if the attribute was set to an actual string.
|
/// was not set at all), or a [String] value, if the attribute was set to an
|
||||||
|
/// actual string.
|
||||||
Object? getAttribute({
|
Object? getAttribute({
|
||||||
required String path,
|
required String path,
|
||||||
required String name,
|
required String name,
|
||||||
|
@ -1480,18 +1535,20 @@ class Repository {
|
||||||
///
|
///
|
||||||
/// [path] is the path to file to consider.
|
/// [path] is the path to file to consider.
|
||||||
///
|
///
|
||||||
/// [flags] is a combination of [GitBlameFlag]s. Defaults to [GitBlameFlag.normal].
|
/// [flags] is a combination of [GitBlameFlag]s. Defaults to
|
||||||
|
/// [GitBlameFlag.normal].
|
||||||
///
|
///
|
||||||
/// [minMatchCharacters] is the lower bound on the number of alphanumeric
|
/// [minMatchCharacters] is the lower bound on the number of alphanumeric
|
||||||
/// characters that must be detected as moving/copying within a file for
|
/// characters that must be detected as moving/copying within a file for
|
||||||
/// it to associate those lines with the parent commit. The default value is 20.
|
/// it to associate those lines with the parent commit. The default value is
|
||||||
/// This value only takes effect if any of the [GitBlameFlag.trackCopies*]
|
/// 20. This value only takes effect if any of the [GitBlameFlag.trackCopies*]
|
||||||
/// flags are specified.
|
/// flags are specified.
|
||||||
///
|
///
|
||||||
/// [newestCommit] is the id of the newest commit to consider. The default is HEAD.
|
/// [newestCommit] is the id of the newest commit to consider. The default is
|
||||||
|
/// HEAD.
|
||||||
///
|
///
|
||||||
/// [oldestCommit] is the id of the oldest commit to consider. The default is the
|
/// [oldestCommit] is the id of the oldest commit to consider. The default is
|
||||||
/// first commit encountered with no parent.
|
/// the first commit encountered with no parent.
|
||||||
///
|
///
|
||||||
/// [minLine] is the first line in the file to blame. The default is 1
|
/// [minLine] is the first line in the file to blame. The default is 1
|
||||||
/// (line numbers start with 1).
|
/// (line numbers start with 1).
|
||||||
|
@ -1610,10 +1667,11 @@ class Repository {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks if a provided [commit] is the descendant of another [ancestor] commit.
|
/// Checks if a provided [commit] is the descendant of another [ancestor]
|
||||||
|
/// commit.
|
||||||
///
|
///
|
||||||
/// Note that a commit is not considered a descendant of itself, in contrast to
|
/// Note that a commit is not considered a descendant of itself, in contrast
|
||||||
/// `git merge-base --is-ancestor`.
|
/// to `git merge-base --is-ancestor`.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
bool descendantOf({required Oid commit, required Oid ancestor}) {
|
bool descendantOf({required Oid commit, required Oid ancestor}) {
|
||||||
|
@ -1624,11 +1682,13 @@ class Repository {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns list with the `ahead` and `behind` number of unique commits respectively.
|
/// Returns list with the `ahead` and `behind` number of unique commits
|
||||||
|
/// respectively.
|
||||||
///
|
///
|
||||||
/// There is no need for branches containing the commits to have any upstream relationship,
|
/// There is no need for branches containing the commits to have any upstream
|
||||||
/// but it helps to think of one as a branch and the other as its upstream, the ahead and
|
/// relationship, but it helps to think of one as a branch and the other as
|
||||||
/// behind values will be what git would report for the branches.
|
/// its upstream, the ahead and behind values will be what git would report
|
||||||
|
/// for the branches.
|
||||||
///
|
///
|
||||||
/// [local] is the commit oid for local.
|
/// [local] is the commit oid for local.
|
||||||
///
|
///
|
||||||
|
@ -1646,28 +1706,29 @@ class Repository {
|
||||||
|
|
||||||
/// Describes a [commit] if provided or the current worktree.
|
/// Describes a [commit] if provided or the current worktree.
|
||||||
///
|
///
|
||||||
/// [maxCandidatesTags] is the number of candidate tags to consider. Increasing above 10 will
|
/// [maxCandidatesTags] is the number of candidate tags to consider.
|
||||||
/// take slightly longer but may produce a more accurate result. A value of 0 will cause
|
/// Increasing above 10 will take slightly longer but may produce a more
|
||||||
/// only exact matches to be output. Default is 10.
|
/// accurate result. A value of 0 will cause only exact matches to be output.
|
||||||
|
/// Default is 10.
|
||||||
///
|
///
|
||||||
/// [describeStrategy] is reference lookup strategy that is one of [GitDescribeStrategy].
|
/// [describeStrategy] is reference lookup strategy that is one of
|
||||||
/// Default matches only annotated tags.
|
/// [GitDescribeStrategy]. Default matches only annotated tags.
|
||||||
///
|
///
|
||||||
/// [pattern] is pattern to use for tags matching, excluding the "refs/tags/" prefix.
|
/// [pattern] is pattern to use for tags matching, excluding the "refs/tags/" prefix.
|
||||||
///
|
///
|
||||||
/// [onlyFollowFirstParent] checks whether or not to follow only the first parent
|
/// [onlyFollowFirstParent] checks whether or not to follow only the first
|
||||||
/// commit upon seeing a merge commit.
|
/// parent commit upon seeing a merge commit.
|
||||||
///
|
///
|
||||||
/// [showCommitOidAsFallback] determines if full id of the commit should be shown
|
/// [showCommitOidAsFallback] determines if full id of the commit should be
|
||||||
/// if no matching tag or reference is found.
|
/// shown if no matching tag or reference is found.
|
||||||
///
|
///
|
||||||
/// [abbreviatedSize] is the minimum number of hexadecimal digits to show for abbreviated
|
/// [abbreviatedSize] is the minimum number of hexadecimal digits to show for
|
||||||
/// object names. A value of 0 will suppress long format, only showing the closest tag.
|
/// abbreviated object names. A value of 0 will suppress long format, only
|
||||||
/// Default is 7.
|
/// showing the closest tag. Default is 7.
|
||||||
///
|
///
|
||||||
/// [alwaysUseLongFormat] determines if he long format (the nearest tag, the number of
|
/// [alwaysUseLongFormat] determines if he long format (the nearest tag, the
|
||||||
/// commits, and the abbrevated commit name) should be used even when the commit matches
|
/// number of commits, and the abbrevated commit name) should be used even
|
||||||
/// the tag.
|
/// when the commit matches the tag.
|
||||||
///
|
///
|
||||||
/// [dirtySuffix] is a string to append if the working tree is dirty.
|
/// [dirtySuffix] is a string to append if the working tree is dirty.
|
||||||
///
|
///
|
||||||
|
@ -1718,15 +1779,16 @@ class Repository {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Packs the objects in the odb chosen by the [packDelegate] function and
|
/// Packs the objects in the odb chosen by the [packDelegate] function and
|
||||||
/// writes ".pack" and ".idx" files for them into provided [path] or default location.
|
/// writes ".pack" and ".idx" files for them into provided [path] or default
|
||||||
|
/// location.
|
||||||
///
|
///
|
||||||
/// Returns the number of objects written to the pack.
|
/// Returns the number of objects written to the pack.
|
||||||
///
|
///
|
||||||
/// [packDelegate] is a function that will provide what objects should be added to the
|
/// [packDelegate] is a function that will provide what objects should be
|
||||||
/// pack builder. Default is add all objects.
|
/// added to the pack builder. Default is add all objects.
|
||||||
///
|
///
|
||||||
/// [threads] is number of threads the PackBuilder will spawn. Default is none. 0 will
|
/// [threads] is number of threads the PackBuilder will spawn. Default is
|
||||||
/// let libgit2 to autodetect number of CPUs.
|
/// none. 0 will let libgit2 to autodetect number of CPUs.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
int pack({
|
int pack({
|
||||||
|
@ -1758,7 +1820,8 @@ class Repository {
|
||||||
/// List with all tracked submodules paths of a repository.
|
/// List with all tracked submodules paths of a repository.
|
||||||
List<String> get submodules => Submodule.list(this);
|
List<String> get submodules => Submodule.list(this);
|
||||||
|
|
||||||
/// Lookups submodule information by [name] or path (they are usually the same).
|
/// Lookups submodule information by [name] or path (they are usually the
|
||||||
|
/// same).
|
||||||
///
|
///
|
||||||
/// **IMPORTANT**: Should be freed to release allocated memory.
|
/// **IMPORTANT**: Should be freed to release allocated memory.
|
||||||
///
|
///
|
||||||
|
@ -1772,8 +1835,8 @@ class Repository {
|
||||||
/// Just like `git submodule init`, this copies information about the
|
/// Just like `git submodule init`, this copies information about the
|
||||||
/// submodule into ".git/config".
|
/// submodule into ".git/config".
|
||||||
///
|
///
|
||||||
/// By default, existing entries will not be overwritten, but setting [overwrite]
|
/// By default, existing entries will not be overwritten, but setting
|
||||||
/// to true forces them to be updated.
|
/// [overwrite] to true forces them to be updated.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
void initSubmodule({
|
void initSubmodule({
|
||||||
|
@ -1784,14 +1847,14 @@ class Repository {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Updates a submodule. This will clone a missing submodule and checkout the
|
/// Updates a submodule. This will clone a missing submodule and checkout the
|
||||||
/// subrepository to the commit specified in the index of the containing repository.
|
/// subrepository to the commit specified in the index of the containing
|
||||||
/// If the submodule repository doesn't contain the target commit (e.g. because
|
/// repository. If the submodule repository doesn't contain the target commit
|
||||||
/// fetchRecurseSubmodules isn't set), then the submodule is fetched using the fetch
|
/// (e.g. because fetchRecurseSubmodules isn't set), then the submodule is
|
||||||
/// options supplied in [callbacks].
|
/// fetched using the fetch options supplied in [callbacks].
|
||||||
///
|
///
|
||||||
/// If the submodule is not initialized, setting [init] to true will initialize the
|
/// If the submodule is not initialized, setting [init] to true will
|
||||||
/// submodule before updating. Otherwise, this will return an error if attempting
|
/// initialize the submodule before updating. Otherwise, this will return an
|
||||||
/// to update an uninitialzed repository.
|
/// error if attempting to update an uninitialzed repository.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
void updateSubmodule({
|
void updateSubmodule({
|
||||||
|
@ -1816,7 +1879,8 @@ class Repository {
|
||||||
/// [useGitLink] determines if workdir should contain a gitlink to the repo in `.git/modules`
|
/// [useGitLink] determines if workdir should contain a gitlink to the repo in `.git/modules`
|
||||||
/// vs. repo directly in workdir. Default is true.
|
/// vs. repo directly in workdir. Default is true.
|
||||||
///
|
///
|
||||||
/// [callbacks] is the combination of callback functions from [Callbacks] object.
|
/// [callbacks] is the combination of callback functions from [Callbacks]
|
||||||
|
/// object.
|
||||||
///
|
///
|
||||||
/// **IMPORTANT**: Should be freed to release allocated memory.
|
/// **IMPORTANT**: Should be freed to release allocated memory.
|
||||||
///
|
///
|
||||||
|
@ -1852,8 +1916,8 @@ class Repository {
|
||||||
|
|
||||||
/// Creates new worktree.
|
/// Creates new worktree.
|
||||||
///
|
///
|
||||||
/// If [ref] is provided, no new branch will be created but specified [ref] will
|
/// If [ref] is provided, no new branch will be created but specified [ref]
|
||||||
/// be used instead.
|
/// will be used instead.
|
||||||
///
|
///
|
||||||
/// [name] is the name of the working tree.
|
/// [name] is the name of the working tree.
|
||||||
///
|
///
|
||||||
|
|
|
@ -4,16 +4,18 @@ import 'bindings/libgit2_bindings.dart';
|
||||||
import 'bindings/revparse.dart' as bindings;
|
import 'bindings/revparse.dart' as bindings;
|
||||||
|
|
||||||
class RevParse {
|
class RevParse {
|
||||||
/// Finds a single object and intermediate reference (if there is one) by a [spec] revision string.
|
/// Finds a single object and intermediate reference (if there is one) by a
|
||||||
|
/// [spec] revision string.
|
||||||
///
|
///
|
||||||
/// See `man gitrevisions`, or https://git-scm.com/docs/git-rev-parse.html#_specifying_revisions
|
/// See `man gitrevisions`, or https://git-scm.com/docs/git-rev-parse.html#_specifying_revisions
|
||||||
/// for information on the syntax accepted.
|
/// for information on the syntax accepted.
|
||||||
///
|
///
|
||||||
/// In some cases (@{<-n>} or <branchname>@{upstream}), the expression may point to an
|
/// In some cases (@{<-n>} or <branchname>@{upstream}), the expression may
|
||||||
/// intermediate reference. When such expressions are being passed in, reference_out will be
|
/// point to an intermediate reference. When such expressions are being
|
||||||
/// valued as well.
|
/// passed in, reference_out will be valued as well.
|
||||||
///
|
///
|
||||||
/// **IMPORTANT**: The returned object and reference should be freed to release allocated memory.
|
/// **IMPORTANT**: The returned object and reference should be freed to
|
||||||
|
/// release allocated memory.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
RevParse.ext({required Repository repo, required String spec}) {
|
RevParse.ext({required Repository repo, required String spec}) {
|
||||||
|
|
|
@ -39,10 +39,11 @@ class RevWalk {
|
||||||
|
|
||||||
/// Adds a new root commit [oid] for the traversal.
|
/// Adds a new root commit [oid] for the traversal.
|
||||||
///
|
///
|
||||||
/// The pushed commit will be marked as one of the roots from which to start the walk.
|
/// The pushed commit will be marked as one of the roots from which to start
|
||||||
/// This commit may not be walked if it or a child is hidden.
|
/// the walk. This commit may not be walked if it or a child is hidden.
|
||||||
///
|
///
|
||||||
/// At least one commit must be pushed onto the walker before a walk can be started.
|
/// At least one commit must be pushed onto the walker before a walk can be
|
||||||
|
/// started.
|
||||||
///
|
///
|
||||||
/// The given [oid] must belong to a committish on the walked repository.
|
/// The given [oid] must belong to a committish on the walked repository.
|
||||||
///
|
///
|
||||||
|
@ -58,7 +59,8 @@ class RevWalk {
|
||||||
///
|
///
|
||||||
/// The given id must belong to a committish on the walked repository.
|
/// The given id must belong to a committish on the walked repository.
|
||||||
///
|
///
|
||||||
/// The resolved commit and all its parents will be hidden from the output on the revision walk.
|
/// The resolved commit and all its parents will be hidden from the output on
|
||||||
|
/// the revision walk.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
void hide(Oid oid) {
|
void hide(Oid oid) {
|
||||||
|
@ -70,8 +72,9 @@ class RevWalk {
|
||||||
|
|
||||||
/// Resets the revision walker for reuse.
|
/// Resets the revision walker for reuse.
|
||||||
///
|
///
|
||||||
/// This will clear all the pushed and hidden commits, and leave the walker in a blank state
|
/// This will clear all the pushed and hidden commits, and leave the walker
|
||||||
/// (just like at creation) ready to receive new commit pushes and start a new walk.
|
/// in a blank state (just like at creation) ready to receive new commit
|
||||||
|
/// pushes and start a new walk.
|
||||||
///
|
///
|
||||||
/// The revision walk is automatically reset when a walk is over.
|
/// The revision walk is automatically reset when a walk is over.
|
||||||
void reset() => bindings.reset(_revWalkPointer);
|
void reset() => bindings.reset(_revWalkPointer);
|
||||||
|
|
|
@ -15,7 +15,8 @@ class Signature {
|
||||||
/// Creates new [Signature] from provided [name], [email], and optional [time]
|
/// Creates new [Signature] from provided [name], [email], and optional [time]
|
||||||
/// in seconds from epoch and [offset] in minutes.
|
/// in seconds from epoch and [offset] in minutes.
|
||||||
///
|
///
|
||||||
/// If [time] isn't provided [Signature] will be created with a timestamp of 'now'.
|
/// If [time] isn't provided [Signature] will be created with a timestamp of
|
||||||
|
/// 'now'.
|
||||||
///
|
///
|
||||||
/// **IMPORTANT**: Should be freed to release allocated memory.
|
/// **IMPORTANT**: Should be freed to release allocated memory.
|
||||||
Signature.create({
|
Signature.create({
|
||||||
|
@ -45,8 +46,9 @@ class Signature {
|
||||||
|
|
||||||
/// Creates a new action signature with default user and now timestamp.
|
/// Creates a new action signature with default user and now timestamp.
|
||||||
///
|
///
|
||||||
/// This looks up the user.name and user.email from the configuration and uses the
|
/// This looks up the user.name and user.email from the configuration and
|
||||||
/// current time as the timestamp, and creates a new signature based on that information.
|
/// uses the current time as the timestamp, and creates a new signature based
|
||||||
|
/// on that information.
|
||||||
static Signature defaultSignature(Repository repo) =>
|
static Signature defaultSignature(Repository repo) =>
|
||||||
Signature(bindings.defaultSignature(repo.pointer));
|
Signature(bindings.defaultSignature(repo.pointer));
|
||||||
|
|
||||||
|
@ -82,6 +84,7 @@ class Signature {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'Signature{name: $name, email: $email, time: $time, offset: $offset}';
|
return 'Signature{name: $name, email: $email, time: $time, '
|
||||||
|
'offset: $offset}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,8 @@ import 'package:libgit2dart/libgit2dart.dart';
|
||||||
import 'bindings/stash.dart' as bindings;
|
import 'bindings/stash.dart' as bindings;
|
||||||
|
|
||||||
class Stash {
|
class Stash {
|
||||||
/// Initializes a new instance of [Stash] class from provided stash [index], [message]
|
/// Initializes a new instance of [Stash] class from provided stash [index],
|
||||||
/// and [oid].
|
/// [message] and [oid].
|
||||||
const Stash({
|
const Stash({
|
||||||
required this.index,
|
required this.index,
|
||||||
required this.message,
|
required this.message,
|
||||||
|
@ -30,7 +30,8 @@ class Stash {
|
||||||
///
|
///
|
||||||
/// [message] is optional description along with the stashed state.
|
/// [message] is optional description along with the stashed state.
|
||||||
///
|
///
|
||||||
/// [flags] is a combination of [GitStash] flags. Defaults to [GitStash.defaults].
|
/// [flags] is a combination of [GitStash] flags. Defaults to
|
||||||
|
/// [GitStash.defaults].
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
static Oid create({
|
static Oid create({
|
||||||
|
@ -51,19 +52,20 @@ class Stash {
|
||||||
|
|
||||||
/// Applies a single stashed state from the stash list.
|
/// Applies a single stashed state from the stash list.
|
||||||
///
|
///
|
||||||
/// [index] is the position of the stashed state in the list. Defaults to last saved.
|
/// [index] is the position of the stashed state in the list. Defaults to
|
||||||
|
/// last saved.
|
||||||
///
|
///
|
||||||
/// [reinstateIndex] whether to try to reinstate not only the working tree's changes,
|
/// [reinstateIndex] whether to try to reinstate not only the working tree's
|
||||||
/// but also the index's changes.
|
/// changes, but also the index's changes.
|
||||||
///
|
///
|
||||||
/// [strategy] is a combination of [GitCheckout] flags. Defaults to [GitCheckout.safe]
|
/// [strategy] is a combination of [GitCheckout] flags. Defaults to
|
||||||
/// with [GitCheckout.recreateMissing].
|
/// [GitCheckout.safe] with [GitCheckout.recreateMissing].
|
||||||
///
|
///
|
||||||
/// [directory] is the alternative checkout path to workdir, can be null.
|
/// [directory] is the alternative checkout path to workdir, can be null.
|
||||||
///
|
///
|
||||||
/// [paths] is a list of wildmatch patterns or paths. By default, all paths are processed.
|
/// [paths] is a list of wildmatch patterns or paths. By default, all paths
|
||||||
/// If you pass a list of wildmatch patterns, those will be used to filter which paths
|
/// are processed. If you pass a list of wildmatch patterns, those will be
|
||||||
/// should be taken into account.
|
/// used to filter which paths should be taken into account.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
static void apply({
|
static void apply({
|
||||||
|
@ -87,8 +89,8 @@ class Stash {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Removes a single stashed state from the stash list at provided [index]. Defaults to
|
/// Removes a single stashed state from the stash list at provided [index].
|
||||||
/// the last saved stash.
|
/// Defaults to the last saved stash.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
static void drop({required Repository repo, int index = 0}) {
|
static void drop({required Repository repo, int index = 0}) {
|
||||||
|
@ -101,19 +103,20 @@ class Stash {
|
||||||
/// Applies a single stashed state from the stash list and remove it from
|
/// Applies a single stashed state from the stash list and remove it from
|
||||||
/// the list if successful.
|
/// the list if successful.
|
||||||
///
|
///
|
||||||
/// [index] is the position of the stashed state in the list. Defaults to last saved.
|
/// [index] is the position of the stashed state in the list. Defaults to
|
||||||
|
/// last saved.
|
||||||
///
|
///
|
||||||
/// [reinstateIndex] whether to try to reinstate not only the working tree's changes,
|
/// [reinstateIndex] whether to try to reinstate not only the working tree's
|
||||||
/// but also the index's changes.
|
/// changes, but also the index's changes.
|
||||||
///
|
///
|
||||||
/// [strategy] is a combination of [GitCheckout] flags. Defaults to [GitCheckout.safe]
|
/// [strategy] is a combination of [GitCheckout] flags. Defaults to
|
||||||
/// with [GitCheckout.recreateMissing].
|
/// [GitCheckout.safe] with [GitCheckout.recreateMissing].
|
||||||
///
|
///
|
||||||
/// [directory] is the alternative checkout path to workdir, can be null.
|
/// [directory] is the alternative checkout path to workdir, can be null.
|
||||||
///
|
///
|
||||||
/// [paths] is a list of wildmatch patterns or paths. By default, all paths are processed.
|
/// [paths] is a list of wildmatch patterns or paths. By default, all paths
|
||||||
/// If you pass a list of wildmatch patterns, those will be used to filter which paths
|
/// are processed. If you pass a list of wildmatch patterns, those will be
|
||||||
/// should be taken into account.
|
/// used to filter which paths should be taken into account.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
static void pop({
|
static void pop({
|
||||||
|
|
|
@ -4,7 +4,8 @@ import 'bindings/libgit2_bindings.dart';
|
||||||
import 'bindings/submodule.dart' as bindings;
|
import 'bindings/submodule.dart' as bindings;
|
||||||
|
|
||||||
class Submodule {
|
class Submodule {
|
||||||
/// Lookups submodule information by [name] or path (they are usually the same).
|
/// Lookups submodule information by [name] or path (they are usually the
|
||||||
|
/// same).
|
||||||
///
|
///
|
||||||
/// **IMPORTANT**: Should be freed to release allocated memory.
|
/// **IMPORTANT**: Should be freed to release allocated memory.
|
||||||
///
|
///
|
||||||
|
@ -25,7 +26,8 @@ class Submodule {
|
||||||
/// [useGitLink] determines if workdir should contain a gitlink to the repo in `.git/modules`
|
/// [useGitLink] determines if workdir should contain a gitlink to the repo in `.git/modules`
|
||||||
/// vs. repo directly in workdir. Default is true.
|
/// vs. repo directly in workdir. Default is true.
|
||||||
///
|
///
|
||||||
/// [callbacks] is the combination of callback functions from [Callbacks] object.
|
/// [callbacks] is the combination of callback functions from [Callbacks]
|
||||||
|
/// object.
|
||||||
///
|
///
|
||||||
/// **IMPORTANT**: Should be freed to release allocated memory.
|
/// **IMPORTANT**: Should be freed to release allocated memory.
|
||||||
///
|
///
|
||||||
|
@ -57,8 +59,8 @@ class Submodule {
|
||||||
/// Just like `git submodule init`, this copies information about the
|
/// Just like `git submodule init`, this copies information about the
|
||||||
/// submodule into ".git/config".
|
/// submodule into ".git/config".
|
||||||
///
|
///
|
||||||
/// By default, existing entries will not be overwritten, but setting [overwrite]
|
/// By default, existing entries will not be overwritten, but setting
|
||||||
/// to true forces them to be updated.
|
/// [overwrite] to true forces them to be updated.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
static void init({
|
static void init({
|
||||||
|
@ -77,14 +79,14 @@ class Submodule {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Updates a submodule. This will clone a missing submodule and checkout the
|
/// Updates a submodule. This will clone a missing submodule and checkout the
|
||||||
/// subrepository to the commit specified in the index of the containing repository.
|
/// subrepository to the commit specified in the index of the containing
|
||||||
/// If the submodule repository doesn't contain the target commit (e.g. because
|
/// repository. If the submodule repository doesn't contain the target commit
|
||||||
/// fetchRecurseSubmodules isn't set), then the submodule is fetched using the fetch
|
/// (e.g. because fetchRecurseSubmodules isn't set), then the submodule is
|
||||||
/// options supplied in [callbacks].
|
/// fetched using the fetch options supplied in [callbacks].
|
||||||
///
|
///
|
||||||
/// If the submodule is not initialized, setting [init] to true will initialize the
|
/// If the submodule is not initialized, setting [init] to true will
|
||||||
/// submodule before updating. Otherwise, this will return an error if attempting
|
/// initialize the submodule before updating. Otherwise, this will return an
|
||||||
/// to update an uninitialzed repository.
|
/// error if attempting to update an uninitialzed repository.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
static void update({
|
static void update({
|
||||||
|
@ -112,11 +114,14 @@ class Submodule {
|
||||||
|
|
||||||
/// Opens the repository for a submodule.
|
/// Opens the repository for a submodule.
|
||||||
///
|
///
|
||||||
/// Multiple calls to this function will return distinct git repository objects.
|
/// Multiple calls to this function will return distinct git repository
|
||||||
|
/// objects.
|
||||||
///
|
///
|
||||||
/// This will only work if the submodule is checked out into the working directory.
|
/// This will only work if the submodule is checked out into the working
|
||||||
|
/// directory.
|
||||||
///
|
///
|
||||||
/// **IMPORTANT**: Returned [Repository] object should be freed to release allocated memory.
|
/// **IMPORTANT**: Returned [Repository] object should be freed to release
|
||||||
|
/// allocated memory.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
Repository open() {
|
Repository open() {
|
||||||
|
@ -125,9 +130,9 @@ class Submodule {
|
||||||
|
|
||||||
/// Returns the status for a submodule.
|
/// Returns the status for a submodule.
|
||||||
///
|
///
|
||||||
/// This looks at a submodule and tries to determine the status. How deeply it examines
|
/// This looks at a submodule and tries to determine the status. How deeply
|
||||||
/// the working directory to do this will depend on the combination of [GitSubmoduleIgnore]
|
/// it examines the working directory to do this will depend on the
|
||||||
/// values provided to [ignore] .
|
/// combination of [GitSubmoduleIgnore] values provided to [ignore] .
|
||||||
Set<GitSubmoduleStatus> status({
|
Set<GitSubmoduleStatus> status({
|
||||||
GitSubmoduleIgnore ignore = GitSubmoduleIgnore.unspecified,
|
GitSubmoduleIgnore ignore = GitSubmoduleIgnore.unspecified,
|
||||||
}) {
|
}) {
|
||||||
|
@ -144,16 +149,16 @@ class Submodule {
|
||||||
|
|
||||||
/// Copies submodule remote info into submodule repo.
|
/// Copies submodule remote info into submodule repo.
|
||||||
///
|
///
|
||||||
/// This copies the information about the submodules URL into the checked out submodule
|
/// This copies the information about the submodules URL into the checked out
|
||||||
/// config, acting like `git submodule sync`. This is useful if you have altered the URL
|
/// submodule config, acting like `git submodule sync`. This is useful if you
|
||||||
/// for the submodule (or it has been altered by a fetch of upstream changes) and you
|
/// have altered the URL for the submodule (or it has been altered by a fetch
|
||||||
/// need to update your local repo.
|
/// of upstream changes) and you need to update your local repo.
|
||||||
void sync() => bindings.sync(_submodulePointer);
|
void sync() => bindings.sync(_submodulePointer);
|
||||||
|
|
||||||
/// Rereads submodule info from config, index, and HEAD.
|
/// Rereads submodule info from config, index, and HEAD.
|
||||||
///
|
///
|
||||||
/// Call this to reread cached submodule information for this submodule if you have
|
/// Call this to reread cached submodule information for this submodule if
|
||||||
/// reason to believe that it has changed.
|
/// you have reason to believe that it has changed.
|
||||||
///
|
///
|
||||||
/// Set [force] to true to reload even if the data doesn't seem out of date.
|
/// Set [force] to true to reload even if the data doesn't seem out of date.
|
||||||
void reload({bool force = false}) {
|
void reload({bool force = false}) {
|
||||||
|
@ -199,26 +204,27 @@ class Submodule {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// [Oid] for the submodule in the current HEAD tree or null if submodule is not
|
/// [Oid] for the submodule in the current HEAD tree or null if submodule is
|
||||||
/// in the HEAD.
|
/// not in the HEAD.
|
||||||
Oid? get headOid {
|
Oid? get headOid {
|
||||||
final result = bindings.headId(_submodulePointer);
|
final result = bindings.headId(_submodulePointer);
|
||||||
return result == null ? null : Oid(result);
|
return result == null ? null : Oid(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// [Oid] for the submodule in the index or null if submodule is not in the index.
|
/// [Oid] for the submodule in the index or null if submodule is not in the
|
||||||
|
/// index.
|
||||||
Oid? get indexOid {
|
Oid? get indexOid {
|
||||||
final result = bindings.indexId(_submodulePointer);
|
final result = bindings.indexId(_submodulePointer);
|
||||||
return result == null ? null : Oid(result);
|
return result == null ? null : Oid(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// [Oid] for the submodule in the current working directory or null if submodule
|
/// [Oid] for the submodule in the current working directory or null if
|
||||||
/// is not checked out.
|
/// submodule is not checked out.
|
||||||
///
|
///
|
||||||
/// This returns the [Oid] that corresponds to looking up `HEAD` in the checked out
|
/// This returns the [Oid] that corresponds to looking up `HEAD` in the
|
||||||
/// submodule. If there are pending changes in the index or anything else, this
|
/// checked out submodule. If there are pending changes in the index or
|
||||||
/// won't notice that. You should call [status] for a more complete picture about
|
/// anything else, this won't notice that. You should call [status] for a
|
||||||
/// the state of the working directory.
|
/// more complete picture about the state of the working directory.
|
||||||
Oid? get workdirOid {
|
Oid? get workdirOid {
|
||||||
final result = bindings.workdirId(_submodulePointer);
|
final result = bindings.workdirId(_submodulePointer);
|
||||||
return result == null ? null : Oid(result);
|
return result == null ? null : Oid(result);
|
||||||
|
@ -263,7 +269,7 @@ class Submodule {
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'Submodule{name: $name, path: $path, url: $url, status: $status, '
|
return 'Submodule{name: $name, path: $path, url: $url, status: $status, '
|
||||||
'branch: $branch, headOid: $headOid, indexOid: $indexOid, workdirOid: $workdirOid, '
|
'branch: $branch, headOid: $headOid, indexOid: $indexOid, '
|
||||||
'ignore: $ignore, updateRule: $updateRule}';
|
'workdirOid: $workdirOid, ignore: $ignore, updateRule: $updateRule}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,8 +28,9 @@ class Tag {
|
||||||
|
|
||||||
/// Creates a new tag in the repository for provided [target] object.
|
/// Creates a new tag in the repository for provided [target] object.
|
||||||
///
|
///
|
||||||
/// A new reference will also be created pointing to this tag object. If [force] is true
|
/// A new reference will also be created pointing to this tag object. If
|
||||||
/// and a reference already exists with the given name, it'll be replaced.
|
/// [force] is true and a reference already exists with the given name, it'll
|
||||||
|
/// be replaced.
|
||||||
///
|
///
|
||||||
/// The [message] will not be cleaned up.
|
/// The [message] will not be cleaned up.
|
||||||
///
|
///
|
||||||
|
@ -39,18 +40,23 @@ class Tag {
|
||||||
///
|
///
|
||||||
/// [repo] is the repository where to store the tag.
|
/// [repo] is the repository where to store the tag.
|
||||||
///
|
///
|
||||||
/// [tagName] is the name for the tag. This name is validated for consistency. It should
|
/// [tagName] is the name for the tag. This name is validated for
|
||||||
/// also not conflict with an already existing tag name.
|
/// 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].
|
/// [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.
|
/// [targetType] is one of the [GitObject] basic types: commit, tree, blob or
|
||||||
|
/// tag.
|
||||||
///
|
///
|
||||||
/// [tagger] is the signature of the tagger for this tag, and of the tagging time.
|
/// [tagger] is the signature of the tagger for this tag, and of the tagging
|
||||||
|
/// time.
|
||||||
///
|
///
|
||||||
/// [message] is the full message for this tag.
|
/// [message] is the full message for this tag.
|
||||||
///
|
///
|
||||||
/// [force] determines whether existing reference with the same [tagName] should be replaced.
|
/// [force] determines whether existing reference with the same [tagName]
|
||||||
|
/// should be replaced.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
static Oid create({
|
static Oid create({
|
||||||
|
@ -100,9 +106,14 @@ class Tag {
|
||||||
|
|
||||||
/// Tagged object (commit, tree, blob, tag) of a tag.
|
/// Tagged object (commit, tree, blob, tag) of a tag.
|
||||||
///
|
///
|
||||||
/// This method performs a repository lookup for the given object and returns it.
|
/// This method performs a repository lookup for the given object and returns
|
||||||
|
/// it.
|
||||||
///
|
///
|
||||||
/// Returned object should be explicitly downcasted to one of four of git object types.
|
/// Returned object should be explicitly downcasted to one of four of git
|
||||||
|
/// object types.
|
||||||
|
///
|
||||||
|
/// **IMPORTANT**: returned object should be freed to release allocated
|
||||||
|
/// memory.
|
||||||
///
|
///
|
||||||
/// ```dart
|
/// ```dart
|
||||||
/// final commit = tag.target as Commit;
|
/// final commit = tag.target as Commit;
|
||||||
|
@ -151,6 +162,7 @@ class Tag {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'Tag{oid: $oid, name: $name, message: $message, target: $target, tagger: $tagger}';
|
return 'Tag{oid: $oid, name: $name, message: $message, target: $target, '
|
||||||
|
'tagger: $tagger}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,8 @@ class Tree {
|
||||||
|
|
||||||
/// Lookups a tree entry in the tree.
|
/// Lookups a tree entry in the tree.
|
||||||
///
|
///
|
||||||
/// If integer [value] is provided, lookup is done by entry position in the tree.
|
/// If integer [value] is provided, lookup is done by entry position in the
|
||||||
|
/// tree.
|
||||||
///
|
///
|
||||||
/// If string [value] is provided, lookup is done by entry filename.
|
/// If string [value] is provided, lookup is done by entry filename.
|
||||||
///
|
///
|
||||||
|
|
|
@ -44,8 +44,8 @@ class TreeBuilder {
|
||||||
|
|
||||||
/// Adds or updates an entry to the tree builder with the given attributes.
|
/// Adds or updates an entry to the tree builder with the given attributes.
|
||||||
///
|
///
|
||||||
/// If an entry with [filename] already exists, its attributes will be updated with
|
/// If an entry with [filename] already exists, its attributes will be
|
||||||
/// the given ones.
|
/// updated with the given ones.
|
||||||
///
|
///
|
||||||
/// By default the entry that you are inserting will be checked for validity;
|
/// By default the entry that you are inserting will be checked for validity;
|
||||||
/// that it exists in the object database and is of the correct type.
|
/// that it exists in the object database and is of the correct type.
|
||||||
|
|
|
@ -6,8 +6,8 @@ import 'bindings/worktree.dart' as bindings;
|
||||||
class Worktree {
|
class Worktree {
|
||||||
/// Creates new worktree.
|
/// Creates new worktree.
|
||||||
///
|
///
|
||||||
/// If [ref] is provided, no new branch will be created but specified [ref] will
|
/// If [ref] is provided, no new branch will be created but specified [ref]
|
||||||
/// be used instead.
|
/// will be used instead.
|
||||||
///
|
///
|
||||||
/// [repo] is the repository to create working tree for.
|
/// [repo] is the repository to create working tree for.
|
||||||
///
|
///
|
||||||
|
@ -57,8 +57,8 @@ class Worktree {
|
||||||
|
|
||||||
/// Whether worktree is locked.
|
/// Whether worktree is locked.
|
||||||
///
|
///
|
||||||
/// A worktree may be locked if the linked working tree is stored on a portable
|
/// A worktree may be locked if the linked working tree is stored on a
|
||||||
/// device which is not available.
|
/// portable device which is not available.
|
||||||
bool get isLocked => bindings.isLocked(_worktreePointer);
|
bool get isLocked => bindings.isLocked(_worktreePointer);
|
||||||
|
|
||||||
/// Locks worktree if not already locked.
|
/// Locks worktree if not already locked.
|
||||||
|
@ -83,8 +83,8 @@ class Worktree {
|
||||||
|
|
||||||
/// Whether worktree is valid.
|
/// Whether worktree is valid.
|
||||||
///
|
///
|
||||||
/// A valid worktree requires both the git data structures inside the linked parent
|
/// A valid worktree requires both the git data structures inside the linked
|
||||||
/// repository and the linked working copy to be present.
|
/// parent repository and the linked working copy to be present.
|
||||||
bool get isValid => bindings.isValid(_worktreePointer);
|
bool get isValid => bindings.isValid(_worktreePointer);
|
||||||
|
|
||||||
/// Releases memory allocated for worktree object.
|
/// Releases memory allocated for worktree object.
|
||||||
|
|
|
@ -98,8 +98,8 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test(
|
test(
|
||||||
'successfully gets the blame for provided file with minMatchCharacters set',
|
'successfully gets the blame for provided file with '
|
||||||
() {
|
'minMatchCharacters set', () {
|
||||||
final blame = repo.blame(
|
final blame = repo.blame(
|
||||||
path: 'feature_file',
|
path: 'feature_file',
|
||||||
minMatchCharacters: 1,
|
minMatchCharacters: 1,
|
||||||
|
@ -165,8 +165,8 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test(
|
test(
|
||||||
'successfully gets the blame for provided file with newestCommit argument',
|
'successfully gets the blame for provided file with '
|
||||||
() {
|
'newestCommit argument', () {
|
||||||
final blame = repo.blame(
|
final blame = repo.blame(
|
||||||
path: 'feature_file',
|
path: 'feature_file',
|
||||||
newestCommit: repo['fc38877'],
|
newestCommit: repo['fc38877'],
|
||||||
|
@ -194,8 +194,8 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test(
|
test(
|
||||||
'successfully gets the blame for provided file with minLine and maxLine set',
|
'successfully gets the blame for provided file with minLine and '
|
||||||
() {
|
'maxLine set', () {
|
||||||
final blame = repo.blame(
|
final blame = repo.blame(
|
||||||
path: 'feature_file',
|
path: 'feature_file',
|
||||||
minLine: 1,
|
minLine: 1,
|
||||||
|
|
|
@ -34,8 +34,8 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test(
|
test(
|
||||||
'throws when trying to checkout head with invalid alternative directory',
|
'throws when trying to checkout head with invalid alternative '
|
||||||
() {
|
'directory', () {
|
||||||
expect(
|
expect(
|
||||||
() => repo.checkout(
|
() => repo.checkout(
|
||||||
refName: 'HEAD',
|
refName: 'HEAD',
|
||||||
|
@ -66,8 +66,8 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test(
|
test(
|
||||||
'throws when trying to checkout index with invalid alternative directory',
|
'throws when trying to checkout index with invalid alternative '
|
||||||
() {
|
'directory', () {
|
||||||
expect(
|
expect(
|
||||||
() => repo.checkout(directory: 'not/there'),
|
() => repo.checkout(directory: 'not/there'),
|
||||||
throwsA(
|
throwsA(
|
||||||
|
@ -111,8 +111,8 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test(
|
test(
|
||||||
'throws when trying to checkout tree with invalid alternative directory',
|
'throws when trying to checkout tree with invalid alternative '
|
||||||
() {
|
'directory', () {
|
||||||
expect(
|
expect(
|
||||||
() => repo.checkout(
|
() => repo.checkout(
|
||||||
refName: 'refs/heads/feature',
|
refName: 'refs/heads/feature',
|
||||||
|
|
|
@ -42,8 +42,8 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test(
|
test(
|
||||||
'opens the global, XDG and system configuration files (if they are present) '
|
'opens the global, XDG and system configuration files '
|
||||||
'if no path provided', () {
|
'(if they are present) if no path provided', () {
|
||||||
try {
|
try {
|
||||||
final config = Config.open();
|
final config = Config.open();
|
||||||
expect(config, isA<Config>());
|
expect(config, isA<Config>());
|
||||||
|
|
|
@ -153,7 +153,8 @@ void main() {
|
||||||
isA<LibGit2Error>().having(
|
isA<LibGit2Error>().having(
|
||||||
(e) => e.toString(),
|
(e) => e.toString(),
|
||||||
'error',
|
'error',
|
||||||
"Failed to authenticate SSH session: Unable to open public key file",
|
'Failed to authenticate SSH session: Unable to open public key '
|
||||||
|
'file',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -56,7 +56,8 @@ void main() {
|
||||||
isA<LibGit2Error>().having(
|
isA<LibGit2Error>().having(
|
||||||
(e) => e.toString(),
|
(e) => e.toString(),
|
||||||
'error',
|
'error',
|
||||||
"cannot describe - no tags can describe 'f17d0d48eae3aa08cecf29128a35e310c97b3521'.",
|
"cannot describe - no tags can describe "
|
||||||
|
"'f17d0d48eae3aa08cecf29128a35e310c97b3521'.",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -112,7 +112,8 @@ void main() {
|
||||||
isA<LibGit2Error>().having(
|
isA<LibGit2Error>().having(
|
||||||
(e) => e.toString(),
|
(e) => e.toString(),
|
||||||
'error',
|
'error',
|
||||||
"could not find '${repo.workdir}not_there' to stat: No such file or directory",
|
"could not find '${repo.workdir}not_there' to stat: No such file "
|
||||||
|
"or directory",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -141,7 +142,8 @@ void main() {
|
||||||
isA<LibGit2Error>().having(
|
isA<LibGit2Error>().having(
|
||||||
(e) => e.toString(),
|
(e) => e.toString(),
|
||||||
'error',
|
'error',
|
||||||
"cannot create blob from file. This operation is not allowed against bare repositories.",
|
"cannot create blob from file. This operation is not allowed "
|
||||||
|
"against bare repositories.",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -184,7 +186,8 @@ void main() {
|
||||||
isA<LibGit2Error>().having(
|
isA<LibGit2Error>().having(
|
||||||
(e) => e.toString(),
|
(e) => e.toString(),
|
||||||
'error',
|
'error',
|
||||||
"cannot index add all. This operation is not allowed against bare repositories.",
|
"cannot index add all. This operation is not allowed against "
|
||||||
|
"bare repositories.",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -148,8 +148,8 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test(
|
test(
|
||||||
'throws when trying to initialize rebase without upstream and onto provided',
|
'throws when trying to initialize rebase without upstream and onto '
|
||||||
() {
|
'provided', () {
|
||||||
expect(
|
expect(
|
||||||
() => Rebase.init(repo: repo),
|
() => Rebase.init(repo: repo),
|
||||||
throwsA(
|
throwsA(
|
||||||
|
@ -218,7 +218,8 @@ void main() {
|
||||||
isA<LibGit2Error>().having(
|
isA<LibGit2Error>().having(
|
||||||
(e) => e.toString(),
|
(e) => e.toString(),
|
||||||
'error',
|
'error',
|
||||||
"object not found - failed to find pack entry (790b86f5fb50db485586370f27c5f90bada97d83)",
|
"object not found - failed to find pack entry "
|
||||||
|
"(790b86f5fb50db485586370f27c5f90bada97d83)",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -201,7 +201,8 @@ void main() {
|
||||||
isA<ArgumentError>().having(
|
isA<ArgumentError>().having(
|
||||||
(e) => e.toString(),
|
(e) => e.toString(),
|
||||||
'error',
|
'error',
|
||||||
'Invalid argument: "0 must be either Oid or String reference name"',
|
'Invalid argument: "0 must be either Oid or String reference '
|
||||||
|
'name"',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -462,7 +463,8 @@ void main() {
|
||||||
isA<ArgumentError>().having(
|
isA<ArgumentError>().having(
|
||||||
(e) => e.toString(),
|
(e) => e.toString(),
|
||||||
'error',
|
'error',
|
||||||
'Invalid argument: "0 must be either Oid or String reference name"',
|
'Invalid argument: "0 must be either Oid or String reference '
|
||||||
|
'name"',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -337,8 +337,8 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test(
|
test(
|
||||||
'throws when trying to get remote repo\'s reference list with invalid url',
|
'throws when trying to get remote repo\'s reference list with '
|
||||||
() {
|
'invalid url', () {
|
||||||
Remote.setUrl(repo: repo, remote: 'libgit2', url: 'invalid');
|
Remote.setUrl(repo: repo, remote: 'libgit2', url: 'invalid');
|
||||||
final remote = repo.lookupRemote('libgit2');
|
final remote = repo.lookupRemote('libgit2');
|
||||||
|
|
||||||
|
@ -455,7 +455,8 @@ void main() {
|
||||||
isA<LibGit2Error>().having(
|
isA<LibGit2Error>().having(
|
||||||
(e) => e.toString(),
|
(e) => e.toString(),
|
||||||
'error',
|
'error',
|
||||||
"failed to resolve address for wrong.url: Name or service not known",
|
"failed to resolve address for wrong.url: Name or service "
|
||||||
|
"not known",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -604,7 +605,8 @@ Total 69 (delta 0), reused 1 (delta 0), pack-reused 68
|
||||||
isA<LibGit2Error>().having(
|
isA<LibGit2Error>().having(
|
||||||
(e) => e.toString(),
|
(e) => e.toString(),
|
||||||
'error',
|
'error',
|
||||||
"failed to resolve address for wrong.url: Name or service not known",
|
"failed to resolve address for wrong.url: Name or service "
|
||||||
|
"not known",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -183,7 +183,8 @@ void main() {
|
||||||
isA<ArgumentError>().having(
|
isA<ArgumentError>().having(
|
||||||
(e) => e.toString(),
|
(e) => e.toString(),
|
||||||
'error',
|
'error',
|
||||||
'Invalid argument: "0 must be either Oid or String reference name"',
|
'Invalid argument: "0 must be either Oid or String reference '
|
||||||
|
'name"',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -305,7 +306,8 @@ void main() {
|
||||||
isA<LibGit2Error>().having(
|
isA<LibGit2Error>().having(
|
||||||
(e) => e.toString(),
|
(e) => e.toString(),
|
||||||
'error',
|
'error',
|
||||||
"cannot status. This operation is not allowed against bare repositories.",
|
"cannot status. This operation is not allowed against bare "
|
||||||
|
"repositories.",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -119,8 +119,8 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test(
|
test(
|
||||||
'.range returns revspec with correct fields values based on provided spec',
|
'.range returns revspec with correct fields values based on '
|
||||||
() {
|
'provided spec', () {
|
||||||
var revspec = repo.revParse('master');
|
var revspec = repo.revParse('master');
|
||||||
|
|
||||||
expect(revspec.from.oid.sha, headSHA);
|
expect(revspec.from.oid.sha, headSHA);
|
||||||
|
@ -165,12 +165,12 @@ void main() {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
() => repo.revParse('master........5aecfa'),
|
() => repo.revParse('master.......5aecfa'),
|
||||||
throwsA(
|
throwsA(
|
||||||
isA<LibGit2Error>().having(
|
isA<LibGit2Error>().having(
|
||||||
(e) => e.toString(),
|
(e) => e.toString(),
|
||||||
'error',
|
'error',
|
||||||
"failed to parse revision specifier - Invalid pattern '.....5aecfa'",
|
"failed to parse revision specifier - Invalid pattern '....5aecfa'",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -32,22 +32,24 @@ void main() {
|
||||||
isA<LibGit2Error>().having(
|
isA<LibGit2Error>().having(
|
||||||
(e) => e.toString(),
|
(e) => e.toString(),
|
||||||
'error',
|
'error',
|
||||||
"failed to parse signature - Signature cannot have an empty name or email",
|
"failed to parse signature - Signature cannot have an empty name "
|
||||||
|
"or email",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test(
|
test(
|
||||||
'throws when trying to create with empty name and email and default time',
|
'throws when trying to create with empty name and email and '
|
||||||
() {
|
'default time', () {
|
||||||
expect(
|
expect(
|
||||||
() => Signature.create(name: '', email: ''),
|
() => Signature.create(name: '', email: ''),
|
||||||
throwsA(
|
throwsA(
|
||||||
isA<LibGit2Error>().having(
|
isA<LibGit2Error>().having(
|
||||||
(e) => e.toString(),
|
(e) => e.toString(),
|
||||||
'error',
|
'error',
|
||||||
"failed to parse signature - Signature cannot have an empty name or email",
|
"failed to parse signature - Signature cannot have an empty name "
|
||||||
|
"or email",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -153,7 +153,8 @@ void main() {
|
||||||
isA<LibGit2Error>().having(
|
isA<LibGit2Error>().having(
|
||||||
(e) => e.toString(),
|
(e) => e.toString(),
|
||||||
'error',
|
'error',
|
||||||
'failed to resolve address for wrong.url: Name or service not known',
|
'failed to resolve address for wrong.url: Name or service '
|
||||||
|
'not known',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -53,8 +53,8 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test(
|
test(
|
||||||
'successfully creates worktree at provided path from provided reference',
|
'successfully creates worktree at provided path from '
|
||||||
() {
|
'provided reference', () {
|
||||||
final head = repo.revParseSingle('HEAD');
|
final head = repo.revParseSingle('HEAD');
|
||||||
final worktreeBranch = repo.createBranch(name: 'v1', target: head);
|
final worktreeBranch = repo.createBranch(name: 'v1', target: head);
|
||||||
final ref = repo.lookupReference('refs/heads/v1');
|
final ref = repo.lookupReference('refs/heads/v1');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue