mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-07 13:29:09 -04:00
Compare commits
No commits in common. "aa74c46a1290848186309052e2251380692777a3" and "a708d54b0aa917f056d3570d8ee54fcbd572d3da" have entirely different histories.
aa74c46a12
...
a708d54b0a
7 changed files with 6 additions and 54 deletions
|
@ -1,9 +1,3 @@
|
||||||
## 1.1.2
|
|
||||||
|
|
||||||
- fix: lookup library in Flutter's .pub_cache folder
|
|
||||||
|
|
||||||
- feat: add ability to limit number of commits to walk in revision walk
|
|
||||||
|
|
||||||
## 1.1.1
|
## 1.1.1
|
||||||
|
|
||||||
- fix: lookup library in correct locations
|
- fix: lookup library in correct locations
|
||||||
|
|
|
@ -145,12 +145,11 @@ void pushRange({
|
||||||
List<Pointer<git_commit>> walk({
|
List<Pointer<git_commit>> walk({
|
||||||
required Pointer<git_repository> repoPointer,
|
required Pointer<git_repository> repoPointer,
|
||||||
required Pointer<git_revwalk> walkerPointer,
|
required Pointer<git_revwalk> walkerPointer,
|
||||||
required int limit,
|
|
||||||
}) {
|
}) {
|
||||||
final result = <Pointer<git_commit>>[];
|
final result = <Pointer<git_commit>>[];
|
||||||
var error = 0;
|
var error = 0;
|
||||||
|
|
||||||
void next() {
|
while (error == 0) {
|
||||||
final oid = calloc<git_oid>();
|
final oid = calloc<git_oid>();
|
||||||
error = libgit2.git_revwalk_next(oid, walkerPointer);
|
error = libgit2.git_revwalk_next(oid, walkerPointer);
|
||||||
if (error == 0) {
|
if (error == 0) {
|
||||||
|
@ -159,21 +158,10 @@ List<Pointer<git_commit>> walk({
|
||||||
oidPointer: oid,
|
oidPointer: oid,
|
||||||
);
|
);
|
||||||
result.add(commit);
|
result.add(commit);
|
||||||
calloc.free(oid);
|
|
||||||
} else {
|
} else {
|
||||||
calloc.free(oid);
|
break;
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (limit == 0) {
|
|
||||||
while (error == 0) {
|
|
||||||
next();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (var i = 0; i < limit; i++) {
|
|
||||||
next();
|
|
||||||
}
|
}
|
||||||
|
calloc.free(oid);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -19,15 +19,11 @@ class RevWalk {
|
||||||
|
|
||||||
/// Returns the list of commits from the revision walk.
|
/// Returns the list of commits from the revision walk.
|
||||||
///
|
///
|
||||||
/// [limit] is optional number of commits to walk (by default walks through
|
|
||||||
/// all of the commits pushed onto the walker).
|
|
||||||
///
|
|
||||||
/// Default sorting is reverse chronological order (default in git).
|
/// Default sorting is reverse chronological order (default in git).
|
||||||
List<Commit> walk({int limit = 0}) {
|
List<Commit> walk() {
|
||||||
final pointers = bindings.walk(
|
final pointers = bindings.walk(
|
||||||
repoPointer: bindings.repository(_revWalkPointer),
|
repoPointer: bindings.repository(_revWalkPointer),
|
||||||
walkerPointer: _revWalkPointer,
|
walkerPointer: _revWalkPointer,
|
||||||
limit: limit,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return pointers.map((e) => Commit(e)).toList();
|
return pointers.map((e) => Commit(e)).toList();
|
||||||
|
|
|
@ -6,7 +6,6 @@ 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_cache/pub_cache.dart';
|
|
||||||
|
|
||||||
const libgit2Version = '1.4.3';
|
const libgit2Version = '1.4.3';
|
||||||
final libDir = path.join('.dart_tool', 'libgit2');
|
final libDir = path.join('.dart_tool', 'libgit2');
|
||||||
|
@ -53,21 +52,6 @@ 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;
|
||||||
|
|
||||||
String checkCache(PubCache pubCache) {
|
|
||||||
final pubCacheDir =
|
|
||||||
pubCache.getLatestVersion('libgit2dart')!.resolve()!.location;
|
|
||||||
return path.join(pubCacheDir.path, Platform.operatingSystem, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If lib is in Flutter's '.pub_cache' folder.
|
|
||||||
final env = Platform.environment;
|
|
||||||
if (env.containsKey('FLUTTER_ROOT')) {
|
|
||||||
final flutterPubCache =
|
|
||||||
PubCache(Directory(path.join(env['FLUTTER_ROOT']!, '.pub-cache')));
|
|
||||||
libPath = checkCache(flutterPubCache);
|
|
||||||
if (_doesFileExist(libPath)) return libPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#
|
#
|
||||||
Pod::Spec.new do |s|
|
Pod::Spec.new do |s|
|
||||||
s.name = 'libgit2dart'
|
s.name = 'libgit2dart'
|
||||||
s.version = '1.1.2'
|
s.version = '1.1.1'
|
||||||
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.
|
||||||
|
|
|
@ -2,7 +2,7 @@ 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.1.2
|
version: 1.1.1
|
||||||
|
|
||||||
homepage: https://github.com/SkinnyMind/libgit2dart
|
homepage: https://github.com/SkinnyMind/libgit2dart
|
||||||
|
|
||||||
|
|
|
@ -50,16 +50,6 @@ void main() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test('walks only number of commits provided with limit', () {
|
|
||||||
final walker = RevWalk(repo);
|
|
||||||
|
|
||||||
walker.push(repo[log.first]);
|
|
||||||
final commits = walker.walk(limit: 1);
|
|
||||||
|
|
||||||
expect(commits.length, 1);
|
|
||||||
expect(commits[0].oid.sha, log[0]);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('returns list of commits with reverse sorting', () {
|
test('returns list of commits with reverse sorting', () {
|
||||||
final walker = RevWalk(repo);
|
final walker = RevWalk(repo);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue