mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-04 20:29:08 -04:00
refactor(reflog): use naming conventions for similar methods
This commit is contained in:
parent
5675f9265c
commit
c26e3f4539
4 changed files with 15 additions and 17 deletions
|
@ -34,7 +34,7 @@ int entryCount(Pointer<git_reflog> reflog) =>
|
||||||
///
|
///
|
||||||
/// Requesting the reflog entry with an index of 0 (zero) will return
|
/// Requesting the reflog entry with an index of 0 (zero) will return
|
||||||
/// the most recently created entry.
|
/// the most recently created entry.
|
||||||
Pointer<git_reflog_entry> entryByIndex(Pointer<git_reflog> reflog, int idx) {
|
Pointer<git_reflog_entry> getByIndex(Pointer<git_reflog> reflog, int idx) {
|
||||||
return libgit2.git_reflog_entry_byindex(reflog, idx);
|
return libgit2.git_reflog_entry_byindex(reflog, idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,11 +21,11 @@ class RefLog {
|
||||||
late final Pointer<git_reflog> _reflogPointer;
|
late final Pointer<git_reflog> _reflogPointer;
|
||||||
|
|
||||||
/// Returns a list with entries of reference log.
|
/// Returns a list with entries of reference log.
|
||||||
List<RefLogEntry> list() {
|
List<RefLogEntry> get entries {
|
||||||
var log = <RefLogEntry>[];
|
var log = <RefLogEntry>[];
|
||||||
|
|
||||||
for (var i = 0; i < count; i++) {
|
for (var i = 0; i < count; i++) {
|
||||||
log.add(entryAt(i));
|
log.add(RefLogEntry(bindings.getByIndex(_reflogPointer, i)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return log;
|
return log;
|
||||||
|
@ -38,8 +38,8 @@ class RefLog {
|
||||||
///
|
///
|
||||||
/// Requesting the reflog entry with an index of 0 (zero) will return
|
/// Requesting the reflog entry with an index of 0 (zero) will return
|
||||||
/// the most recently created entry.
|
/// the most recently created entry.
|
||||||
RefLogEntry entryAt(int index) {
|
RefLogEntry operator [](int index) {
|
||||||
return RefLogEntry(bindings.entryByIndex(_reflogPointer, index));
|
return RefLogEntry(bindings.getByIndex(_reflogPointer, index));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Releases memory allocated for reflog object.
|
/// Releases memory allocated for reflog object.
|
||||||
|
|
|
@ -162,7 +162,7 @@ void main() {
|
||||||
);
|
);
|
||||||
|
|
||||||
final reflog = ref.log;
|
final reflog = ref.log;
|
||||||
final reflogEntry = reflog.entryAt(0);
|
final reflogEntry = reflog[0];
|
||||||
|
|
||||||
expect(reflogEntry.message, 'log message');
|
expect(reflogEntry.message, 'log message');
|
||||||
expect(reflogEntry.committer.name, 'name');
|
expect(reflogEntry.committer.name, 'name');
|
||||||
|
@ -297,7 +297,7 @@ void main() {
|
||||||
);
|
);
|
||||||
|
|
||||||
final reflog = ref.log;
|
final reflog = ref.log;
|
||||||
final reflogEntry = reflog.entryAt(0);
|
final reflogEntry = reflog[0];
|
||||||
|
|
||||||
expect(reflogEntry.message, 'log message');
|
expect(reflogEntry.message, 'log message');
|
||||||
expect(reflogEntry.committer.name, 'name');
|
expect(reflogEntry.committer.name, 'name');
|
||||||
|
@ -338,7 +338,7 @@ void main() {
|
||||||
test('returns log for reference', () {
|
test('returns log for reference', () {
|
||||||
final ref = repo.references['refs/heads/master'];
|
final ref = repo.references['refs/heads/master'];
|
||||||
final reflog = ref.log;
|
final reflog = ref.log;
|
||||||
expect(reflog.list().last.message, 'commit (initial): init');
|
expect(reflog.entries.last.message, 'commit (initial): init');
|
||||||
|
|
||||||
reflog.free();
|
reflog.free();
|
||||||
ref.free();
|
ref.free();
|
||||||
|
@ -379,9 +379,9 @@ void main() {
|
||||||
ref.setTarget('refs/heads/feature', 'log message');
|
ref.setTarget('refs/heads/feature', 'log message');
|
||||||
expect(ref.target.sha, '5aecfa0fb97eadaac050ccb99f03c3fb65460ad4');
|
expect(ref.target.sha, '5aecfa0fb97eadaac050ccb99f03c3fb65460ad4');
|
||||||
final reflog = ref.log;
|
final reflog = ref.log;
|
||||||
expect(reflog.list().first.message, 'log message');
|
expect(reflog.entries.first.message, 'log message');
|
||||||
expect(reflog.list().first.committer.name, 'name');
|
expect(reflog.entries.first.committer.name, 'name');
|
||||||
expect(reflog.list().first.committer.email, 'email');
|
expect(reflog.entries.first.committer.email, 'email');
|
||||||
|
|
||||||
reflog.free();
|
reflog.free();
|
||||||
ref.free();
|
ref.free();
|
||||||
|
|
|
@ -38,15 +38,13 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('returns the log message', () {
|
test('returns the log message', () {
|
||||||
final entry = reflog.entryAt(0);
|
expect(reflog[0].message, "commit: add subdirectory file");
|
||||||
expect(entry.message, "commit: add subdirectory file");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('returns the committer of the entry', () {
|
test('returns the committer of the entry', () {
|
||||||
final entry = reflog.entryAt(0);
|
expect(reflog[0].committer.name, 'Aleksey Kulikov');
|
||||||
expect(entry.committer.name, 'Aleksey Kulikov');
|
expect(reflog[0].committer.email, 'skinny.mind@gmail.com');
|
||||||
expect(entry.committer.email, 'skinny.mind@gmail.com');
|
expect(reflog[0].committer.time, 1630568461);
|
||||||
expect(entry.committer.time, 1630568461);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue