feat(repository)!: add more aliases for api methods

BREAKING CHANGE: Make repository entry point for most operations
This commit is contained in:
Aleksey Kulikov 2021-10-11 20:06:36 +03:00
parent 9205a3ad82
commit 3a0fa75929
51 changed files with 1380 additions and 1062 deletions

View file

@ -2,9 +2,9 @@ import 'dart:io';
import 'package:libgit2dart/libgit2dart.dart';
import '../test/helpers/util.dart';
void main() async {
void main() {
// Preparing example repository.
final tmpDir = await setupRepo(Directory('test/assets/testrepo/'));
final tmpDir = setupRepo(Directory('test/assets/testrepo/'));
// Open system + global config file.
final config = Config.open();
@ -54,5 +54,5 @@ void main() async {
}
// Removing example repository.
await tmpDir.delete(recursive: true);
tmpDir.deleteSync(recursive: true);
}

View file

@ -2,17 +2,17 @@ import 'dart:io';
import 'package:libgit2dart/libgit2dart.dart';
import '../test/helpers/util.dart';
void main() async {
void main() {
// Preparing example repository.
final tmpDir = await setupRepo(Directory('test/assets/testrepo/'));
final tmpDir = setupRepo(Directory('test/assets/testrepo/'));
final repo = Repository.open(tmpDir.path);
// Get list of repo's references.
print('Repository references: ${repo.references.list}');
print('Repository references: ${repo.references}');
// Get reference by name.
final ref = repo.references['refs/heads/master'];
final ref = repo.lookupReference('refs/heads/master');
print('Reference SHA hex: ${ref.target.sha}');
print('Is reference a local branch: ${ref.isBranch}');
@ -20,16 +20,16 @@ void main() async {
print('Reference shorthand name: ${ref.shorthand}');
// Create new reference (direct or symbolic).
final newRef = repo.references.create(
final newRef = repo.createReference(
name: 'refs/tags/v1',
target: 'refs/heads/master',
);
// Rename reference.
newRef.rename(newName: 'refs/tags/v1.1');
repo.renameReference(oldName: 'v1', newName: 'refs/tags/v1.1');
// Delete reference.
newRef.delete();
repo.deleteReference('v1.1');
// free() should be called on object to free memory when done.
ref.free();
@ -37,5 +37,5 @@ void main() async {
repo.free();
// Removing example repository.
await tmpDir.delete(recursive: true);
tmpDir.deleteSync(recursive: true);
}