mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-05 04:39:07 -04:00
Compare commits
No commits in common. "master" and "v1.1.2" have entirely different histories.
55 changed files with 164 additions and 757 deletions
34
CHANGELOG.md
34
CHANGELOG.md
|
@ -1,37 +1,3 @@
|
||||||
## 1.2.2
|
|
||||||
|
|
||||||
- fix: lookup package in correct location of Dart/Flutter cached packages
|
|
||||||
|
|
||||||
## 1.2.1
|
|
||||||
|
|
||||||
- fix: use default location of Flutter's '.pub_cache' folder
|
|
||||||
|
|
||||||
- docs: update README with troubleshooting instructions for Windows
|
|
||||||
|
|
||||||
- chore: bump minimum dart and flutter versions
|
|
||||||
|
|
||||||
- chore: Lookup library in system path (thanks @dnys1)
|
|
||||||
|
|
||||||
## 1.2.0
|
|
||||||
|
|
||||||
- feat: upgrade libgit2 to 1.5.0
|
|
||||||
|
|
||||||
- feat: add ability to pass checkout options to `reset(...)` API method
|
|
||||||
|
|
||||||
- feat: add ability to pass options to `prune(...)` Worktree API method
|
|
||||||
|
|
||||||
- feat: add ability to pass options to `Merge.fileFromIndex(...)` API method
|
|
||||||
|
|
||||||
- feat: add ability to pass options to `addAll(...)` Index API method
|
|
||||||
|
|
||||||
- feat: add ability to pass options to `revert(...)` and `revertTo(...)` Commit API methods:
|
|
||||||
|
|
||||||
- select parent to revert to for merge commits
|
|
||||||
- merge options
|
|
||||||
- checkout options
|
|
||||||
|
|
||||||
- chore: upgrade dependencies
|
|
||||||
|
|
||||||
## 1.1.2
|
## 1.1.2
|
||||||
|
|
||||||
- fix: lookup library in Flutter's .pub_cache folder
|
- fix: lookup library in Flutter's .pub_cache folder
|
||||||
|
|
15
README.md
15
README.md
|
@ -1,5 +1,7 @@
|
||||||
# libgit2dart
|
# libgit2dart
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
**Dart bindings to libgit2**
|
**Dart bindings to libgit2**
|
||||||
|
|
||||||
libgit2dart package provides ability to use [libgit2](https://github.com/libgit2/libgit2) in Dart/Flutter.
|
libgit2dart package provides ability to use [libgit2](https://github.com/libgit2/libgit2) in Dart/Flutter.
|
||||||
|
@ -663,8 +665,6 @@ Fork libgit2dart, improve libgit2dart, send a pull request.
|
||||||
|
|
||||||
### Troubleshooting
|
### Troubleshooting
|
||||||
|
|
||||||
#### Linux:
|
|
||||||
|
|
||||||
If you are developing on Linux using non-Debian based distrib you might encounter these errors:
|
If you are developing on Linux using non-Debian based distrib you might encounter these errors:
|
||||||
|
|
||||||
- Failed to load dynamic library: libpcre.so.3: cannot open shared object file: No such file or directory
|
- Failed to load dynamic library: libpcre.so.3: cannot open shared object file: No such file or directory
|
||||||
|
@ -679,16 +679,6 @@ sudo ln -s /usr/lib64/libpcre.so /usr/lib64/libpcre.so.3
|
||||||
sudo ln -s /usr/lib64/libpcreposix.so /usr/lib64/libpcreposix.so.3
|
sudo ln -s /usr/lib64/libpcreposix.so /usr/lib64/libpcreposix.so.3
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Windows:
|
|
||||||
|
|
||||||
If you are developing on Windows you might encounter:
|
|
||||||
|
|
||||||
- Failed to load dynamic library: error code 126
|
|
||||||
|
|
||||||
That happens because libgit2 dynamic library bundled with libgit2dart package is precompiled with ssh support, and it fails to find the `libssh2.dll`.
|
|
||||||
|
|
||||||
To fix that error you should [build](https://github.com/libssh2/libssh2/blob/master/docs/INSTALL_CMAKE.md) libssh2, and place resulting `libssh2.dll` somewhere in system path (e.g. "Windows\System32").
|
|
||||||
|
|
||||||
### Ffigen
|
### Ffigen
|
||||||
|
|
||||||
To generate bindings with ffigen use (adjust paths to yours):
|
To generate bindings with ffigen use (adjust paths to yours):
|
||||||
|
@ -703,6 +693,7 @@ To run all tests and generate coverage report make sure to have activated packag
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ dart pub global activate coverage
|
$ dart pub global activate coverage
|
||||||
|
$ dart pub global activate flutter_coverage_badge
|
||||||
```
|
```
|
||||||
|
|
||||||
And run:
|
And run:
|
||||||
|
|
|
@ -4,7 +4,6 @@ analyzer:
|
||||||
language:
|
language:
|
||||||
strict-casts: true
|
strict-casts: true
|
||||||
strict-raw-types: true
|
strict-raw-types: true
|
||||||
strict-inference: true
|
|
||||||
|
|
||||||
exclude:
|
exclude:
|
||||||
- lib/src/bindings/libgit2_bindings.dart
|
- lib/src/bindings/libgit2_bindings.dart
|
||||||
|
|
|
@ -5,6 +5,7 @@ import 'package:libgit2dart/libgit2dart.dart';
|
||||||
import 'package:libgit2dart/src/libgit2.dart';
|
import 'package:libgit2dart/src/libgit2.dart';
|
||||||
import 'package:libgit2dart/src/util.dart';
|
import 'package:libgit2dart/src/util.dart';
|
||||||
import 'package:path/path.dart' as path;
|
import 'package:path/path.dart' as path;
|
||||||
|
import 'package:pub_cache/pub_cache.dart';
|
||||||
|
|
||||||
/// Copies prebuilt libgit2 library from package in '.pub_cache' into correct
|
/// Copies prebuilt libgit2 library from package in '.pub_cache' into correct
|
||||||
/// directory for [platform].
|
/// directory for [platform].
|
||||||
|
@ -22,25 +23,28 @@ Future<void> copyLibrary(String platform) async {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
final libPath = checkCache();
|
String? checkCache(PubCache pubCache) =>
|
||||||
|
pubCache.getLatestVersion('libgit2dart')?.resolve()?.location.path;
|
||||||
|
|
||||||
|
final libPath = checkCache(PubCache()) ??
|
||||||
|
checkCache(
|
||||||
|
PubCache(
|
||||||
|
Directory(
|
||||||
|
path.join(Platform.environment['FLUTTER_ROOT']!, '.pub-cache'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
final libName = getLibName();
|
final libName = getLibName();
|
||||||
|
|
||||||
stdout.writeln('Copying libgit2 for $platform');
|
stdout.writeln('Copying libgit2 for $platform');
|
||||||
if (libPath == null) {
|
|
||||||
stdout.writeln(
|
|
||||||
"Couldn't find libgit2dart package.\n"
|
|
||||||
"Make sure to run 'dart pub get' to resolve dependencies.",
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
final destination = path.join(libDir, platform);
|
final destination = path.join(libDir, platform);
|
||||||
Directory(destination).createSync(recursive: true);
|
Directory(destination).createSync(recursive: true);
|
||||||
File(path.join(libPath, platform, libName)).copySync(
|
File(path.join(libPath!, platform, libName)).copySync(
|
||||||
path.join(destination, libName),
|
path.join(destination, libName),
|
||||||
);
|
);
|
||||||
|
|
||||||
stdout.writeln('Done! libgit2 for $platform is now available!');
|
stdout.writeln('Done! libgit2 for $platform is now available!');
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class CleanCommand extends Command<void> {
|
class CleanCommand extends Command<void> {
|
||||||
|
@ -53,10 +57,8 @@ class CleanCommand extends Command<void> {
|
||||||
@override
|
@override
|
||||||
void run() {
|
void run() {
|
||||||
stdout.writeln('Cleaning...');
|
stdout.writeln('Cleaning...');
|
||||||
if (Directory(libDir).existsSync()) {
|
|
||||||
Directory(libDir).deleteSync(recursive: true);
|
Directory(libDir).deleteSync(recursive: true);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void main(List<String> args) {
|
void main(List<String> args) {
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
dart test --coverage=coverage --test-randomize-ordering-seed random && dart pub global run coverage:format_coverage --lcov --check-ignore --in=coverage --out=coverage/lcov.info --report-on=lib && genhtml coverage/lcov.info -o coverage/
|
dart test --coverage=coverage --test-randomize-ordering-seed random && dart pub global run coverage:format_coverage --lcov --check-ignore --in=coverage --out=coverage/lcov.info --report-on=lib && genhtml coverage/lcov.info -o coverage/ && dart pub global run flutter_coverage_badge
|
20
coverage_badge.svg
Normal file
20
coverage_badge.svg
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="102" height="20">
|
||||||
|
<linearGradient id="b" x2="0" y2="100%">
|
||||||
|
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
||||||
|
<stop offset="1" stop-opacity=".1"/>
|
||||||
|
</linearGradient>
|
||||||
|
<clipPath id="a">
|
||||||
|
<rect width="102" height="20" rx="3" fill="#fff"/>
|
||||||
|
</clipPath>
|
||||||
|
<g clip-path="url(#a)">
|
||||||
|
<path fill="#555" d="M0 0h59v20H0z"/>
|
||||||
|
<path fill="#44cc11" d="M59 0h43v20H59z"/>
|
||||||
|
<path fill="url(#b)" d="M0 0h102v20H0z"/>
|
||||||
|
</g>
|
||||||
|
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="110">
|
||||||
|
<text x="305" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="490">coverage</text>
|
||||||
|
<text x="305" y="140" transform="scale(.1)" textLength="490">coverage</text>
|
||||||
|
<text x="795" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="330">100%</text>
|
||||||
|
<text x="795" y="140" transform="scale(.1)" textLength="330">100%</text>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 1 KiB |
|
@ -84,7 +84,6 @@ class AnnotatedCommit extends Equatable {
|
||||||
/// Pointer to pointer to memory address for allocated commit object.
|
/// Pointer to pointer to memory address for allocated commit object.
|
||||||
///
|
///
|
||||||
/// Note: For internal use.
|
/// Note: For internal use.
|
||||||
@internal
|
|
||||||
Pointer<git_annotated_commit> get pointer => _annotatedCommitPointer;
|
Pointer<git_annotated_commit> get pointer => _annotatedCommitPointer;
|
||||||
|
|
||||||
/// Commit oid that the given annotated commit refers to.
|
/// Commit oid that the given annotated commit refers to.
|
||||||
|
|
|
@ -384,48 +384,8 @@ Pointer<git_tree> tree(Pointer<git_commit> commit) {
|
||||||
void revert({
|
void revert({
|
||||||
required Pointer<git_repository> repoPointer,
|
required Pointer<git_repository> repoPointer,
|
||||||
required Pointer<git_commit> commitPointer,
|
required Pointer<git_commit> commitPointer,
|
||||||
required int mainline,
|
|
||||||
int? mergeFavor,
|
|
||||||
int? mergeFlags,
|
|
||||||
int? mergeFileFlags,
|
|
||||||
int? checkoutStrategy,
|
|
||||||
String? checkoutDirectory,
|
|
||||||
List<String>? checkoutPaths,
|
|
||||||
}) {
|
}) {
|
||||||
final opts = calloc<git_revert_options>();
|
final error = libgit2.git_revert(repoPointer, commitPointer, nullptr);
|
||||||
libgit2.git_revert_options_init(opts, GIT_REVERT_OPTIONS_VERSION);
|
|
||||||
|
|
||||||
opts.ref.mainline = mainline;
|
|
||||||
|
|
||||||
if (mergeFavor != null) opts.ref.merge_opts.file_favor = mergeFavor;
|
|
||||||
if (mergeFlags != null) opts.ref.merge_opts.flags = mergeFlags;
|
|
||||||
if (mergeFileFlags != null) opts.ref.merge_opts.file_flags = mergeFileFlags;
|
|
||||||
|
|
||||||
if (checkoutStrategy != null) {
|
|
||||||
opts.ref.checkout_opts.checkout_strategy = checkoutStrategy;
|
|
||||||
}
|
|
||||||
if (checkoutDirectory != null) {
|
|
||||||
opts.ref.checkout_opts.target_directory = checkoutDirectory.toChar();
|
|
||||||
}
|
|
||||||
var pathPointers = <Pointer<Char>>[];
|
|
||||||
Pointer<Pointer<Char>> strArray = nullptr;
|
|
||||||
if (checkoutPaths != null) {
|
|
||||||
pathPointers = checkoutPaths.map((e) => e.toChar()).toList();
|
|
||||||
strArray = calloc(checkoutPaths.length);
|
|
||||||
for (var i = 0; i < checkoutPaths.length; i++) {
|
|
||||||
strArray[i] = pathPointers[i];
|
|
||||||
}
|
|
||||||
opts.ref.checkout_opts.paths.strings = strArray;
|
|
||||||
opts.ref.checkout_opts.paths.count = checkoutPaths.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
final error = libgit2.git_revert(repoPointer, commitPointer, opts);
|
|
||||||
|
|
||||||
for (final p in pathPointers) {
|
|
||||||
calloc.free(p);
|
|
||||||
}
|
|
||||||
calloc.free(strArray);
|
|
||||||
calloc.free(opts);
|
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
|
@ -443,18 +403,11 @@ Pointer<git_index> revertCommit({
|
||||||
required Pointer<git_commit> revertCommitPointer,
|
required Pointer<git_commit> revertCommitPointer,
|
||||||
required Pointer<git_commit> ourCommitPointer,
|
required Pointer<git_commit> ourCommitPointer,
|
||||||
required int mainline,
|
required int mainline,
|
||||||
int? mergeFavor,
|
|
||||||
int? mergeFlags,
|
|
||||||
int? mergeFileFlags,
|
|
||||||
}) {
|
}) {
|
||||||
final out = calloc<Pointer<git_index>>();
|
final out = calloc<Pointer<git_index>>();
|
||||||
final opts = calloc<git_merge_options>();
|
final opts = calloc<git_merge_options>();
|
||||||
libgit2.git_merge_options_init(opts, GIT_MERGE_OPTIONS_VERSION);
|
libgit2.git_merge_options_init(opts, GIT_MERGE_OPTIONS_VERSION);
|
||||||
|
|
||||||
if (mergeFavor != null) opts.ref.file_favor = mergeFavor;
|
|
||||||
if (mergeFlags != null) opts.ref.flags = mergeFlags;
|
|
||||||
if (mergeFileFlags != null) opts.ref.file_flags = mergeFileFlags;
|
|
||||||
|
|
||||||
final error = libgit2.git_revert_commit(
|
final error = libgit2.git_revert_commit(
|
||||||
out,
|
out,
|
||||||
repoPointer,
|
repoPointer,
|
||||||
|
|
|
@ -292,7 +292,6 @@ void addFromBuffer({
|
||||||
void addAll({
|
void addAll({
|
||||||
required Pointer<git_index> indexPointer,
|
required Pointer<git_index> indexPointer,
|
||||||
required List<String> pathspec,
|
required List<String> pathspec,
|
||||||
required int flags,
|
|
||||||
}) {
|
}) {
|
||||||
final pathspecC = calloc<git_strarray>();
|
final pathspecC = calloc<git_strarray>();
|
||||||
final pathPointers = pathspec.map((e) => e.toChar()).toList();
|
final pathPointers = pathspec.map((e) => e.toChar()).toList();
|
||||||
|
@ -308,7 +307,7 @@ void addAll({
|
||||||
final error = libgit2.git_index_add_all(
|
final error = libgit2.git_index_add_all(
|
||||||
indexPointer,
|
indexPointer,
|
||||||
pathspecC,
|
pathspecC,
|
||||||
flags,
|
0,
|
||||||
nullptr,
|
nullptr,
|
||||||
nullptr,
|
nullptr,
|
||||||
);
|
);
|
||||||
|
|
|
@ -2217,23 +2217,6 @@ class Libgit2 {
|
||||||
int Function(
|
int Function(
|
||||||
ffi.Pointer<ffi.Int>, ffi.Pointer<ffi.Int>, ffi.Pointer<ffi.Int>)>();
|
ffi.Pointer<ffi.Int>, ffi.Pointer<ffi.Int>, ffi.Pointer<ffi.Int>)>();
|
||||||
|
|
||||||
/// Return the prerelease state of the libgit2 library currently being
|
|
||||||
/// used. For nightly builds during active development, this will be
|
|
||||||
/// "alpha". Releases may have a "beta" or release candidate ("rc1",
|
|
||||||
/// "rc2", etc) prerelease. For a final release, this function returns
|
|
||||||
/// NULL.
|
|
||||||
///
|
|
||||||
/// @return the name of the prerelease state or NULL
|
|
||||||
ffi.Pointer<ffi.Char> git_libgit2_prerelease() {
|
|
||||||
return _git_libgit2_prerelease();
|
|
||||||
}
|
|
||||||
|
|
||||||
late final _git_libgit2_prereleasePtr =
|
|
||||||
_lookup<ffi.NativeFunction<ffi.Pointer<ffi.Char> Function()>>(
|
|
||||||
'git_libgit2_prerelease');
|
|
||||||
late final _git_libgit2_prerelease =
|
|
||||||
_git_libgit2_prereleasePtr.asFunction<ffi.Pointer<ffi.Char> Function()>();
|
|
||||||
|
|
||||||
/// Query compile time options for libgit2.
|
/// Query compile time options for libgit2.
|
||||||
///
|
///
|
||||||
/// @return A combination of GIT_FEATURE_* values.
|
/// @return A combination of GIT_FEATURE_* values.
|
||||||
|
@ -9476,8 +9459,8 @@ class Libgit2 {
|
||||||
/// See `git_tag_create()` for rules about valid names.
|
/// See `git_tag_create()` for rules about valid names.
|
||||||
///
|
///
|
||||||
/// Note that if the move succeeds, the old reference object will not
|
/// Note that if the move succeeds, the old reference object will not
|
||||||
/// be valid anymore, and should be freed immediately by the user using
|
/// + be valid anymore, and should be freed immediately by the user using
|
||||||
/// `git_reference_free()`.
|
/// + `git_reference_free()`.
|
||||||
///
|
///
|
||||||
/// @param out New reference object for the updated name.
|
/// @param out New reference object for the updated name.
|
||||||
///
|
///
|
||||||
|
@ -11885,7 +11868,7 @@ class Libgit2 {
|
||||||
/// completes, resolve any conflicts and prepare a commit.
|
/// completes, resolve any conflicts and prepare a commit.
|
||||||
///
|
///
|
||||||
/// For compatibility with git, the repository is put into a merging
|
/// For compatibility with git, the repository is put into a merging
|
||||||
/// state. Once the commit is done (or if the user wishes to abort),
|
/// state. Once the commit is done (or if the uses wishes to abort),
|
||||||
/// you should clear this state by calling
|
/// you should clear this state by calling
|
||||||
/// `git_repository_state_cleanup()`.
|
/// `git_repository_state_cleanup()`.
|
||||||
///
|
///
|
||||||
|
@ -15458,7 +15441,7 @@ class Libgit2 {
|
||||||
/// global configuration file.
|
/// global configuration file.
|
||||||
///
|
///
|
||||||
/// This method will not guess the path to the xdg compatible
|
/// This method will not guess the path to the xdg compatible
|
||||||
/// config file (`.config/git/config`).
|
/// config file (.config/git/config).
|
||||||
///
|
///
|
||||||
/// @param out Pointer to a user-allocated git_buf in which to store the path
|
/// @param out Pointer to a user-allocated git_buf in which to store the path
|
||||||
/// @return 0 if a global configuration file has been found. Its path will be stored in `out`.
|
/// @return 0 if a global configuration file has been found. Its path will be stored in `out`.
|
||||||
|
@ -15505,8 +15488,8 @@ class Libgit2 {
|
||||||
|
|
||||||
/// Locate the path to the system configuration file
|
/// Locate the path to the system configuration file
|
||||||
///
|
///
|
||||||
/// If `/etc/gitconfig` doesn't exist, it will look for
|
/// If /etc/gitconfig doesn't exist, it will look for
|
||||||
/// `%PROGRAMFILES%\Git\etc\gitconfig`.
|
/// %PROGRAMFILES%\Git\etc\gitconfig.
|
||||||
///
|
///
|
||||||
/// @param out Pointer to a user-allocated git_buf in which to store the path
|
/// @param out Pointer to a user-allocated git_buf in which to store the path
|
||||||
/// @return 0 if a system configuration file has been
|
/// @return 0 if a system configuration file has been
|
||||||
|
@ -15527,7 +15510,7 @@ class Libgit2 {
|
||||||
|
|
||||||
/// Locate the path to the configuration file in ProgramData
|
/// Locate the path to the configuration file in ProgramData
|
||||||
///
|
///
|
||||||
/// Look for the file in `%PROGRAMDATA%\Git\config` used by portable git.
|
/// Look for the file in %PROGRAMDATA%\Git\config used by portable git.
|
||||||
///
|
///
|
||||||
/// @param out Pointer to a user-allocated git_buf in which to store the path
|
/// @param out Pointer to a user-allocated git_buf in which to store the path
|
||||||
/// @return 0 if a ProgramData configuration file has been
|
/// @return 0 if a ProgramData configuration file has been
|
||||||
|
@ -16100,8 +16083,8 @@ class Libgit2 {
|
||||||
|
|
||||||
/// Return the current entry and advance the iterator
|
/// Return the current entry and advance the iterator
|
||||||
///
|
///
|
||||||
/// The pointers returned by this function are valid until the next call
|
/// The pointers returned by this function are valid until the iterator
|
||||||
/// to `git_config_next` or until the iterator is freed.
|
/// is freed.
|
||||||
///
|
///
|
||||||
/// @param entry pointer to store the entry
|
/// @param entry pointer to store the entry
|
||||||
/// @param iter the iterator
|
/// @param iter the iterator
|
||||||
|
@ -16939,8 +16922,7 @@ class Libgit2 {
|
||||||
late final _git_error_clear =
|
late final _git_error_clear =
|
||||||
_git_error_clearPtr.asFunction<void Function()>();
|
_git_error_clearPtr.asFunction<void Function()>();
|
||||||
|
|
||||||
/// Set the error message string for this thread, using `printf`-style
|
/// Set the error message string for this thread.
|
||||||
/// formatting.
|
|
||||||
///
|
///
|
||||||
/// This function is public so that custom ODB backends and the like can
|
/// This function is public so that custom ODB backends and the like can
|
||||||
/// relay an error message through libgit2. Most regular users of libgit2
|
/// relay an error message through libgit2. Most regular users of libgit2
|
||||||
|
@ -16953,31 +16935,7 @@ class Libgit2 {
|
||||||
///
|
///
|
||||||
/// @param error_class One of the `git_error_t` enum above describing the
|
/// @param error_class One of the `git_error_t` enum above describing the
|
||||||
/// general subsystem that is responsible for the error.
|
/// general subsystem that is responsible for the error.
|
||||||
/// @param fmt The `printf`-style format string; subsequent arguments must
|
/// @param string The formatted error message to keep
|
||||||
/// be the arguments for the format string.
|
|
||||||
void git_error_set(
|
|
||||||
int error_class,
|
|
||||||
ffi.Pointer<ffi.Char> fmt,
|
|
||||||
) {
|
|
||||||
return _git_error_set(
|
|
||||||
error_class,
|
|
||||||
fmt,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
late final _git_error_setPtr = _lookup<
|
|
||||||
ffi.NativeFunction<
|
|
||||||
ffi.Void Function(ffi.Int, ffi.Pointer<ffi.Char>)>>('git_error_set');
|
|
||||||
late final _git_error_set =
|
|
||||||
_git_error_setPtr.asFunction<void Function(int, ffi.Pointer<ffi.Char>)>();
|
|
||||||
|
|
||||||
/// Set the error message string for this thread. This function is like
|
|
||||||
/// `git_error_set` but takes a static string instead of a `printf`-style
|
|
||||||
/// format.
|
|
||||||
///
|
|
||||||
/// @param error_class One of the `git_error_t` enum above describing the
|
|
||||||
/// general subsystem that is responsible for the error.
|
|
||||||
/// @param string The error message to keep
|
|
||||||
/// @return 0 on success or -1 on failure
|
/// @return 0 on success or -1 on failure
|
||||||
int git_error_set_str(
|
int git_error_set_str(
|
||||||
int error_class,
|
int error_class,
|
||||||
|
@ -30729,7 +30687,7 @@ abstract class git_error_t {
|
||||||
static const int GIT_ERROR_FILESYSTEM = 30;
|
static const int GIT_ERROR_FILESYSTEM = 30;
|
||||||
static const int GIT_ERROR_PATCH = 31;
|
static const int GIT_ERROR_PATCH = 31;
|
||||||
static const int GIT_ERROR_WORKTREE = 32;
|
static const int GIT_ERROR_WORKTREE = 32;
|
||||||
static const int GIT_ERROR_SHA = 33;
|
static const int GIT_ERROR_SHA1 = 33;
|
||||||
static const int GIT_ERROR_HTTP = 34;
|
static const int GIT_ERROR_HTTP = 34;
|
||||||
static const int GIT_ERROR_INTERNAL = 35;
|
static const int GIT_ERROR_INTERNAL = 35;
|
||||||
}
|
}
|
||||||
|
@ -31242,15 +31200,12 @@ class git_status_options extends ffi.Struct {
|
||||||
external int version;
|
external int version;
|
||||||
|
|
||||||
/// The `show` value is one of the `git_status_show_t` constants that
|
/// The `show` value is one of the `git_status_show_t` constants that
|
||||||
/// control which files to scan and in what order. The default is
|
/// control which files to scan and in what order.
|
||||||
/// `GIT_STATUS_SHOW_INDEX_AND_WORKDIR`.
|
|
||||||
@ffi.Int32()
|
@ffi.Int32()
|
||||||
external int show1;
|
external int show1;
|
||||||
|
|
||||||
/// The `flags` value is an OR'ed combination of the
|
/// The `flags` value is an OR'ed combination of the
|
||||||
/// `git_status_opt_t` values above. The default is
|
/// `git_status_opt_t` values above.
|
||||||
/// `GIT_STATUS_OPT_DEFAULTS`, which matches git's default
|
|
||||||
/// behavior.
|
|
||||||
@ffi.UnsignedInt()
|
@ffi.UnsignedInt()
|
||||||
external int flags;
|
external int flags;
|
||||||
|
|
||||||
|
@ -32651,8 +32606,6 @@ const int GITERR_WORKTREE = 32;
|
||||||
|
|
||||||
const int GITERR_SHA1 = 33;
|
const int GITERR_SHA1 = 33;
|
||||||
|
|
||||||
const int GIT_ERROR_SHA1 = 33;
|
|
||||||
|
|
||||||
const int GIT_IDXENTRY_NAMEMASK = 4095;
|
const int GIT_IDXENTRY_NAMEMASK = 4095;
|
||||||
|
|
||||||
const int GIT_IDXENTRY_STAGEMASK = 12288;
|
const int GIT_IDXENTRY_STAGEMASK = 12288;
|
||||||
|
@ -32757,16 +32710,14 @@ const int GIT_CREDTYPE_SSH_MEMORY = 64;
|
||||||
|
|
||||||
const int GIT_EMAIL_CREATE_OPTIONS_VERSION = 1;
|
const int GIT_EMAIL_CREATE_OPTIONS_VERSION = 1;
|
||||||
|
|
||||||
const String LIBGIT2_VERSION = '1.5.0';
|
const String LIBGIT2_VERSION = '1.4.3';
|
||||||
|
|
||||||
const int LIBGIT2_VER_MAJOR = 1;
|
const int LIBGIT2_VER_MAJOR = 1;
|
||||||
|
|
||||||
const int LIBGIT2_VER_MINOR = 5;
|
const int LIBGIT2_VER_MINOR = 4;
|
||||||
|
|
||||||
const int LIBGIT2_VER_REVISION = 0;
|
const int LIBGIT2_VER_REVISION = 3;
|
||||||
|
|
||||||
const int LIBGIT2_VER_PATCH = 0;
|
const int LIBGIT2_VER_PATCH = 0;
|
||||||
|
|
||||||
const int LIBGIT2_VER_PRERELEASE = 0;
|
const String LIBGIT2_SOVERSION = '1.4';
|
||||||
|
|
||||||
const String LIBGIT2_SOVERSION = '1.5';
|
|
||||||
|
|
|
@ -186,39 +186,30 @@ String mergeFile({
|
||||||
libgit2.git_merge_file_input_init(theirsC, GIT_MERGE_FILE_INPUT_VERSION);
|
libgit2.git_merge_file_input_init(theirsC, GIT_MERGE_FILE_INPUT_VERSION);
|
||||||
ancestorC.ref.ptr = ancestor.toChar();
|
ancestorC.ref.ptr = ancestor.toChar();
|
||||||
ancestorC.ref.size = ancestor.length;
|
ancestorC.ref.size = ancestor.length;
|
||||||
Pointer<Char> ancestorLabelC = nullptr;
|
|
||||||
oursC.ref.ptr = ours.toChar();
|
oursC.ref.ptr = ours.toChar();
|
||||||
oursC.ref.size = ours.length;
|
oursC.ref.size = ours.length;
|
||||||
Pointer<Char> oursLabelC = nullptr;
|
|
||||||
theirsC.ref.ptr = theirs.toChar();
|
theirsC.ref.ptr = theirs.toChar();
|
||||||
theirsC.ref.size = theirs.length;
|
theirsC.ref.size = theirs.length;
|
||||||
Pointer<Char> theirsLabelC = nullptr;
|
|
||||||
|
|
||||||
final opts = calloc<git_merge_file_options>();
|
final opts = calloc<git_merge_file_options>();
|
||||||
libgit2.git_merge_file_options_init(opts, GIT_MERGE_FILE_OPTIONS_VERSION);
|
libgit2.git_merge_file_options_init(opts, GIT_MERGE_FILE_OPTIONS_VERSION);
|
||||||
opts.ref.favor = favor;
|
opts.ref.favor = favor;
|
||||||
opts.ref.flags = flags;
|
opts.ref.flags = flags;
|
||||||
if (ancestorLabel.isNotEmpty) {
|
if (ancestorLabel.isNotEmpty) {
|
||||||
ancestorLabelC = ancestorLabel.toChar();
|
opts.ref.ancestor_label = ancestorLabel.toChar();
|
||||||
opts.ref.ancestor_label = ancestorLabelC;
|
|
||||||
}
|
}
|
||||||
if (oursLabel.isNotEmpty) {
|
if (oursLabel.isNotEmpty) {
|
||||||
oursLabelC = oursLabel.toChar();
|
opts.ref.our_label = oursLabel.toChar();
|
||||||
opts.ref.our_label = oursLabelC;
|
|
||||||
}
|
}
|
||||||
if (theirsLabel.isNotEmpty) {
|
if (theirsLabel.isNotEmpty) {
|
||||||
theirsLabelC = theirsLabel.toChar();
|
opts.ref.their_label = theirsLabel.toChar();
|
||||||
opts.ref.their_label = theirsLabelC;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
libgit2.git_merge_file(out, ancestorC, oursC, theirsC, opts);
|
libgit2.git_merge_file(out, ancestorC, oursC, theirsC, opts);
|
||||||
|
|
||||||
calloc.free(ancestorC);
|
calloc.free(ancestorC);
|
||||||
calloc.free(ancestorLabelC);
|
|
||||||
calloc.free(oursC);
|
calloc.free(oursC);
|
||||||
calloc.free(oursLabelC);
|
|
||||||
calloc.free(theirsC);
|
calloc.free(theirsC);
|
||||||
calloc.free(theirsLabelC);
|
|
||||||
calloc.free(opts);
|
calloc.free(opts);
|
||||||
|
|
||||||
final result = out.ref.ptr.toDartString(length: out.ref.len);
|
final result = out.ref.ptr.toDartString(length: out.ref.len);
|
||||||
|
@ -235,43 +226,17 @@ String mergeFile({
|
||||||
String mergeFileFromIndex({
|
String mergeFileFromIndex({
|
||||||
required Pointer<git_repository> repoPointer,
|
required Pointer<git_repository> repoPointer,
|
||||||
required Pointer<git_index_entry>? ancestorPointer,
|
required Pointer<git_index_entry>? ancestorPointer,
|
||||||
required String ancestorLabel,
|
|
||||||
required Pointer<git_index_entry> oursPointer,
|
required Pointer<git_index_entry> oursPointer,
|
||||||
required String oursLabel,
|
|
||||||
required Pointer<git_index_entry> theirsPointer,
|
required Pointer<git_index_entry> theirsPointer,
|
||||||
required String theirsLabel,
|
|
||||||
required int favor,
|
|
||||||
required int flags,
|
|
||||||
}) {
|
}) {
|
||||||
final out = calloc<git_merge_file_result>();
|
final out = calloc<git_merge_file_result>();
|
||||||
final opts = calloc<git_merge_file_options>();
|
|
||||||
Pointer<Char> ancestorLabelC = nullptr;
|
|
||||||
Pointer<Char> oursLabelC = nullptr;
|
|
||||||
Pointer<Char> theirsLabelC = nullptr;
|
|
||||||
|
|
||||||
libgit2.git_merge_file_options_init(opts, GIT_MERGE_FILE_OPTIONS_VERSION);
|
|
||||||
opts.ref.favor = favor;
|
|
||||||
opts.ref.flags = flags;
|
|
||||||
if (ancestorLabel.isNotEmpty) {
|
|
||||||
ancestorLabelC = ancestorLabel.toChar();
|
|
||||||
opts.ref.ancestor_label = ancestorLabelC;
|
|
||||||
}
|
|
||||||
if (oursLabel.isNotEmpty) {
|
|
||||||
oursLabelC = oursLabel.toChar();
|
|
||||||
opts.ref.our_label = oursLabelC;
|
|
||||||
}
|
|
||||||
if (theirsLabel.isNotEmpty) {
|
|
||||||
theirsLabelC = theirsLabel.toChar();
|
|
||||||
opts.ref.their_label = theirsLabelC;
|
|
||||||
}
|
|
||||||
|
|
||||||
final error = libgit2.git_merge_file_from_index(
|
final error = libgit2.git_merge_file_from_index(
|
||||||
out,
|
out,
|
||||||
repoPointer,
|
repoPointer,
|
||||||
ancestorPointer ?? nullptr,
|
ancestorPointer ?? nullptr,
|
||||||
oursPointer,
|
oursPointer,
|
||||||
theirsPointer,
|
theirsPointer,
|
||||||
opts,
|
nullptr,
|
||||||
);
|
);
|
||||||
|
|
||||||
late final String result;
|
late final String result;
|
||||||
|
@ -279,10 +244,6 @@ String mergeFileFromIndex({
|
||||||
result = out.ref.ptr.toDartString(length: out.ref.len);
|
result = out.ref.ptr.toDartString(length: out.ref.len);
|
||||||
}
|
}
|
||||||
|
|
||||||
calloc.free(ancestorLabelC);
|
|
||||||
calloc.free(oursLabelC);
|
|
||||||
calloc.free(theirsLabelC);
|
|
||||||
calloc.free(opts);
|
|
||||||
calloc.free(out);
|
calloc.free(out);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
|
|
|
@ -17,48 +17,13 @@ import 'package:libgit2dart/src/util.dart';
|
||||||
/// HARD reset will trigger a MIXED reset and the working directory will be
|
/// HARD reset will trigger a MIXED reset and the working directory will be
|
||||||
/// replaced with the content of the index. (Untracked and ignored files will
|
/// replaced with the content of the index. (Untracked and ignored files will
|
||||||
/// be left alone, however.)
|
/// be left alone, however.)
|
||||||
///
|
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
|
||||||
void reset({
|
void reset({
|
||||||
required Pointer<git_repository> repoPointer,
|
required Pointer<git_repository> repoPointer,
|
||||||
required Pointer<git_object> targetPointer,
|
required Pointer<git_object> targetPointer,
|
||||||
required int resetType,
|
required int resetType,
|
||||||
int? strategy,
|
required Pointer<git_checkout_options> checkoutOptsPointer,
|
||||||
String? checkoutDirectory,
|
|
||||||
List<String>? pathspec,
|
|
||||||
}) {
|
}) {
|
||||||
final opts = calloc<git_checkout_options>();
|
libgit2.git_reset(repoPointer, targetPointer, resetType, checkoutOptsPointer);
|
||||||
libgit2.git_checkout_options_init(opts, GIT_CHECKOUT_OPTIONS_VERSION);
|
|
||||||
|
|
||||||
if (strategy != null) {
|
|
||||||
opts.ref.checkout_strategy = strategy;
|
|
||||||
}
|
|
||||||
if (checkoutDirectory != null) {
|
|
||||||
opts.ref.target_directory = checkoutDirectory.toChar();
|
|
||||||
}
|
|
||||||
var pathPointers = <Pointer<Char>>[];
|
|
||||||
Pointer<Pointer<Char>> strArray = nullptr;
|
|
||||||
if (pathspec != null) {
|
|
||||||
pathPointers = pathspec.map((e) => e.toChar()).toList();
|
|
||||||
strArray = calloc(pathspec.length);
|
|
||||||
for (var i = 0; i < pathspec.length; i++) {
|
|
||||||
strArray[i] = pathPointers[i];
|
|
||||||
}
|
|
||||||
opts.ref.paths.strings = strArray;
|
|
||||||
opts.ref.paths.count = pathspec.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
final error = libgit2.git_reset(repoPointer, targetPointer, resetType, opts);
|
|
||||||
|
|
||||||
for (final p in pathPointers) {
|
|
||||||
calloc.free(p);
|
|
||||||
}
|
|
||||||
calloc.free(strArray);
|
|
||||||
calloc.free(opts);
|
|
||||||
|
|
||||||
if (error < 0) {
|
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Updates some entries in the index from the target commit tree.
|
/// Updates some entries in the index from the target commit tree.
|
||||||
|
|
|
@ -96,16 +96,8 @@ bool isPrunable(Pointer<git_worktree> wt) {
|
||||||
/// Prune working tree.
|
/// Prune working tree.
|
||||||
///
|
///
|
||||||
/// Prune the working tree, that is remove the git data structures on disk.
|
/// Prune the working tree, that is remove the git data structures on disk.
|
||||||
void prune({required Pointer<git_worktree> worktreePointer, int? flags}) {
|
void prune(Pointer<git_worktree> wt) {
|
||||||
final opts = calloc<git_worktree_prune_options>();
|
libgit2.git_worktree_prune(wt, nullptr);
|
||||||
libgit2.git_worktree_prune_options_init(
|
|
||||||
opts,
|
|
||||||
GIT_WORKTREE_PRUNE_OPTIONS_VERSION,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (flags != null) opts.ref.flags = flags;
|
|
||||||
|
|
||||||
libgit2.git_worktree_prune(worktreePointer, opts);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// List names of linked working trees.
|
/// List names of linked working trees.
|
||||||
|
|
|
@ -12,7 +12,6 @@ class Blob extends Equatable {
|
||||||
/// blob object in memory.
|
/// blob object in memory.
|
||||||
///
|
///
|
||||||
/// Note: For internal use. Use [Blob.lookup] instead.
|
/// Note: For internal use. Use [Blob.lookup] instead.
|
||||||
@internal
|
|
||||||
Blob(this._blobPointer) {
|
Blob(this._blobPointer) {
|
||||||
_finalizer.attach(this, _blobPointer, detach: this);
|
_finalizer.attach(this, _blobPointer, detach: this);
|
||||||
}
|
}
|
||||||
|
@ -31,7 +30,6 @@ class Blob extends Equatable {
|
||||||
/// Pointer to memory address for allocated blob object.
|
/// Pointer to memory address for allocated blob object.
|
||||||
///
|
///
|
||||||
/// Note: For internal use.
|
/// Note: For internal use.
|
||||||
@internal
|
|
||||||
Pointer<git_blob> get pointer => _blobPointer;
|
Pointer<git_blob> get pointer => _blobPointer;
|
||||||
|
|
||||||
/// Creates a new blob from a [content] string and writes it to ODB.
|
/// Creates a new blob from a [content] string and writes it to ODB.
|
||||||
|
|
|
@ -15,7 +15,6 @@ class Branch extends Equatable {
|
||||||
/// Note: For internal use. Instead, use one of:
|
/// Note: For internal use. Instead, use one of:
|
||||||
/// - [Branch.create]
|
/// - [Branch.create]
|
||||||
/// - [Branch.lookup]
|
/// - [Branch.lookup]
|
||||||
@internal
|
|
||||||
Branch(this._branchPointer) {
|
Branch(this._branchPointer) {
|
||||||
_finalizer.attach(this, _branchPointer, detach: this);
|
_finalizer.attach(this, _branchPointer, detach: this);
|
||||||
}
|
}
|
||||||
|
@ -75,7 +74,6 @@ class Branch extends Equatable {
|
||||||
/// Pointer to memory address for allocated branch object.
|
/// Pointer to memory address for allocated branch object.
|
||||||
///
|
///
|
||||||
/// Note: For internal use.
|
/// Note: For internal use.
|
||||||
@internal
|
|
||||||
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
|
/// Returns a list of branches that can be found in a [repo]sitory for
|
||||||
|
|
|
@ -13,7 +13,6 @@ class Commit extends Equatable {
|
||||||
/// commit object in memory.
|
/// commit object in memory.
|
||||||
///
|
///
|
||||||
/// Note: For internal use. Use [Commit.lookup] instead.
|
/// Note: For internal use. Use [Commit.lookup] instead.
|
||||||
@internal
|
|
||||||
Commit(this._commitPointer) {
|
Commit(this._commitPointer) {
|
||||||
_finalizer.attach(this, _commitPointer, detach: this);
|
_finalizer.attach(this, _commitPointer, detach: this);
|
||||||
}
|
}
|
||||||
|
@ -32,7 +31,6 @@ class Commit extends Equatable {
|
||||||
/// Pointer to memory address for allocated commit object.
|
/// Pointer to memory address for allocated commit object.
|
||||||
///
|
///
|
||||||
/// Note: For internal use.
|
/// Note: For internal use.
|
||||||
@internal
|
|
||||||
Pointer<git_commit> get pointer => _commitPointer;
|
Pointer<git_commit> get pointer => _commitPointer;
|
||||||
|
|
||||||
/// Creates new commit in the [repo]sitory.
|
/// Creates new commit in the [repo]sitory.
|
||||||
|
@ -191,64 +189,23 @@ class Commit extends Equatable {
|
||||||
|
|
||||||
/// Reverts commit, producing changes in the index and working directory.
|
/// Reverts commit, producing changes in the index and working directory.
|
||||||
///
|
///
|
||||||
/// [mainline] is parent of the commit if it is a merge (i.e. 1, 2, etc.).
|
|
||||||
///
|
|
||||||
/// [mergeFavor] is one of the optional [GitMergeFileFavor] flags for
|
|
||||||
/// handling conflicting content.
|
|
||||||
///
|
|
||||||
/// [mergeFlags] is optional combination of [GitMergeFlag] flags.
|
|
||||||
///
|
|
||||||
/// [mergeFileFlags] is optional combination of [GitMergeFileFlag] flags.
|
|
||||||
///
|
|
||||||
/// [checkoutStrategy] is optional combination of [GitCheckout] flags.
|
|
||||||
///
|
|
||||||
/// [checkoutDirectory] is optional alternative checkout path to workdir.
|
|
||||||
///
|
|
||||||
/// [checkoutPaths] is optional list of files to checkout (by default all
|
|
||||||
/// paths are processed).
|
|
||||||
///
|
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
void revert({
|
void revert() {
|
||||||
int mainline = 0,
|
|
||||||
GitMergeFileFavor? mergeFavor,
|
|
||||||
Set<GitMergeFlag>? mergeFlags,
|
|
||||||
Set<GitMergeFileFlag>? mergeFileFlags,
|
|
||||||
Set<GitCheckout>? checkoutStrategy,
|
|
||||||
String? checkoutDirectory,
|
|
||||||
List<String>? checkoutPaths,
|
|
||||||
}) {
|
|
||||||
bindings.revert(
|
bindings.revert(
|
||||||
repoPointer: bindings.owner(_commitPointer),
|
repoPointer: bindings.owner(_commitPointer),
|
||||||
commitPointer: _commitPointer,
|
commitPointer: _commitPointer,
|
||||||
mainline: mainline,
|
|
||||||
mergeFavor: mergeFavor?.value,
|
|
||||||
mergeFlags: mergeFlags?.fold(0, (acc, e) => acc! | e.value),
|
|
||||||
mergeFileFlags: mergeFileFlags?.fold(0, (acc, e) => acc! | e.value),
|
|
||||||
checkoutStrategy: checkoutStrategy?.fold(0, (acc, e) => acc! | e.value),
|
|
||||||
checkoutDirectory: checkoutDirectory,
|
|
||||||
checkoutPaths: checkoutPaths,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Reverts commit against provided [commit], producing an index that
|
/// Reverts commit against provided [commit], producing an index that
|
||||||
/// reflects the result of the revert.
|
/// reflects the result of the revert.
|
||||||
///
|
///
|
||||||
/// [mainline] is parent of the commit if it is a merge (i.e. 1, 2, etc.).
|
/// [mainline] is parent of the commit if it is a merge (i.e. 1, 2).
|
||||||
///
|
|
||||||
/// [mergeFavor] is one of the optional [GitMergeFileFavor] flags for
|
|
||||||
/// handling conflicting content.
|
|
||||||
///
|
|
||||||
/// [mergeFlags] is optional combination of [GitMergeFlag] flags.
|
|
||||||
///
|
|
||||||
/// [mergeFileFlags] is optional combination of [GitMergeFileFlag] flags.
|
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
Index revertTo({
|
Index revertTo({
|
||||||
required Commit commit,
|
required Commit commit,
|
||||||
int mainline = 0,
|
int mainline = 0,
|
||||||
GitMergeFileFavor? mergeFavor,
|
|
||||||
Set<GitMergeFlag>? mergeFlags,
|
|
||||||
Set<GitMergeFileFlag>? mergeFileFlags,
|
|
||||||
}) {
|
}) {
|
||||||
return Index(
|
return Index(
|
||||||
bindings.revertCommit(
|
bindings.revertCommit(
|
||||||
|
@ -256,9 +213,6 @@ class Commit extends Equatable {
|
||||||
revertCommitPointer: _commitPointer,
|
revertCommitPointer: _commitPointer,
|
||||||
ourCommitPointer: commit.pointer,
|
ourCommitPointer: commit.pointer,
|
||||||
mainline: mainline,
|
mainline: mainline,
|
||||||
mergeFavor: mergeFavor?.value,
|
|
||||||
mergeFlags: mergeFlags?.fold(0, (acc, e) => acc! | e.value),
|
|
||||||
mergeFileFlags: mergeFileFlags?.fold(0, (acc, e) => acc! | e.value),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@ class Config with IterableMixin<ConfigEntry> {
|
||||||
/// - [Config.system]
|
/// - [Config.system]
|
||||||
/// - [Config.global]
|
/// - [Config.global]
|
||||||
/// - [Config.xdg]
|
/// - [Config.xdg]
|
||||||
@internal
|
|
||||||
Config(this._configPointer) {
|
Config(this._configPointer) {
|
||||||
_finalizer.attach(this, _configPointer, detach: this);
|
_finalizer.attach(this, _configPointer, detach: this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@ class Diff extends Equatable {
|
||||||
/// - [Diff.treeToWorkdirWithIndex]
|
/// - [Diff.treeToWorkdirWithIndex]
|
||||||
/// - [Diff.treeToTree]
|
/// - [Diff.treeToTree]
|
||||||
/// - [Diff.parse]
|
/// - [Diff.parse]
|
||||||
@internal
|
|
||||||
Diff(this._diffPointer) {
|
Diff(this._diffPointer) {
|
||||||
_finalizer.attach(this, _diffPointer, detach: this);
|
_finalizer.attach(this, _diffPointer, detach: this);
|
||||||
}
|
}
|
||||||
|
@ -277,7 +276,6 @@ class Diff extends Equatable {
|
||||||
/// Pointer to memory address for allocated diff object.
|
/// Pointer to memory address for allocated diff object.
|
||||||
///
|
///
|
||||||
/// Note: For internal use.
|
/// Note: For internal use.
|
||||||
@internal
|
|
||||||
Pointer<git_diff> get pointer => _diffPointer;
|
Pointer<git_diff> get pointer => _diffPointer;
|
||||||
|
|
||||||
/// How many diff records are there in a diff.
|
/// How many diff records are there in a diff.
|
||||||
|
@ -473,9 +471,6 @@ final _finalizer = Finalizer<Pointer<git_diff>>(
|
||||||
class DiffDelta extends Equatable {
|
class DiffDelta extends Equatable {
|
||||||
/// Initializes a new instance of [DiffDelta] class from provided
|
/// Initializes a new instance of [DiffDelta] class from provided
|
||||||
/// pointer to diff delta object in memory.
|
/// pointer to diff delta object in memory.
|
||||||
///
|
|
||||||
/// Note: For internal use.
|
|
||||||
@internal
|
|
||||||
const DiffDelta(this._diffDeltaPointer);
|
const DiffDelta(this._diffDeltaPointer);
|
||||||
|
|
||||||
/// Pointer to memory address for allocated diff delta object.
|
/// Pointer to memory address for allocated diff delta object.
|
||||||
|
@ -583,7 +578,6 @@ class DiffStats {
|
||||||
/// pointer to diff stats object in memory.
|
/// pointer to diff stats object in memory.
|
||||||
///
|
///
|
||||||
/// Note: For internal use.
|
/// Note: For internal use.
|
||||||
@internal
|
|
||||||
DiffStats(this._diffStatsPointer) {
|
DiffStats(this._diffStatsPointer) {
|
||||||
_statsFinalizer.attach(this, _diffStatsPointer, detach: this);
|
_statsFinalizer.attach(this, _diffStatsPointer, detach: this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,12 +3,9 @@
|
||||||
import 'dart:ffi';
|
import 'dart:ffi';
|
||||||
import 'package:libgit2dart/src/bindings/libgit2_bindings.dart';
|
import 'package:libgit2dart/src/bindings/libgit2_bindings.dart';
|
||||||
import 'package:libgit2dart/src/extensions.dart';
|
import 'package:libgit2dart/src/extensions.dart';
|
||||||
import 'package:meta/meta.dart';
|
|
||||||
|
|
||||||
/// Details of the last error that occurred.
|
/// Details of the last error that occurred.
|
||||||
class LibGit2Error {
|
class LibGit2Error {
|
||||||
/// Note: For internal use.
|
|
||||||
@internal
|
|
||||||
LibGit2Error(this._errorPointer);
|
LibGit2Error(this._errorPointer);
|
||||||
|
|
||||||
final Pointer<git_error> _errorPointer;
|
final Pointer<git_error> _errorPointer;
|
||||||
|
|
|
@ -1173,37 +1173,3 @@ enum GitBlobFilter {
|
||||||
const GitBlobFilter(this.value);
|
const GitBlobFilter(this.value);
|
||||||
final int value;
|
final int value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Flags for APIs that add files matching pathspec.
|
|
||||||
enum GitIndexAddOption {
|
|
||||||
defaults(0),
|
|
||||||
|
|
||||||
/// Skip the checking of ignore rules.
|
|
||||||
force(1),
|
|
||||||
|
|
||||||
/// Disable glob expansion and force exact matching of files in working
|
|
||||||
/// directory.
|
|
||||||
disablePathspecMatch(2),
|
|
||||||
|
|
||||||
/// Check that each entry in the pathspec is an exact match to a filename on
|
|
||||||
/// disk is either not ignored or already in the index.
|
|
||||||
checkPathspec(4);
|
|
||||||
|
|
||||||
const GitIndexAddOption(this.value);
|
|
||||||
final int value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Flags to alter working tree pruning behavior.
|
|
||||||
enum GitWorktree {
|
|
||||||
/// Prune working tree even if working tree is valid.
|
|
||||||
pruneValid(1),
|
|
||||||
|
|
||||||
/// Prune working tree even if it is locked.
|
|
||||||
pruneLocked(2),
|
|
||||||
|
|
||||||
/// Prune checked out working tree.
|
|
||||||
pruneWorkingTree(4);
|
|
||||||
|
|
||||||
const GitWorktree(this.value);
|
|
||||||
final int value;
|
|
||||||
}
|
|
||||||
|
|
|
@ -13,7 +13,6 @@ class Index with IterableMixin<IndexEntry> {
|
||||||
/// pointer to index object in memory.
|
/// pointer to index object in memory.
|
||||||
///
|
///
|
||||||
/// Note: For internal use.
|
/// Note: For internal use.
|
||||||
@internal
|
|
||||||
Index(this._indexPointer) {
|
Index(this._indexPointer) {
|
||||||
_finalizer.attach(this, _indexPointer, detach: this);
|
_finalizer.attach(this, _indexPointer, detach: this);
|
||||||
}
|
}
|
||||||
|
@ -32,7 +31,6 @@ class Index with IterableMixin<IndexEntry> {
|
||||||
/// Pointer to memory address for allocated index object.
|
/// Pointer to memory address for allocated index object.
|
||||||
///
|
///
|
||||||
/// Note: For internal use.
|
/// Note: For internal use.
|
||||||
@internal
|
|
||||||
Pointer<git_index> get pointer => _indexPointer;
|
Pointer<git_index> get pointer => _indexPointer;
|
||||||
|
|
||||||
/// Full path to the index file on disk.
|
/// Full path to the index file on disk.
|
||||||
|
@ -217,18 +215,9 @@ class Index with IterableMixin<IndexEntry> {
|
||||||
/// that matches will be added to the index (either updating an existing
|
/// that matches will be added to the index (either updating an existing
|
||||||
/// entry or adding a new entry).
|
/// entry or adding a new entry).
|
||||||
///
|
///
|
||||||
/// [flags] is optional combination of [GitIndexAddOption] flags.
|
|
||||||
///
|
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
void addAll(
|
void addAll(List<String> pathspec) {
|
||||||
List<String> pathspec, {
|
bindings.addAll(indexPointer: _indexPointer, pathspec: pathspec);
|
||||||
Set<GitIndexAddOption> flags = const {GitIndexAddOption.defaults},
|
|
||||||
}) {
|
|
||||||
bindings.addAll(
|
|
||||||
indexPointer: _indexPointer,
|
|
||||||
pathspec: pathspec,
|
|
||||||
flags: flags.fold(0, (acc, e) => acc | e.value),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Updates all index entries to match the working directory.
|
/// Updates all index entries to match the working directory.
|
||||||
|
@ -341,7 +330,6 @@ class IndexEntry extends Equatable {
|
||||||
/// Initializes a new instance of [IndexEntry] class.
|
/// Initializes a new instance of [IndexEntry] class.
|
||||||
///
|
///
|
||||||
/// Note: For internal use.
|
/// Note: For internal use.
|
||||||
@internal
|
|
||||||
const IndexEntry(this._indexEntryPointer);
|
const IndexEntry(this._indexEntryPointer);
|
||||||
|
|
||||||
final Pointer<git_index_entry> _indexEntryPointer;
|
final Pointer<git_index_entry> _indexEntryPointer;
|
||||||
|
@ -349,7 +337,6 @@ class IndexEntry extends Equatable {
|
||||||
/// Pointer to memory address for allocated index entry object.
|
/// Pointer to memory address for allocated index entry object.
|
||||||
///
|
///
|
||||||
/// Note: For internal use.
|
/// Note: For internal use.
|
||||||
@internal
|
|
||||||
Pointer<git_index_entry> get pointer => _indexEntryPointer;
|
Pointer<git_index_entry> get pointer => _indexEntryPointer;
|
||||||
|
|
||||||
/// [Oid] of the index entry.
|
/// [Oid] of the index entry.
|
||||||
|
@ -391,7 +378,6 @@ class ConflictEntry {
|
||||||
/// Initializes a new instance of [ConflictEntry] class.
|
/// Initializes a new instance of [ConflictEntry] class.
|
||||||
///
|
///
|
||||||
/// Note: For internal use.
|
/// Note: For internal use.
|
||||||
@internal
|
|
||||||
const ConflictEntry(
|
const ConflictEntry(
|
||||||
this._indexPointer,
|
this._indexPointer,
|
||||||
this._path,
|
this._path,
|
||||||
|
|
|
@ -265,43 +265,18 @@ class Merge {
|
||||||
/// given common [ancestor] as the baseline, producing a string that reflects
|
/// given common [ancestor] as the baseline, producing a string that reflects
|
||||||
/// the merge result containing possible conflicts.
|
/// the merge result containing possible conflicts.
|
||||||
///
|
///
|
||||||
/// [ancestorLabel] is optional label for the ancestor file side of the
|
|
||||||
/// conflict which will be prepended to labels in diff3-format merge files.
|
|
||||||
///
|
|
||||||
/// [oursLabel] is optional label for our file side of the conflict which
|
|
||||||
/// will be prepended to labels in merge files.
|
|
||||||
///
|
|
||||||
/// [theirsLabel] is optional label for their file side of the conflict which
|
|
||||||
/// will be prepended to labels in merge files.
|
|
||||||
///
|
|
||||||
/// [favor] is one of the [GitMergeFileFavor] flags for handling conflicting
|
|
||||||
/// content. Defaults to [GitMergeFileFavor.normal].
|
|
||||||
///
|
|
||||||
/// [flags] is a combination of [GitMergeFileFlag] flags. Defaults to
|
|
||||||
/// [GitMergeFileFlag.defaults].
|
|
||||||
///
|
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
static String fileFromIndex({
|
static String fileFromIndex({
|
||||||
required Repository repo,
|
required Repository repo,
|
||||||
required IndexEntry? ancestor,
|
required IndexEntry? ancestor,
|
||||||
String ancestorLabel = '',
|
|
||||||
required IndexEntry ours,
|
required IndexEntry ours,
|
||||||
String oursLabel = '',
|
|
||||||
required IndexEntry theirs,
|
required IndexEntry theirs,
|
||||||
String theirsLabel = '',
|
|
||||||
GitMergeFileFavor favor = GitMergeFileFavor.normal,
|
|
||||||
Set<GitMergeFileFlag> flags = const {GitMergeFileFlag.defaults},
|
|
||||||
}) {
|
}) {
|
||||||
return bindings.mergeFileFromIndex(
|
return bindings.mergeFileFromIndex(
|
||||||
repoPointer: repo.pointer,
|
repoPointer: repo.pointer,
|
||||||
ancestorPointer: ancestor?.pointer,
|
ancestorPointer: ancestor?.pointer,
|
||||||
ancestorLabel: ancestorLabel,
|
|
||||||
oursPointer: ours.pointer,
|
oursPointer: ours.pointer,
|
||||||
oursLabel: oursLabel,
|
|
||||||
theirsPointer: theirs.pointer,
|
theirsPointer: theirs.pointer,
|
||||||
theirsLabel: theirsLabel,
|
|
||||||
favor: favor.value,
|
|
||||||
flags: flags.fold(0, (acc, e) => acc | e.value),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@ class Note extends Equatable {
|
||||||
/// pointer to note and annotatedOid objects in memory.
|
/// pointer to note and annotatedOid objects in memory.
|
||||||
///
|
///
|
||||||
/// Note: For internal use. Use [Note.lookup] instead.
|
/// Note: For internal use. Use [Note.lookup] instead.
|
||||||
@internal
|
|
||||||
Note(this._notePointer, this._annotatedOidPointer) {
|
Note(this._notePointer, this._annotatedOidPointer) {
|
||||||
_finalizer.attach(this, _notePointer, detach: this);
|
_finalizer.attach(this, _notePointer, detach: this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@ class Odb extends Equatable {
|
||||||
/// pointer to Odb object in memory.
|
/// pointer to Odb object in memory.
|
||||||
///
|
///
|
||||||
/// Note: For internal use.
|
/// Note: For internal use.
|
||||||
@internal
|
|
||||||
Odb(this._odbPointer) {
|
Odb(this._odbPointer) {
|
||||||
_finalizer.attach(this, _odbPointer, detach: this);
|
_finalizer.attach(this, _odbPointer, detach: this);
|
||||||
}
|
}
|
||||||
|
@ -33,7 +32,6 @@ class Odb extends Equatable {
|
||||||
/// Pointer to memory address for allocated oid object.
|
/// Pointer to memory address for allocated oid object.
|
||||||
///
|
///
|
||||||
/// Note: For internal use.
|
/// Note: For internal use.
|
||||||
@internal
|
|
||||||
Pointer<git_odb> get pointer => _odbPointer;
|
Pointer<git_odb> get pointer => _odbPointer;
|
||||||
|
|
||||||
/// Adds an on-disk alternate to an existing Object DB.
|
/// Adds an on-disk alternate to an existing Object DB.
|
||||||
|
|
|
@ -14,7 +14,6 @@ class Oid extends Equatable {
|
||||||
/// pointer to Oid object in memory.
|
/// pointer to Oid object in memory.
|
||||||
///
|
///
|
||||||
/// Note: For internal use. Use [Oid.fromSHA] instead.
|
/// Note: For internal use. Use [Oid.fromSHA] instead.
|
||||||
@internal
|
|
||||||
Oid(this._oidPointer);
|
Oid(this._oidPointer);
|
||||||
|
|
||||||
/// Initializes a new instance of [Oid] class by determining if an object can
|
/// Initializes a new instance of [Oid] class by determining if an object can
|
||||||
|
@ -42,9 +41,6 @@ class Oid extends Equatable {
|
||||||
|
|
||||||
/// Initializes a new instance of [Oid] class from provided raw git_oid
|
/// Initializes a new instance of [Oid] class from provided raw git_oid
|
||||||
/// structure.
|
/// structure.
|
||||||
///
|
|
||||||
/// Note: For internal use.
|
|
||||||
@internal
|
|
||||||
Oid.fromRaw(git_oid raw) {
|
Oid.fromRaw(git_oid raw) {
|
||||||
_oidPointer = bindings.fromRaw(raw.id);
|
_oidPointer = bindings.fromRaw(raw.id);
|
||||||
}
|
}
|
||||||
|
@ -54,7 +50,6 @@ class Oid extends Equatable {
|
||||||
/// Pointer to memory address for allocated oid object.
|
/// Pointer to memory address for allocated oid object.
|
||||||
///
|
///
|
||||||
/// Note: For internal use.
|
/// Note: For internal use.
|
||||||
@internal
|
|
||||||
Pointer<git_oid> get pointer => _oidPointer;
|
Pointer<git_oid> get pointer => _oidPointer;
|
||||||
|
|
||||||
/// Hexadecimal SHA string.
|
/// Hexadecimal SHA string.
|
||||||
|
|
|
@ -2,7 +2,6 @@ import 'dart:ffi';
|
||||||
import 'package:libgit2dart/libgit2dart.dart';
|
import 'package:libgit2dart/libgit2dart.dart';
|
||||||
import 'package:libgit2dart/src/bindings/libgit2_bindings.dart';
|
import 'package:libgit2dart/src/bindings/libgit2_bindings.dart';
|
||||||
import 'package:libgit2dart/src/bindings/packbuilder.dart' as bindings;
|
import 'package:libgit2dart/src/bindings/packbuilder.dart' as bindings;
|
||||||
import 'package:meta/meta.dart';
|
|
||||||
|
|
||||||
class PackBuilder {
|
class PackBuilder {
|
||||||
/// Initializes a new instance of [PackBuilder] class.
|
/// Initializes a new instance of [PackBuilder] class.
|
||||||
|
@ -10,7 +9,6 @@ class PackBuilder {
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
///
|
///
|
||||||
/// Note: For internal use.
|
/// Note: For internal use.
|
||||||
@internal
|
|
||||||
PackBuilder(Repository repo) {
|
PackBuilder(Repository repo) {
|
||||||
_packbuilderPointer = bindings.init(repo.pointer);
|
_packbuilderPointer = bindings.init(repo.pointer);
|
||||||
_finalizer.attach(this, _packbuilderPointer, detach: this);
|
_finalizer.attach(this, _packbuilderPointer, detach: this);
|
||||||
|
|
|
@ -18,7 +18,6 @@ class Patch extends Equatable {
|
||||||
/// - [Patch.fromBlobAndBuffer]
|
/// - [Patch.fromBlobAndBuffer]
|
||||||
/// - [Patch.fromBuffers]
|
/// - [Patch.fromBuffers]
|
||||||
/// - [Patch.fromDiff]
|
/// - [Patch.fromDiff]
|
||||||
@internal
|
|
||||||
Patch(this._patchPointer) {
|
Patch(this._patchPointer) {
|
||||||
_finalizer.attach(this, _patchPointer, detach: this);
|
_finalizer.attach(this, _patchPointer, detach: this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@ class Reference extends Equatable {
|
||||||
/// Note: For internal use. Instead, use one of:
|
/// Note: For internal use. Instead, use one of:
|
||||||
/// - [Reference.create]
|
/// - [Reference.create]
|
||||||
/// - [Reference.lookup]
|
/// - [Reference.lookup]
|
||||||
@internal
|
|
||||||
Reference(this._refPointer) {
|
Reference(this._refPointer) {
|
||||||
_finalizer.attach(this, _refPointer, detach: this);
|
_finalizer.attach(this, _refPointer, detach: this);
|
||||||
}
|
}
|
||||||
|
@ -88,7 +87,6 @@ class Reference extends Equatable {
|
||||||
/// Pointer to memory address for allocated reference object.
|
/// Pointer to memory address for allocated reference object.
|
||||||
///
|
///
|
||||||
/// Note: For internal use.
|
/// Note: For internal use.
|
||||||
@internal
|
|
||||||
Pointer<git_reference> get pointer => _refPointer;
|
Pointer<git_reference> get pointer => _refPointer;
|
||||||
|
|
||||||
/// Deletes an existing reference with provided [name].
|
/// Deletes an existing reference with provided [name].
|
||||||
|
|
|
@ -11,7 +11,6 @@ class Refspec extends Equatable {
|
||||||
/// from provided pointer to refspec object in memory.
|
/// from provided pointer to refspec object in memory.
|
||||||
///
|
///
|
||||||
/// Note: For internal use.
|
/// Note: For internal use.
|
||||||
@internal
|
|
||||||
const Refspec(this._refspecPointer);
|
const Refspec(this._refspecPointer);
|
||||||
|
|
||||||
/// Pointer to memory address for allocated refspec object.
|
/// Pointer to memory address for allocated refspec object.
|
||||||
|
|
|
@ -327,7 +327,6 @@ class TransferProgress {
|
||||||
/// pointer to transfer progress object in memory.
|
/// pointer to transfer progress object in memory.
|
||||||
///
|
///
|
||||||
/// Note: For internal use.
|
/// Note: For internal use.
|
||||||
@internal
|
|
||||||
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.
|
||||||
|
|
|
@ -23,7 +23,6 @@ class Repository extends Equatable {
|
||||||
/// - [Repository.init]
|
/// - [Repository.init]
|
||||||
/// - [Repository.open]
|
/// - [Repository.open]
|
||||||
/// - [Repository.clone]
|
/// - [Repository.clone]
|
||||||
@internal
|
|
||||||
Repository(Pointer<git_repository> pointer) {
|
Repository(Pointer<git_repository> pointer) {
|
||||||
_repoPointer = pointer;
|
_repoPointer = pointer;
|
||||||
_finalizer.attach(this, _repoPointer, detach: this);
|
_finalizer.attach(this, _repoPointer, detach: this);
|
||||||
|
@ -162,7 +161,6 @@ class Repository extends Equatable {
|
||||||
/// Pointer to memory address for allocated repository object.
|
/// Pointer to memory address for allocated repository object.
|
||||||
///
|
///
|
||||||
/// Note: For internal use.
|
/// Note: For internal use.
|
||||||
@internal
|
|
||||||
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
|
/// Looks for a git repository and return its path. The lookup start from
|
||||||
|
@ -557,23 +555,8 @@ class Repository extends Equatable {
|
||||||
///
|
///
|
||||||
/// [resetType] is one of the [GitReset] flags.
|
/// [resetType] is one of the [GitReset] flags.
|
||||||
///
|
///
|
||||||
/// [strategy], [checkoutDirectory] and [pathspec] are optional checkout
|
|
||||||
/// options to be used for a HARD reset.
|
|
||||||
///
|
|
||||||
/// [strategy] is optional combination of [GitCheckout] flags.
|
|
||||||
///
|
|
||||||
/// [checkoutDirectory] is optional alternative checkout path to workdir.
|
|
||||||
///
|
|
||||||
/// [pathspec] is optional list of files to checkout.
|
|
||||||
///
|
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
void reset({
|
void reset({required Oid oid, required GitReset resetType}) {
|
||||||
required Oid oid,
|
|
||||||
required GitReset resetType,
|
|
||||||
Set<GitCheckout>? strategy,
|
|
||||||
String? checkoutDirectory,
|
|
||||||
List<String>? pathspec,
|
|
||||||
}) {
|
|
||||||
final object = object_bindings.lookup(
|
final object = object_bindings.lookup(
|
||||||
repoPointer: _repoPointer,
|
repoPointer: _repoPointer,
|
||||||
oidPointer: oid.pointer,
|
oidPointer: oid.pointer,
|
||||||
|
@ -584,9 +567,7 @@ class Repository extends Equatable {
|
||||||
repoPointer: _repoPointer,
|
repoPointer: _repoPointer,
|
||||||
targetPointer: object,
|
targetPointer: object,
|
||||||
resetType: resetType.value,
|
resetType: resetType.value,
|
||||||
strategy: strategy?.fold(0, (acc, e) => acc! | e.value),
|
checkoutOptsPointer: nullptr,
|
||||||
checkoutDirectory: checkoutDirectory,
|
|
||||||
pathspec: pathspec,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
object_bindings.free(object);
|
object_bindings.free(object);
|
||||||
|
|
|
@ -2,7 +2,6 @@ import 'dart:ffi';
|
||||||
import 'package:libgit2dart/libgit2dart.dart';
|
import 'package:libgit2dart/libgit2dart.dart';
|
||||||
import 'package:libgit2dart/src/bindings/libgit2_bindings.dart';
|
import 'package:libgit2dart/src/bindings/libgit2_bindings.dart';
|
||||||
import 'package:libgit2dart/src/bindings/revwalk.dart' as bindings;
|
import 'package:libgit2dart/src/bindings/revwalk.dart' as bindings;
|
||||||
import 'package:meta/meta.dart';
|
|
||||||
|
|
||||||
class RevWalk {
|
class RevWalk {
|
||||||
/// Initializes a new instance of the [RevWalk] class.
|
/// Initializes a new instance of the [RevWalk] class.
|
||||||
|
@ -16,7 +15,6 @@ class RevWalk {
|
||||||
/// Pointer to memory address for allocated [RevWalk] object.
|
/// Pointer to memory address for allocated [RevWalk] object.
|
||||||
///
|
///
|
||||||
/// Note: For internal use.
|
/// Note: For internal use.
|
||||||
@internal
|
|
||||||
Pointer<git_revwalk> get pointer => _revWalkPointer;
|
Pointer<git_revwalk> get pointer => _revWalkPointer;
|
||||||
|
|
||||||
/// Returns the list of commits from the revision walk.
|
/// Returns the list of commits from the revision walk.
|
||||||
|
|
|
@ -16,7 +16,6 @@ class Signature extends Equatable {
|
||||||
/// Note: For internal use. Instead, use one of:
|
/// Note: For internal use. Instead, use one of:
|
||||||
/// - [Signature.create]
|
/// - [Signature.create]
|
||||||
/// - [Signature.defaultSignature]
|
/// - [Signature.defaultSignature]
|
||||||
@internal
|
|
||||||
Signature(Pointer<git_signature> pointer) {
|
Signature(Pointer<git_signature> pointer) {
|
||||||
_signaturePointer = bindings.duplicate(pointer);
|
_signaturePointer = bindings.duplicate(pointer);
|
||||||
_finalizer.attach(this, _signaturePointer, detach: this);
|
_finalizer.attach(this, _signaturePointer, detach: this);
|
||||||
|
@ -63,7 +62,6 @@ class Signature extends Equatable {
|
||||||
/// Pointer to memory address for allocated signature object.
|
/// Pointer to memory address for allocated signature object.
|
||||||
///
|
///
|
||||||
/// Note: For internal use.
|
/// Note: For internal use.
|
||||||
@internal
|
|
||||||
Pointer<git_signature> get pointer => _signaturePointer;
|
Pointer<git_signature> get pointer => _signaturePointer;
|
||||||
|
|
||||||
/// Full name of the author.
|
/// Full name of the author.
|
||||||
|
|
|
@ -7,9 +7,6 @@ import 'package:meta/meta.dart';
|
||||||
class Stash extends Equatable {
|
class Stash extends Equatable {
|
||||||
/// Initializes a new instance of [Stash] class from provided stash [index],
|
/// Initializes a new instance of [Stash] class from provided stash [index],
|
||||||
/// [message] and [oid].
|
/// [message] and [oid].
|
||||||
///
|
|
||||||
/// Note: For internal use. Use [Stash.create] instead to create stash.
|
|
||||||
@internal
|
|
||||||
const Stash({
|
const Stash({
|
||||||
required this.index,
|
required this.index,
|
||||||
required this.message,
|
required this.message,
|
||||||
|
|
|
@ -13,7 +13,6 @@ class Tag extends Equatable {
|
||||||
/// tag object in memory.
|
/// tag object in memory.
|
||||||
///
|
///
|
||||||
/// Note: For internal use. Use [Tag.lookup] instead.
|
/// Note: For internal use. Use [Tag.lookup] instead.
|
||||||
@internal
|
|
||||||
Tag(this._tagPointer) {
|
Tag(this._tagPointer) {
|
||||||
_finalizer.attach(this, _tagPointer, detach: this);
|
_finalizer.attach(this, _tagPointer, detach: this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@ class Tree extends Equatable {
|
||||||
/// tree object in memory.
|
/// tree object in memory.
|
||||||
///
|
///
|
||||||
/// Note: For internal use. Use [Tree.lookup] instead.
|
/// Note: For internal use. Use [Tree.lookup] instead.
|
||||||
@internal
|
|
||||||
Tree(this._treePointer) {
|
Tree(this._treePointer) {
|
||||||
_finalizer.attach(this, _treePointer, detach: this);
|
_finalizer.attach(this, _treePointer, detach: this);
|
||||||
}
|
}
|
||||||
|
@ -31,7 +30,6 @@ class Tree extends Equatable {
|
||||||
/// Pointer to memory address for allocated tree object.
|
/// Pointer to memory address for allocated tree object.
|
||||||
///
|
///
|
||||||
/// Note: For internal use.
|
/// Note: For internal use.
|
||||||
@internal
|
|
||||||
Pointer<git_tree> get pointer => _treePointer;
|
Pointer<git_tree> get pointer => _treePointer;
|
||||||
|
|
||||||
/// List with tree entries of a tree.
|
/// List with tree entries of a tree.
|
||||||
|
@ -115,7 +113,6 @@ class TreeEntry extends Equatable {
|
||||||
/// tree entry object in memory.
|
/// tree entry object in memory.
|
||||||
///
|
///
|
||||||
/// Note: For internal use.
|
/// Note: For internal use.
|
||||||
@internal
|
|
||||||
const TreeEntry(this._treeEntryPointer);
|
const TreeEntry(this._treeEntryPointer);
|
||||||
|
|
||||||
/// Initializes a new instance of [TreeEntry] class from provided pointer to
|
/// Initializes a new instance of [TreeEntry] class from provided pointer to
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
// coverage:ignore-file
|
// coverage:ignore-file
|
||||||
|
|
||||||
import 'dart:convert';
|
|
||||||
import 'dart:ffi';
|
import 'dart:ffi';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:libgit2dart/src/bindings/libgit2_bindings.dart';
|
import 'package:libgit2dart/src/bindings/libgit2_bindings.dart';
|
||||||
import 'package:libgit2dart/src/bindings/libgit2_opts_bindings.dart';
|
import 'package:libgit2dart/src/bindings/libgit2_opts_bindings.dart';
|
||||||
import 'package:path/path.dart' as path;
|
import 'package:path/path.dart' as path;
|
||||||
import 'package:pub_semver/pub_semver.dart';
|
import 'package:pub_cache/pub_cache.dart';
|
||||||
|
|
||||||
const libgit2Version = '1.5.0';
|
const libgit2Version = '1.4.3';
|
||||||
final libDir = path.join('.dart_tool', 'libgit2');
|
final libDir = path.join('.dart_tool', 'libgit2');
|
||||||
|
|
||||||
String getLibName() {
|
String getLibName() {
|
||||||
|
@ -26,20 +25,6 @@ String getLibName() {
|
||||||
return 'libgit2-$libgit2Version.$ext';
|
return 'libgit2-$libgit2Version.$ext';
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns location of the most recent verison of the libgit2dart package
|
|
||||||
/// contained in the cache.
|
|
||||||
String? checkCache() {
|
|
||||||
final cache = json.decode(
|
|
||||||
Process.runSync('dart', ['pub', 'cache', 'list']).stdout as String,
|
|
||||||
) as Map<String, dynamic>;
|
|
||||||
final packages = cache['packages'] as Map<String, dynamic>;
|
|
||||||
final libPackages = packages['libgit2dart'] as Map<String, dynamic>?;
|
|
||||||
final versions = libPackages?.keys.map((e) => Version.parse(e)).toList();
|
|
||||||
final latestVersion = libPackages?[Version.primary(versions!).toString()]
|
|
||||||
as Map<String, dynamic>?;
|
|
||||||
return latestVersion?['location'] as String?;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Checks if [File]/[Link] exists for [path].
|
/// Checks if [File]/[Link] exists for [path].
|
||||||
bool _doesFileExist(String path) {
|
bool _doesFileExist(String path) {
|
||||||
return File(path).existsSync() || Link(path).existsSync();
|
return File(path).existsSync() || Link(path).existsSync();
|
||||||
|
@ -68,22 +53,18 @@ String? _resolveLibPath(String name) {
|
||||||
libPath = path.join(path.dirname(Platform.resolvedExecutable), 'lib', name);
|
libPath = path.join(path.dirname(Platform.resolvedExecutable), 'lib', name);
|
||||||
if (_doesFileExist(libPath)) return libPath;
|
if (_doesFileExist(libPath)) return libPath;
|
||||||
|
|
||||||
// If lib is installed in system dir.
|
String checkCache(PubCache pubCache) {
|
||||||
if (Platform.isMacOS || Platform.isLinux) {
|
final pubCacheDir =
|
||||||
final paths = [
|
pubCache.getLatestVersion('libgit2dart')!.resolve()!.location;
|
||||||
'/usr/local/lib/libgit2.$libgit2Version.dylib',
|
return path.join(pubCacheDir.path, Platform.operatingSystem, name);
|
||||||
'/usr/local/lib/libgit2.so.$libgit2Version',
|
|
||||||
'/usr/lib64/libgit2.so.$libgit2Version'
|
|
||||||
];
|
|
||||||
for (final path in paths) {
|
|
||||||
if (_doesFileExist(path)) return path;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If lib is in '.pub_cache' folder.
|
// If lib is in Flutter's '.pub_cache' folder.
|
||||||
final cachedLocation = checkCache();
|
final env = Platform.environment;
|
||||||
if (cachedLocation != null) {
|
if (env.containsKey('FLUTTER_ROOT')) {
|
||||||
libPath = path.join(cachedLocation, Platform.operatingSystem, name);
|
final flutterPubCache =
|
||||||
|
PubCache(Directory(path.join(env['FLUTTER_ROOT']!, '.pub-cache')));
|
||||||
|
libPath = checkCache(flutterPubCache);
|
||||||
if (_doesFileExist(libPath)) return libPath;
|
if (_doesFileExist(libPath)) return libPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,15 +77,10 @@ class Worktree extends Equatable {
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
bool get isPrunable => bindings.isPrunable(_worktreePointer);
|
bool get isPrunable => bindings.isPrunable(_worktreePointer);
|
||||||
|
|
||||||
/// Prunes working tree, that is removes the git data structures on disk.
|
/// Prunes working tree.
|
||||||
///
|
///
|
||||||
/// [flags] is optional combination of [GitWorktree] flags.
|
/// Prune the working tree, that is remove the git data structures on disk.
|
||||||
void prune([Set<GitWorktree>? flags]) {
|
void prune() => bindings.prune(_worktreePointer);
|
||||||
bindings.prune(
|
|
||||||
worktreePointer: _worktreePointer,
|
|
||||||
flags: flags?.fold(0, (acc, e) => acc! | e.value),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Whether worktree is valid.
|
/// Whether worktree is valid.
|
||||||
///
|
///
|
||||||
|
|
|
@ -20,6 +20,6 @@ target_link_libraries(${PLUGIN_NAME} PRIVATE PkgConfig::GTK)
|
||||||
|
|
||||||
# List of absolute paths to libraries that should be bundled with the plugin
|
# List of absolute paths to libraries that should be bundled with the plugin
|
||||||
set(libgit2dart_bundled_libraries
|
set(libgit2dart_bundled_libraries
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/libgit2-1.5.0.so"
|
"${CMAKE_CURRENT_SOURCE_DIR}/libgit2-1.4.3.so"
|
||||||
PARENT_SCOPE
|
PARENT_SCOPE
|
||||||
)
|
)
|
||||||
|
|
BIN
linux/libgit2-1.4.3.so
Normal file
BIN
linux/libgit2-1.4.3.so
Normal file
Binary file not shown.
Binary file not shown.
BIN
macos/libgit2-1.4.3.dylib
Normal file
BIN
macos/libgit2-1.4.3.dylib
Normal file
Binary file not shown.
Binary file not shown.
|
@ -4,7 +4,7 @@
|
||||||
#
|
#
|
||||||
Pod::Spec.new do |s|
|
Pod::Spec.new do |s|
|
||||||
s.name = 'libgit2dart'
|
s.name = 'libgit2dart'
|
||||||
s.version = '1.2.2'
|
s.version = '1.1.2'
|
||||||
s.summary = 'Dart bindings to libgit2.'
|
s.summary = 'Dart bindings to libgit2.'
|
||||||
s.description = <<-DESC
|
s.description = <<-DESC
|
||||||
Dart bindings to libgit2.
|
Dart bindings to libgit2.
|
||||||
|
@ -15,7 +15,7 @@ Dart bindings to libgit2.
|
||||||
s.source = { :path => '.' }
|
s.source = { :path => '.' }
|
||||||
s.source_files = 'Classes/**/*'
|
s.source_files = 'Classes/**/*'
|
||||||
s.dependency 'FlutterMacOS'
|
s.dependency 'FlutterMacOS'
|
||||||
s.vendored_libraries = 'libgit2-1.5.0.dylib'
|
s.vendored_libraries = 'libgit2-1.4.3.dylib'
|
||||||
|
|
||||||
s.platform = :osx, '10.11'
|
s.platform = :osx, '10.11'
|
||||||
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }
|
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }
|
||||||
|
|
12
pubspec.yaml
12
pubspec.yaml
|
@ -2,24 +2,24 @@ name: libgit2dart
|
||||||
|
|
||||||
description: Dart bindings to libgit2, provides ability to use libgit2 library in Dart and Flutter.
|
description: Dart bindings to libgit2, provides ability to use libgit2 library in Dart and Flutter.
|
||||||
|
|
||||||
version: 1.2.2
|
version: 1.1.2
|
||||||
|
|
||||||
homepage: https://github.com/SkinnyMind/libgit2dart
|
homepage: https://github.com/SkinnyMind/libgit2dart
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.18.0 <3.0.0"
|
sdk: ">=2.17.0 <3.0.0"
|
||||||
flutter: ">=3.3.0"
|
flutter: ">=3.0.0"
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
args: ^2.3.0
|
args: ^2.3.0
|
||||||
equatable: ^2.0.3
|
equatable: ^2.0.3
|
||||||
ffi: ^2.0.0
|
ffi: ^1.1.2
|
||||||
meta: ^1.7.0
|
meta: ^1.7.0
|
||||||
path: ^1.8.1
|
path: ^1.8.1
|
||||||
pub_semver: ^2.1.3
|
pub_cache: ^0.3.1
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
ffigen: ^6.0.1
|
ffigen: ^5.0.0
|
||||||
lints: ^2.0.0
|
lints: ^2.0.0
|
||||||
test: ^1.20.0
|
test: ^1.20.0
|
||||||
|
|
||||||
|
|
|
@ -67,109 +67,6 @@ void main() {
|
||||||
expect(file.existsSync(), false);
|
expect(file.existsSync(), false);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('reverts merge commit to provided parent', () {
|
|
||||||
const masterContents = 'master contents';
|
|
||||||
final file = File(p.join(repo.workdir, 'another_feature_file'))
|
|
||||||
..createSync()
|
|
||||||
..writeAsStringSync(masterContents);
|
|
||||||
|
|
||||||
repo.index.add('another_feature_file');
|
|
||||||
repo.index.write();
|
|
||||||
|
|
||||||
// Creating commit on 'master' branch with file contents conflicting to
|
|
||||||
// 'feature' branch.
|
|
||||||
final masterTip = Commit.create(
|
|
||||||
repo: repo,
|
|
||||||
updateRef: 'HEAD',
|
|
||||||
message: 'master commit\n',
|
|
||||||
author: author,
|
|
||||||
committer: committer,
|
|
||||||
tree: Tree.lookup(repo: repo, oid: repo.index.writeTree()),
|
|
||||||
parents: [Commit.lookup(repo: repo, oid: repo.head.target)],
|
|
||||||
);
|
|
||||||
|
|
||||||
// Switching to 'feature' branch.
|
|
||||||
Checkout.reference(repo: repo, name: 'refs/heads/feature');
|
|
||||||
repo.setHead('refs/heads/feature');
|
|
||||||
|
|
||||||
file.writeAsStringSync('feature contents');
|
|
||||||
|
|
||||||
repo.index.add('another_feature_file');
|
|
||||||
repo.index.write();
|
|
||||||
|
|
||||||
// Creating commit on 'feature' branch with file contents conflicting to
|
|
||||||
// 'master' branch.
|
|
||||||
final featureTip = Commit.create(
|
|
||||||
repo: repo,
|
|
||||||
updateRef: 'HEAD',
|
|
||||||
message: 'feature commit\n',
|
|
||||||
author: author,
|
|
||||||
committer: committer,
|
|
||||||
tree: Tree.lookup(repo: repo, oid: repo.index.writeTree()),
|
|
||||||
parents: [Commit.lookup(repo: repo, oid: repo.head.target)],
|
|
||||||
);
|
|
||||||
|
|
||||||
// Merging master branch.
|
|
||||||
Merge.commit(
|
|
||||||
repo: repo,
|
|
||||||
commit: AnnotatedCommit.lookup(
|
|
||||||
repo: repo,
|
|
||||||
oid: Oid.fromSHA(repo: repo, sha: masterTip.sha),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(repo.index.hasConflicts, true);
|
|
||||||
|
|
||||||
// "Resolving" conflict.
|
|
||||||
repo.index.updateAll(['another_feature_file']);
|
|
||||||
repo.index.write();
|
|
||||||
repo.stateCleanup();
|
|
||||||
|
|
||||||
// Creating merge commit.
|
|
||||||
final mergeOid = Commit.create(
|
|
||||||
repo: repo,
|
|
||||||
updateRef: 'HEAD',
|
|
||||||
message: 'merge commit\n',
|
|
||||||
author: author,
|
|
||||||
committer: committer,
|
|
||||||
tree: Tree.lookup(repo: repo, oid: repo.index.writeTree()),
|
|
||||||
parents: [
|
|
||||||
Commit.lookup(repo: repo, oid: featureTip),
|
|
||||||
Commit.lookup(repo: repo, oid: masterTip),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
|
|
||||||
final mergeCommit = Commit.lookup(repo: repo, oid: mergeOid);
|
|
||||||
mergeCommit.revert(mainline: 2);
|
|
||||||
|
|
||||||
expect(file.readAsStringSync(), masterContents);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('reverts commit with provided merge options and checkout options', () {
|
|
||||||
final commit = Commit.lookup(repo: repo, oid: repo['821ed6e']);
|
|
||||||
final file = File(p.join(repo.workdir, 'dir', 'dir_file.txt'));
|
|
||||||
expect(repo.index.find('dir/dir_file.txt'), true);
|
|
||||||
expect(file.existsSync(), true);
|
|
||||||
|
|
||||||
commit.revert(
|
|
||||||
mergeFavor: GitMergeFileFavor.ours,
|
|
||||||
mergeFlags: {GitMergeFlag.noRecursive, GitMergeFlag.skipREUC},
|
|
||||||
mergeFileFlags: {
|
|
||||||
GitMergeFileFlag.ignoreWhitespace,
|
|
||||||
GitMergeFileFlag.styleZdiff3
|
|
||||||
},
|
|
||||||
checkoutStrategy: {
|
|
||||||
GitCheckout.force,
|
|
||||||
GitCheckout.conflictStyleMerge,
|
|
||||||
},
|
|
||||||
checkoutDirectory: repo.workdir,
|
|
||||||
checkoutPaths: ['dir/dir_file.txt'],
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(repo.index.find('dir/dir_file.txt'), false);
|
|
||||||
expect(file.existsSync(), false);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('throws when trying to revert and error occurs', () {
|
test('throws when trying to revert and error occurs', () {
|
||||||
expect(() => Commit(nullptr).revert(), throwsA(isA<LibGit2Error>()));
|
expect(() => Commit(nullptr).revert(), throwsA(isA<LibGit2Error>()));
|
||||||
});
|
});
|
||||||
|
@ -187,25 +84,6 @@ void main() {
|
||||||
expect(file.existsSync(), true);
|
expect(file.existsSync(), true);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('reverts commit to provided commit with provided merge options', () {
|
|
||||||
final file = File(p.join(repo.workdir, 'dir', 'dir_file.txt'));
|
|
||||||
expect(repo.index.find('dir/dir_file.txt'), true);
|
|
||||||
expect(file.existsSync(), true);
|
|
||||||
|
|
||||||
final from = Commit.lookup(repo: repo, oid: repo['821ed6e']);
|
|
||||||
final revertIndex = from.revertTo(
|
|
||||||
commit: Commit.lookup(repo: repo, oid: repo['78b8bf1']),
|
|
||||||
mergeFavor: GitMergeFileFavor.ours,
|
|
||||||
mergeFlags: {GitMergeFlag.noRecursive, GitMergeFlag.skipREUC},
|
|
||||||
mergeFileFlags: {
|
|
||||||
GitMergeFileFlag.ignoreWhitespace,
|
|
||||||
GitMergeFileFlag.styleZdiff3
|
|
||||||
},
|
|
||||||
);
|
|
||||||
expect(revertIndex.find('dir/dir_file.txt'), false);
|
|
||||||
expect(file.existsSync(), true);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('throws when trying to revert commit and error occurs', () {
|
test('throws when trying to revert commit and error occurs', () {
|
||||||
final nullCommit = Commit(nullptr);
|
final nullCommit = Commit(nullptr);
|
||||||
expect(
|
expect(
|
||||||
|
|
|
@ -83,7 +83,10 @@ void main() {
|
||||||
cloneDir.deleteSync(recursive: true);
|
cloneDir.deleteSync(recursive: true);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('clones repository with provided keypair', () {
|
test(
|
||||||
|
testOn: '!linux',
|
||||||
|
'clones repository with provided keypair',
|
||||||
|
() {
|
||||||
final cloneDir = Directory.systemTemp.createTempSync('clone');
|
final cloneDir = Directory.systemTemp.createTempSync('clone');
|
||||||
final keypair = Keypair(
|
final keypair = Keypair(
|
||||||
username: 'git',
|
username: 'git',
|
||||||
|
@ -104,7 +107,8 @@ void main() {
|
||||||
if (Platform.isLinux || Platform.isMacOS) {
|
if (Platform.isLinux || Platform.isMacOS) {
|
||||||
cloneDir.deleteSync(recursive: true);
|
cloneDir.deleteSync(recursive: true);
|
||||||
}
|
}
|
||||||
});
|
},
|
||||||
|
);
|
||||||
|
|
||||||
test('throws when no credentials is provided', () {
|
test('throws when no credentials is provided', () {
|
||||||
final cloneDir = Directory.systemTemp.createTempSync('clone');
|
final cloneDir = Directory.systemTemp.createTempSync('clone');
|
||||||
|
@ -185,7 +189,10 @@ void main() {
|
||||||
cloneDir.deleteSync(recursive: true);
|
cloneDir.deleteSync(recursive: true);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('clones repository with provided keypair from memory', () {
|
test(
|
||||||
|
testOn: '!linux',
|
||||||
|
'clones repository with provided keypair from memory',
|
||||||
|
() {
|
||||||
final cloneDir = Directory.systemTemp.createTempSync('clone');
|
final cloneDir = Directory.systemTemp.createTempSync('clone');
|
||||||
final pubKey = File(p.join('test', 'assets', 'keys', 'id_rsa.pub'))
|
final pubKey = File(p.join('test', 'assets', 'keys', 'id_rsa.pub'))
|
||||||
.readAsStringSync();
|
.readAsStringSync();
|
||||||
|
@ -210,7 +217,8 @@ void main() {
|
||||||
if (Platform.isLinux || Platform.isMacOS) {
|
if (Platform.isLinux || Platform.isMacOS) {
|
||||||
cloneDir.deleteSync(recursive: true);
|
cloneDir.deleteSync(recursive: true);
|
||||||
}
|
}
|
||||||
});
|
},
|
||||||
|
);
|
||||||
|
|
||||||
test('throws when provided keypair from memory is incorrect', () {
|
test('throws when provided keypair from memory is incorrect', () {
|
||||||
final cloneDir = Directory.systemTemp.createTempSync('clone');
|
final cloneDir = Directory.systemTemp.createTempSync('clone');
|
||||||
|
|
|
@ -551,25 +551,4 @@ void main() {
|
||||||
expect(actual, expected);
|
expect(actual, expected);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('GitIndexAddOption returns correct values', () {
|
|
||||||
const expected = {
|
|
||||||
GitIndexAddOption.defaults: 0,
|
|
||||||
GitIndexAddOption.force: 1,
|
|
||||||
GitIndexAddOption.disablePathspecMatch: 2,
|
|
||||||
GitIndexAddOption.checkPathspec: 4,
|
|
||||||
};
|
|
||||||
final actual = {for (final e in GitIndexAddOption.values) e: e.value};
|
|
||||||
expect(actual, expected);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('GitWorktree returns correct values', () {
|
|
||||||
const expected = {
|
|
||||||
GitWorktree.pruneValid: 1,
|
|
||||||
GitWorktree.pruneLocked: 2,
|
|
||||||
GitWorktree.pruneWorkingTree: 4,
|
|
||||||
};
|
|
||||||
final actual = {for (final e in GitWorktree.values) e: e.value};
|
|
||||||
expect(actual, expected);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,10 +175,7 @@ void main() {
|
||||||
group('addAll()', () {
|
group('addAll()', () {
|
||||||
test('adds with provided pathspec', () {
|
test('adds with provided pathspec', () {
|
||||||
index.clear();
|
index.clear();
|
||||||
index.addAll(
|
index.addAll(['file', 'feature_file']);
|
||||||
['file', 'feature_file'],
|
|
||||||
flags: {GitIndexAddOption.checkPathspec, GitIndexAddOption.force},
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(index.length, 2);
|
expect(index.length, 2);
|
||||||
expect(index['file'].oid.sha, fileSha);
|
expect(index['file'].oid.sha, fileSha);
|
||||||
|
|
|
@ -168,38 +168,31 @@ Another feature edit
|
||||||
expect(diff, diffExpected);
|
expect(diff, diffExpected);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('merges with provided options', () {
|
test('merges with provided merge flags and file flags', () {
|
||||||
const diffExpected = """
|
const diffExpected = """
|
||||||
\<<<<<<< ours
|
\<<<<<<< conflict_file
|
||||||
Feature edit on feature branch
|
master conflict edit
|
||||||
||||||| ancestor
|
|
||||||
Feature edit
|
|
||||||
=======
|
=======
|
||||||
Another feature edit
|
conflict branch edit
|
||||||
>>>>>>> theirs
|
>>>>>>> conflict_file
|
||||||
""";
|
""";
|
||||||
|
|
||||||
Checkout.reference(repo: repo, name: 'refs/heads/feature');
|
|
||||||
repo.setHead('refs/heads/feature');
|
|
||||||
|
|
||||||
Merge.commit(
|
Merge.commit(
|
||||||
repo: repo,
|
repo: repo,
|
||||||
commit: AnnotatedCommit.lookup(
|
commit: AnnotatedCommit.lookup(
|
||||||
repo: repo,
|
repo: repo,
|
||||||
oid: Branch.lookup(repo: repo, name: 'ancestor-conflict').target,
|
oid: Branch.lookup(repo: repo, name: 'conflict-branch').target,
|
||||||
),
|
),
|
||||||
|
mergeFlags: {GitMergeFlag.noRecursive},
|
||||||
|
fileFlags: {GitMergeFileFlag.ignoreWhitespaceEOL},
|
||||||
);
|
);
|
||||||
|
|
||||||
final conflictedFile = repo.index.conflicts['feature_file']!;
|
final conflictedFile = repo.index.conflicts['conflict_file']!;
|
||||||
final diff = Merge.fileFromIndex(
|
final diff = Merge.fileFromIndex(
|
||||||
repo: repo,
|
repo: repo,
|
||||||
ancestor: conflictedFile.ancestor,
|
ancestor: null,
|
||||||
ancestorLabel: 'ancestor',
|
|
||||||
ours: conflictedFile.our!,
|
ours: conflictedFile.our!,
|
||||||
oursLabel: 'ours',
|
|
||||||
theirs: conflictedFile.their!,
|
theirs: conflictedFile.their!,
|
||||||
theirsLabel: 'theirs',
|
|
||||||
flags: {GitMergeFileFlag.styleDiff3},
|
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(diff, diffExpected);
|
expect(diff, diffExpected);
|
||||||
|
|
|
@ -278,7 +278,7 @@ void main() {
|
||||||
expect(refs.first.localId, null);
|
expect(refs.first.localId, null);
|
||||||
expect(refs.first.name, 'HEAD');
|
expect(refs.first.name, 'HEAD');
|
||||||
expect(refs.first.symRef, 'refs/heads/master');
|
expect(refs.first.symRef, 'refs/heads/master');
|
||||||
expect(refs.first.oid.sha, '49322bb17d3acc9146f98c97d078513228bbf3c0');
|
expect((refs.first.oid).sha, '49322bb17d3acc9146f98c97d078513228bbf3c0');
|
||||||
expect(refs.first.toString(), contains('RemoteReference{'));
|
expect(refs.first.toString(), contains('RemoteReference{'));
|
||||||
expect(refs.first, remote.ls().first);
|
expect(refs.first, remote.ls().first);
|
||||||
});
|
});
|
||||||
|
|
|
@ -50,34 +50,6 @@ void main() {
|
||||||
expect(diff.deltas.length, 1);
|
expect(diff.deltas.length, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('resets with provided checkout options', () {
|
|
||||||
expect(file.readAsStringSync(), 'Feature edit\n');
|
|
||||||
|
|
||||||
repo.reset(
|
|
||||||
oid: repo[sha],
|
|
||||||
resetType: GitReset.hard,
|
|
||||||
strategy: {GitCheckout.conflictStyleZdiff3},
|
|
||||||
pathspec: ['feature_file'],
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(file.readAsStringSync(), isEmpty);
|
|
||||||
});
|
|
||||||
|
|
||||||
test(
|
|
||||||
'throws when trying to reset and error occurs',
|
|
||||||
testOn: '!windows',
|
|
||||||
() {
|
|
||||||
expect(
|
|
||||||
() => repo.reset(
|
|
||||||
oid: repo[sha],
|
|
||||||
resetType: GitReset.hard,
|
|
||||||
checkoutDirectory: '',
|
|
||||||
),
|
|
||||||
throwsA(isA<LibGit2Error>()),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
group('resetDefault', () {
|
group('resetDefault', () {
|
||||||
test('updates entry in the index', () {
|
test('updates entry in the index', () {
|
||||||
file.writeAsStringSync('new edit');
|
file.writeAsStringSync('new edit');
|
||||||
|
|
|
@ -151,22 +151,6 @@ void main() {
|
||||||
expect(repo.worktrees, <String>[]);
|
expect(repo.worktrees, <String>[]);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('prunes worktree with provided flags', () {
|
|
||||||
expect(repo.worktrees, <String>[]);
|
|
||||||
|
|
||||||
final worktree = Worktree.create(
|
|
||||||
repo: repo,
|
|
||||||
name: worktreeName,
|
|
||||||
path: worktreeDir.path,
|
|
||||||
);
|
|
||||||
expect(repo.worktrees, [worktreeName]);
|
|
||||||
expect(worktree.isPrunable, false);
|
|
||||||
expect(worktree.isValid, true);
|
|
||||||
|
|
||||||
worktree.prune({GitWorktree.pruneValid});
|
|
||||||
expect(repo.worktrees, <String>[]);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('throws when trying get list of worktrees and error occurs', () {
|
test('throws when trying get list of worktrees and error occurs', () {
|
||||||
expect(
|
expect(
|
||||||
() => Worktree.list(Repository(nullptr)),
|
() => Worktree.list(Repository(nullptr)),
|
||||||
|
|
|
@ -19,6 +19,6 @@ target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin)
|
||||||
|
|
||||||
# List of absolute paths to libraries that should be bundled with the plugin
|
# List of absolute paths to libraries that should be bundled with the plugin
|
||||||
set(libgit2dart_bundled_libraries
|
set(libgit2dart_bundled_libraries
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/libgit2-1.5.0.dll"
|
"${CMAKE_CURRENT_SOURCE_DIR}/libgit2-1.4.3.dll"
|
||||||
PARENT_SCOPE
|
PARENT_SCOPE
|
||||||
)
|
)
|
||||||
|
|
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue