mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-04 20:29:08 -04:00
refactor(repository)!: remove excessive aliases (#40)
BREAKING CHANGE: instead of removed aliases, API methods from relevant classes should be called (e.g. Commit.create, Reference.lookup, etc.)
This commit is contained in:
parent
432abffa89
commit
e7c18c35e2
13 changed files with 144 additions and 1063 deletions
|
@ -14,7 +14,7 @@ void main() {
|
||||||
print('Repository references: ${repo.references}');
|
print('Repository references: ${repo.references}');
|
||||||
|
|
||||||
// Get reference by name.
|
// Get reference by name.
|
||||||
final ref = repo.lookupReference('refs/heads/master');
|
final ref = Reference.lookup(repo: repo, name: 'refs/heads/master');
|
||||||
|
|
||||||
print('Reference SHA hex: ${ref.target.sha}');
|
print('Reference SHA hex: ${ref.target.sha}');
|
||||||
print('Is reference a local branch: ${ref.isBranch}');
|
print('Is reference a local branch: ${ref.isBranch}');
|
||||||
|
@ -22,16 +22,17 @@ void main() {
|
||||||
print('Reference shorthand name: ${ref.shorthand}');
|
print('Reference shorthand name: ${ref.shorthand}');
|
||||||
|
|
||||||
// Create new reference (direct or symbolic).
|
// Create new reference (direct or symbolic).
|
||||||
final newRef = repo.createReference(
|
final newRef = Reference.create(
|
||||||
|
repo: repo,
|
||||||
name: 'refs/tags/v1',
|
name: 'refs/tags/v1',
|
||||||
target: 'refs/heads/master',
|
target: 'refs/heads/master',
|
||||||
);
|
);
|
||||||
|
|
||||||
// Rename reference.
|
// Rename reference.
|
||||||
repo.renameReference(oldName: 'v1', newName: 'refs/tags/v1.1');
|
Reference.rename(repo: repo, oldName: 'v1', newName: 'refs/tags/v1.1');
|
||||||
|
|
||||||
// Delete reference.
|
// Delete reference.
|
||||||
repo.deleteReference('v1.1');
|
Reference.delete(repo: repo, name: 'v1.1');
|
||||||
|
|
||||||
// free() should be called on object to free memory when done.
|
// free() should be called on object to free memory when done.
|
||||||
ref.free();
|
ref.free();
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -41,7 +41,7 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('creates annotated commit from provided reference', () {
|
test('creates annotated commit from provided reference', () {
|
||||||
final reference = repo.lookupReference('refs/heads/master');
|
final reference = Reference.lookup(repo: repo, name: 'refs/heads/master');
|
||||||
final annotated = AnnotatedCommit.fromReference(
|
final annotated = AnnotatedCommit.fromReference(
|
||||||
repo: repo,
|
repo: repo,
|
||||||
reference: reference,
|
reference: reference,
|
||||||
|
@ -57,7 +57,7 @@ void main() {
|
||||||
test(
|
test(
|
||||||
'throws when trying to create annotated commit from provided '
|
'throws when trying to create annotated commit from provided '
|
||||||
'reference and error occurs', () {
|
'reference and error occurs', () {
|
||||||
final reference = repo.lookupReference('refs/heads/master');
|
final reference = Reference.lookup(repo: repo, name: 'refs/heads/master');
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
() => AnnotatedCommit.fromReference(
|
() => AnnotatedCommit.fromReference(
|
||||||
|
|
|
@ -71,9 +71,7 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('checkouts reference', () {
|
test('checkouts reference', () {
|
||||||
final masterHead = repo.lookupCommit(
|
final masterHead = Commit.lookup(repo: repo, oid: repo['821ed6e']);
|
||||||
repo['821ed6e80627b8769d170a293862f9fc60825226'],
|
|
||||||
);
|
|
||||||
final masterTree = masterHead.tree;
|
final masterTree = masterHead.tree;
|
||||||
expect(
|
expect(
|
||||||
masterTree.entries.any((e) => e.name == 'another_feature_file'),
|
masterTree.entries.any((e) => e.name == 'another_feature_file'),
|
||||||
|
@ -81,9 +79,7 @@ void main() {
|
||||||
);
|
);
|
||||||
|
|
||||||
repo.checkout(target: 'refs/heads/feature');
|
repo.checkout(target: 'refs/heads/feature');
|
||||||
final featureHead = repo.lookupCommit(
|
final featureHead = Commit.lookup(repo: repo, oid: repo['5aecfa0']);
|
||||||
repo['5aecfa0fb97eadaac050ccb99f03c3fb65460ad4'],
|
|
||||||
);
|
|
||||||
final featureTree = featureHead.tree;
|
final featureTree = featureHead.tree;
|
||||||
final repoHead = repo.head;
|
final repoHead = repo.head;
|
||||||
expect(repoHead.target, featureHead.oid);
|
expect(repoHead.target, featureHead.oid);
|
||||||
|
@ -116,9 +112,7 @@ void main() {
|
||||||
final index = repo.index;
|
final index = repo.index;
|
||||||
expect(index.find('another_feature_file'), equals(false));
|
expect(index.find('another_feature_file'), equals(false));
|
||||||
|
|
||||||
final featureHead = repo.lookupCommit(
|
final featureHead = Commit.lookup(repo: repo, oid: repo['5aecfa0']);
|
||||||
repo['5aecfa0fb97eadaac050ccb99f03c3fb65460ad4'],
|
|
||||||
);
|
|
||||||
repo.checkout(target: featureHead.oid);
|
repo.checkout(target: featureHead.oid);
|
||||||
|
|
||||||
final repoHead = repo.head;
|
final repoHead = repo.head;
|
||||||
|
@ -132,9 +126,7 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('checkouts commit with provided path', () {
|
test('checkouts commit with provided path', () {
|
||||||
final featureHead = repo.lookupCommit(
|
final featureHead = Commit.lookup(repo: repo, oid: repo['5aecfa0']);
|
||||||
repo['5aecfa0fb97eadaac050ccb99f03c3fb65460ad4'],
|
|
||||||
);
|
|
||||||
repo.checkout(target: featureHead.oid, paths: ['another_feature_file']);
|
repo.checkout(target: featureHead.oid, paths: ['another_feature_file']);
|
||||||
|
|
||||||
final repoHead = repo.head;
|
final repoHead = repo.head;
|
||||||
|
@ -167,7 +159,10 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('checkouts file with provided path', () {
|
test('checkouts file with provided path', () {
|
||||||
final featureTip = repo.lookupReference('refs/heads/feature').target;
|
final featureTip = Reference.lookup(
|
||||||
|
repo: repo,
|
||||||
|
name: 'refs/heads/feature',
|
||||||
|
).target;
|
||||||
|
|
||||||
expect(repo.status, isEmpty);
|
expect(repo.status, isEmpty);
|
||||||
repo.checkout(
|
repo.checkout(
|
||||||
|
|
|
@ -32,7 +32,7 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('describes commit', () {
|
test('describes commit', () {
|
||||||
repo.deleteTag('v0.2');
|
Tag.delete(repo: repo, name: 'v0.2');
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
repo.describe(describeStrategy: GitDescribeStrategy.tags),
|
repo.describe(describeStrategy: GitDescribeStrategy.tags),
|
||||||
|
@ -41,13 +41,13 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws when trying to describe and no reference found', () {
|
test('throws when trying to describe and no reference found', () {
|
||||||
final commit = repo.lookupCommit(repo['f17d0d48']);
|
final commit = Commit.lookup(repo: repo, oid: repo['f17d0d4']);
|
||||||
expect(() => repo.describe(commit: commit), throwsA(isA<LibGit2Error>()));
|
expect(() => repo.describe(commit: commit), throwsA(isA<LibGit2Error>()));
|
||||||
commit.free();
|
commit.free();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('returns oid when fallback argument is provided', () {
|
test('returns oid when fallback argument is provided', () {
|
||||||
final commit = repo.lookupCommit(repo['f17d0d48']);
|
final commit = Commit.lookup(repo: repo, oid: repo['f17d0d4']);
|
||||||
expect(
|
expect(
|
||||||
repo.describe(commit: commit, showCommitOidAsFallback: true),
|
repo.describe(commit: commit, showCommitOidAsFallback: true),
|
||||||
'f17d0d4',
|
'f17d0d4',
|
||||||
|
@ -56,7 +56,7 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('describes with provided strategy', () {
|
test('describes with provided strategy', () {
|
||||||
final commit = repo.lookupCommit(repo['5aecfa0']);
|
final commit = Commit.lookup(repo: repo, oid: repo['5aecfa0']);
|
||||||
expect(
|
expect(
|
||||||
repo.describe(
|
repo.describe(
|
||||||
commit: commit,
|
commit: commit,
|
||||||
|
@ -73,10 +73,11 @@ void main() {
|
||||||
email: 'author@email.com',
|
email: 'author@email.com',
|
||||||
time: 1234,
|
time: 1234,
|
||||||
);
|
);
|
||||||
final commit = repo.lookupCommit(repo['fc38877']);
|
final commit = Commit.lookup(repo: repo, oid: repo['fc38877']);
|
||||||
repo.createAnnotatedTag(
|
Tag.createAnnotated(
|
||||||
|
repo: repo,
|
||||||
tagName: 'test/tag1',
|
tagName: 'test/tag1',
|
||||||
target: repo['f17d0d48'],
|
target: repo['f17d0d4'],
|
||||||
targetType: GitObject.commit,
|
targetType: GitObject.commit,
|
||||||
tagger: signature,
|
tagger: signature,
|
||||||
message: 'message',
|
message: 'message',
|
||||||
|
@ -92,8 +93,8 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('describes and follows first parent only', () {
|
test('describes and follows first parent only', () {
|
||||||
final commit = repo.lookupCommit(repo['821ed6e']);
|
final commit = Commit.lookup(repo: repo, oid: repo['821ed6e']);
|
||||||
repo.deleteTag('v0.2');
|
Tag.delete(repo: repo, name: 'v0.2');
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
repo.describe(
|
repo.describe(
|
||||||
|
@ -108,8 +109,8 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('describes with provided abbreviated size', () {
|
test('describes with provided abbreviated size', () {
|
||||||
final commit = repo.lookupCommit(repo['821ed6e']);
|
final commit = Commit.lookup(repo: repo, oid: repo['821ed6e']);
|
||||||
repo.deleteTag('v0.2');
|
Tag.delete(repo: repo, name: 'v0.2');
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
repo.describe(
|
repo.describe(
|
||||||
|
|
|
@ -177,7 +177,7 @@ index e69de29..c217c63 100644
|
||||||
|
|
||||||
test('returns diff between tree and workdir with index', () {
|
test('returns diff between tree and workdir with index', () {
|
||||||
final head = repo.head;
|
final head = repo.head;
|
||||||
final commit = repo.lookupCommit(head.target);
|
final commit = Commit.lookup(repo: repo, oid: head.target);
|
||||||
final tree = commit.tree;
|
final tree = commit.tree;
|
||||||
|
|
||||||
final diff = Diff.treeToWorkdirWithIndex(repo: repo, tree: tree);
|
final diff = Diff.treeToWorkdirWithIndex(repo: repo, tree: tree);
|
||||||
|
|
|
@ -293,9 +293,7 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('reads tree with provided SHA hex', () {
|
test('reads tree with provided SHA hex', () {
|
||||||
final tree = repo.lookupTree(
|
final tree = Tree.lookup(repo: repo, oid: repo['df2b8fc']);
|
||||||
repo['df2b8fc99e1c1d4dbc0a854d9f72157f1d6ea078'],
|
|
||||||
);
|
|
||||||
expect(index.length, 4);
|
expect(index.length, 4);
|
||||||
index.readTree(tree);
|
index.readTree(tree);
|
||||||
|
|
||||||
|
@ -322,7 +320,7 @@ void main() {
|
||||||
final tmpDir = setupRepo(Directory(mergeRepoPath));
|
final tmpDir = setupRepo(Directory(mergeRepoPath));
|
||||||
final repo = Repository.open(tmpDir.path);
|
final repo = Repository.open(tmpDir.path);
|
||||||
|
|
||||||
final conflictBranch = repo.lookupBranch(name: 'conflict-branch');
|
final conflictBranch = Branch.lookup(repo: repo, name: 'conflict-branch');
|
||||||
final index = repo.index;
|
final index = repo.index;
|
||||||
final commit = AnnotatedCommit.lookup(
|
final commit = AnnotatedCommit.lookup(
|
||||||
repo: repo,
|
repo: repo,
|
||||||
|
@ -357,7 +355,8 @@ void main() {
|
||||||
final repoDir = setupRepo(Directory(mergeRepoPath));
|
final repoDir = setupRepo(Directory(mergeRepoPath));
|
||||||
final conflictRepo = Repository.open(repoDir.path);
|
final conflictRepo = Repository.open(repoDir.path);
|
||||||
|
|
||||||
final conflictBranch = conflictRepo.lookupBranch(
|
final conflictBranch = Branch.lookup(
|
||||||
|
repo: conflictRepo,
|
||||||
name: 'ancestor-conflict',
|
name: 'ancestor-conflict',
|
||||||
);
|
);
|
||||||
final commit = AnnotatedCommit.lookup(
|
final commit = AnnotatedCommit.lookup(
|
||||||
|
@ -387,7 +386,10 @@ void main() {
|
||||||
final repoDir = setupRepo(Directory(mergeRepoPath));
|
final repoDir = setupRepo(Directory(mergeRepoPath));
|
||||||
final conflictRepo = Repository.open(repoDir.path);
|
final conflictRepo = Repository.open(repoDir.path);
|
||||||
|
|
||||||
final conflictBranch = conflictRepo.lookupBranch(name: 'conflict-branch');
|
final conflictBranch = Branch.lookup(
|
||||||
|
repo: conflictRepo,
|
||||||
|
name: 'conflict-branch',
|
||||||
|
);
|
||||||
final commit = AnnotatedCommit.lookup(
|
final commit = AnnotatedCommit.lookup(
|
||||||
repo: conflictRepo,
|
repo: conflictRepo,
|
||||||
oid: conflictBranch.target,
|
oid: conflictBranch.target,
|
||||||
|
@ -413,7 +415,8 @@ void main() {
|
||||||
final repoDir = setupRepo(Directory(mergeRepoPath));
|
final repoDir = setupRepo(Directory(mergeRepoPath));
|
||||||
final conflictRepo = Repository.open(repoDir.path);
|
final conflictRepo = Repository.open(repoDir.path);
|
||||||
|
|
||||||
final conflictBranch = conflictRepo.lookupBranch(
|
final conflictBranch = Branch.lookup(
|
||||||
|
repo: conflictRepo,
|
||||||
name: 'ancestor-conflict',
|
name: 'ancestor-conflict',
|
||||||
);
|
);
|
||||||
final commit = AnnotatedCommit.lookup(
|
final commit = AnnotatedCommit.lookup(
|
||||||
|
@ -443,7 +446,10 @@ void main() {
|
||||||
final repoDir = setupRepo(Directory(mergeRepoPath));
|
final repoDir = setupRepo(Directory(mergeRepoPath));
|
||||||
final conflictRepo = Repository.open(repoDir.path);
|
final conflictRepo = Repository.open(repoDir.path);
|
||||||
|
|
||||||
final conflictBranch = conflictRepo.lookupBranch(name: 'their-conflict');
|
final conflictBranch = Branch.lookup(
|
||||||
|
repo: conflictRepo,
|
||||||
|
name: 'their-conflict',
|
||||||
|
);
|
||||||
final commit = AnnotatedCommit.lookup(
|
final commit = AnnotatedCommit.lookup(
|
||||||
repo: conflictRepo,
|
repo: conflictRepo,
|
||||||
oid: conflictBranch.target,
|
oid: conflictBranch.target,
|
||||||
|
@ -471,7 +477,10 @@ void main() {
|
||||||
final repoDir = setupRepo(Directory(mergeRepoPath));
|
final repoDir = setupRepo(Directory(mergeRepoPath));
|
||||||
final conflictRepo = Repository.open(repoDir.path);
|
final conflictRepo = Repository.open(repoDir.path);
|
||||||
|
|
||||||
final conflictBranch = conflictRepo.lookupBranch(name: 'conflict-branch');
|
final conflictBranch = Branch.lookup(
|
||||||
|
repo: conflictRepo,
|
||||||
|
name: 'conflict-branch',
|
||||||
|
);
|
||||||
final commit = AnnotatedCommit.lookup(
|
final commit = AnnotatedCommit.lookup(
|
||||||
repo: conflictRepo,
|
repo: conflictRepo,
|
||||||
oid: conflictBranch.target,
|
oid: conflictBranch.target,
|
||||||
|
@ -509,7 +518,10 @@ void main() {
|
||||||
final repoDir = setupRepo(Directory(mergeRepoPath));
|
final repoDir = setupRepo(Directory(mergeRepoPath));
|
||||||
final conflictRepo = Repository.open(repoDir.path);
|
final conflictRepo = Repository.open(repoDir.path);
|
||||||
|
|
||||||
final conflictBranch = conflictRepo.lookupBranch(name: 'conflict-branch');
|
final conflictBranch = Branch.lookup(
|
||||||
|
repo: conflictRepo,
|
||||||
|
name: 'conflict-branch',
|
||||||
|
);
|
||||||
final commit = AnnotatedCommit.lookup(
|
final commit = AnnotatedCommit.lookup(
|
||||||
repo: conflictRepo,
|
repo: conflictRepo,
|
||||||
oid: conflictBranch.target,
|
oid: conflictBranch.target,
|
||||||
|
|
|
@ -44,8 +44,9 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('is fast forward', () {
|
test('is fast forward', () {
|
||||||
final ffCommit = repo.lookupCommit(repo['f17d0d4']);
|
final ffCommit = Commit.lookup(repo: repo, oid: repo['f17d0d4']);
|
||||||
final ffBranch = repo.createBranch(
|
final ffBranch = Branch.create(
|
||||||
|
repo: repo,
|
||||||
name: 'ff-branch',
|
name: 'ff-branch',
|
||||||
target: ffCommit,
|
target: ffCommit,
|
||||||
);
|
);
|
||||||
|
@ -72,7 +73,7 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('writes conflicts to index', () {
|
test('writes conflicts to index', () {
|
||||||
final conflictBranch = repo.lookupBranch(name: 'conflict-branch');
|
final conflictBranch = Branch.lookup(repo: repo, name: 'conflict-branch');
|
||||||
final commit = AnnotatedCommit.lookup(
|
final commit = AnnotatedCommit.lookup(
|
||||||
repo: repo,
|
repo: repo,
|
||||||
oid: conflictBranch.target,
|
oid: conflictBranch.target,
|
||||||
|
@ -123,7 +124,10 @@ master conflict edit
|
||||||
conflict branch edit
|
conflict branch edit
|
||||||
>>>>>>> conflict_file
|
>>>>>>> conflict_file
|
||||||
""";
|
""";
|
||||||
final conflictBranch = repo.lookupBranch(name: 'conflict-branch');
|
final conflictBranch = Branch.lookup(
|
||||||
|
repo: repo,
|
||||||
|
name: 'conflict-branch',
|
||||||
|
);
|
||||||
final commit = AnnotatedCommit.lookup(
|
final commit = AnnotatedCommit.lookup(
|
||||||
repo: repo,
|
repo: repo,
|
||||||
oid: conflictBranch.target,
|
oid: conflictBranch.target,
|
||||||
|
@ -154,7 +158,10 @@ Feature edit on feature branch
|
||||||
Another feature edit
|
Another feature edit
|
||||||
>>>>>>> feature_file
|
>>>>>>> feature_file
|
||||||
""";
|
""";
|
||||||
final conflictBranch = repo.lookupBranch(name: 'ancestor-conflict');
|
final conflictBranch = Branch.lookup(
|
||||||
|
repo: repo,
|
||||||
|
name: 'ancestor-conflict',
|
||||||
|
);
|
||||||
final commit = AnnotatedCommit.lookup(
|
final commit = AnnotatedCommit.lookup(
|
||||||
repo: repo,
|
repo: repo,
|
||||||
oid: conflictBranch.target,
|
oid: conflictBranch.target,
|
||||||
|
@ -186,7 +193,10 @@ master conflict edit
|
||||||
conflict branch edit
|
conflict branch edit
|
||||||
>>>>>>> conflict_file
|
>>>>>>> conflict_file
|
||||||
""";
|
""";
|
||||||
final conflictBranch = repo.lookupBranch(name: 'conflict-branch');
|
final conflictBranch = Branch.lookup(
|
||||||
|
repo: repo,
|
||||||
|
name: 'conflict-branch',
|
||||||
|
);
|
||||||
final commit = AnnotatedCommit.lookup(
|
final commit = AnnotatedCommit.lookup(
|
||||||
repo: repo,
|
repo: repo,
|
||||||
oid: conflictBranch.target,
|
oid: conflictBranch.target,
|
||||||
|
@ -214,7 +224,10 @@ conflict branch edit
|
||||||
});
|
});
|
||||||
|
|
||||||
test('merges with provided merge favor', () {
|
test('merges with provided merge favor', () {
|
||||||
final conflictBranch = repo.lookupBranch(name: 'conflict-branch');
|
final conflictBranch = Branch.lookup(
|
||||||
|
repo: repo,
|
||||||
|
name: 'conflict-branch',
|
||||||
|
);
|
||||||
final commit = AnnotatedCommit.lookup(
|
final commit = AnnotatedCommit.lookup(
|
||||||
repo: repo,
|
repo: repo,
|
||||||
oid: conflictBranch.target,
|
oid: conflictBranch.target,
|
||||||
|
@ -303,12 +316,12 @@ theirs content
|
||||||
|
|
||||||
group('merge commits', () {
|
group('merge commits', () {
|
||||||
test('merges with default values', () {
|
test('merges with default values', () {
|
||||||
final theirCommit = repo.lookupCommit(repo['5aecfa0']);
|
final theirCommit = Commit.lookup(repo: repo, oid: repo['5aecfa0']);
|
||||||
final theirCommitAnnotated = AnnotatedCommit.lookup(
|
final theirCommitAnnotated = AnnotatedCommit.lookup(
|
||||||
repo: repo,
|
repo: repo,
|
||||||
oid: theirCommit.oid,
|
oid: theirCommit.oid,
|
||||||
);
|
);
|
||||||
final ourCommit = repo.lookupCommit(repo['1490545']);
|
final ourCommit = Commit.lookup(repo: repo, oid: repo['1490545']);
|
||||||
|
|
||||||
final mergeIndex = repo.mergeCommits(
|
final mergeIndex = repo.mergeCommits(
|
||||||
ourCommit: ourCommit,
|
ourCommit: ourCommit,
|
||||||
|
@ -332,8 +345,8 @@ theirs content
|
||||||
});
|
});
|
||||||
|
|
||||||
test('merges with provided favor', () {
|
test('merges with provided favor', () {
|
||||||
final theirCommit = repo.lookupCommit(repo['5aecfa0']);
|
final theirCommit = Commit.lookup(repo: repo, oid: repo['5aecfa0']);
|
||||||
final ourCommit = repo.lookupCommit(repo['1490545']);
|
final ourCommit = Commit.lookup(repo: repo, oid: repo['1490545']);
|
||||||
|
|
||||||
final mergeIndex = repo.mergeCommits(
|
final mergeIndex = repo.mergeCommits(
|
||||||
ourCommit: ourCommit,
|
ourCommit: ourCommit,
|
||||||
|
@ -348,8 +361,8 @@ theirs content
|
||||||
});
|
});
|
||||||
|
|
||||||
test('merges with provided merge and file flags', () {
|
test('merges with provided merge and file flags', () {
|
||||||
final theirCommit = repo.lookupCommit(repo['5aecfa0']);
|
final theirCommit = Commit.lookup(repo: repo, oid: repo['5aecfa0']);
|
||||||
final ourCommit = repo.lookupCommit(repo['1490545']);
|
final ourCommit = Commit.lookup(repo: repo, oid: repo['1490545']);
|
||||||
|
|
||||||
final mergeIndex = repo.mergeCommits(
|
final mergeIndex = repo.mergeCommits(
|
||||||
ourCommit: ourCommit,
|
ourCommit: ourCommit,
|
||||||
|
@ -454,14 +467,15 @@ theirs content
|
||||||
|
|
||||||
group('merge trees', () {
|
group('merge trees', () {
|
||||||
test('merges with default values', () {
|
test('merges with default values', () {
|
||||||
final theirCommit = repo.lookupCommit(repo['5aecfa0']);
|
final theirCommit = Commit.lookup(repo: repo, oid: repo['5aecfa0']);
|
||||||
final theirCommitAnnotated = AnnotatedCommit.lookup(
|
final theirCommitAnnotated = AnnotatedCommit.lookup(
|
||||||
repo: repo,
|
repo: repo,
|
||||||
oid: theirCommit.oid,
|
oid: theirCommit.oid,
|
||||||
);
|
);
|
||||||
final ourCommit = repo.lookupCommit(repo['1490545']);
|
final ourCommit = Commit.lookup(repo: repo, oid: repo['1490545']);
|
||||||
final baseCommit = repo.lookupCommit(
|
final baseCommit = Commit.lookup(
|
||||||
repo.mergeBase([ourCommit.oid, theirCommit.oid]),
|
repo: repo,
|
||||||
|
oid: repo.mergeBase([ourCommit.oid, theirCommit.oid]),
|
||||||
);
|
);
|
||||||
final theirTree = theirCommit.tree;
|
final theirTree = theirCommit.tree;
|
||||||
final ourTree = ourCommit.tree;
|
final ourTree = ourCommit.tree;
|
||||||
|
@ -495,10 +509,11 @@ theirs content
|
||||||
});
|
});
|
||||||
|
|
||||||
test('merges with provided favor', () {
|
test('merges with provided favor', () {
|
||||||
final theirCommit = repo.lookupCommit(repo['5aecfa0']);
|
final theirCommit = Commit.lookup(repo: repo, oid: repo['5aecfa0']);
|
||||||
final ourCommit = repo.lookupCommit(repo['1490545']);
|
final ourCommit = Commit.lookup(repo: repo, oid: repo['1490545']);
|
||||||
final baseCommit = repo.lookupCommit(
|
final baseCommit = Commit.lookup(
|
||||||
repo.mergeBase([ourCommit.oid, theirCommit.oid]),
|
repo: repo,
|
||||||
|
oid: repo.mergeBase([ourCommit.oid, theirCommit.oid]),
|
||||||
);
|
);
|
||||||
final theirTree = theirCommit.tree;
|
final theirTree = theirCommit.tree;
|
||||||
final ourTree = ourCommit.tree;
|
final ourTree = ourCommit.tree;
|
||||||
|
@ -534,7 +549,7 @@ theirs content
|
||||||
});
|
});
|
||||||
|
|
||||||
test('cherry-picks commit', () {
|
test('cherry-picks commit', () {
|
||||||
final cherry = repo.lookupCommit(repo['5aecfa0']);
|
final cherry = Commit.lookup(repo: repo, oid: repo['5aecfa0']);
|
||||||
repo.cherryPick(cherry);
|
repo.cherryPick(cherry);
|
||||||
expect(repo.state, GitRepositoryState.cherrypick);
|
expect(repo.state, GitRepositoryState.cherrypick);
|
||||||
expect(repo.message, 'add another feature file\n');
|
expect(repo.message, 'add another feature file\n');
|
||||||
|
|
|
@ -23,8 +23,8 @@ void main() {
|
||||||
url: tmpDir.path,
|
url: tmpDir.path,
|
||||||
localPath: cloneDir.path,
|
localPath: cloneDir.path,
|
||||||
);
|
);
|
||||||
originRepo.deleteBranch('feature');
|
Branch.delete(repo: originRepo, name: 'feature');
|
||||||
remote = clonedRepo.lookupRemote('origin');
|
remote = Remote.lookup(repo: clonedRepo, name: 'origin');
|
||||||
});
|
});
|
||||||
|
|
||||||
tearDown(() {
|
tearDown(() {
|
||||||
|
|
|
@ -72,7 +72,7 @@ void main() {
|
||||||
|
|
||||||
test('clones repository with provided remote callback', () {
|
test('clones repository with provided remote callback', () {
|
||||||
Remote remote(Repository repo, String name, String url) =>
|
Remote remote(Repository repo, String name, String url) =>
|
||||||
repo.createRemote(name: 'test', url: tmpDir.path);
|
Remote.create(repo: repo, name: 'test', url: tmpDir.path);
|
||||||
|
|
||||||
final clonedRepo = Repository.clone(
|
final clonedRepo = Repository.clone(
|
||||||
url: tmpDir.path,
|
url: tmpDir.path,
|
||||||
|
@ -90,7 +90,7 @@ void main() {
|
||||||
|
|
||||||
test('throws when cloning repository with invalid remote callback', () {
|
test('throws when cloning repository with invalid remote callback', () {
|
||||||
Remote remote(Repository repo, String name, String url) =>
|
Remote remote(Repository repo, String name, String url) =>
|
||||||
repo.createRemote(name: '', url: '');
|
Remote.create(repo: repo, name: '', url: '');
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
() => Repository.clone(
|
() => Repository.clone(
|
||||||
|
|
|
@ -51,7 +51,7 @@ void main() {
|
||||||
File(p.join(repo.path, 'description')).readAsStringSync(),
|
File(p.join(repo.path, 'description')).readAsStringSync(),
|
||||||
'test repo',
|
'test repo',
|
||||||
);
|
);
|
||||||
expect(repo.lookupRemote('origin').url, 'test.url');
|
expect(Remote.lookup(repo: repo, name: 'origin').url, 'test.url');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,91 +162,6 @@ void main() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
group('createBlob', () {
|
|
||||||
const newBlobContent = 'New blob\n';
|
|
||||||
|
|
||||||
test('creates new blob', () {
|
|
||||||
final oid = repo.createBlob(newBlobContent);
|
|
||||||
final newBlob = repo.lookupBlob(oid);
|
|
||||||
|
|
||||||
expect(newBlob, isA<Blob>());
|
|
||||||
|
|
||||||
newBlob.free();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('creates new blob from file at provided relative path', () {
|
|
||||||
final oid = repo.createBlobFromWorkdir('feature_file');
|
|
||||||
final newBlob = repo.lookupBlob(oid);
|
|
||||||
|
|
||||||
expect(newBlob, isA<Blob>());
|
|
||||||
|
|
||||||
newBlob.free();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('creates new blob from file at provided path', () {
|
|
||||||
final outsideFile = File(
|
|
||||||
p.join(Directory.current.absolute.path, 'test', 'blob_test.dart'),
|
|
||||||
);
|
|
||||||
final oid = repo.createBlobFromDisk(outsideFile.path);
|
|
||||||
final newBlob = repo.lookupBlob(oid);
|
|
||||||
|
|
||||||
expect(newBlob, isA<Blob>());
|
|
||||||
|
|
||||||
newBlob.free();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
test('creates annotated tag with provided sha', () {
|
|
||||||
final signature = Signature.create(
|
|
||||||
name: 'Author',
|
|
||||||
email: 'author@email.com',
|
|
||||||
time: 1234,
|
|
||||||
);
|
|
||||||
const tagName = 'tag';
|
|
||||||
final target = repo['f17d0d48eae3aa08cecf29128a35e310c97b3521'];
|
|
||||||
const message = 'init tag\n';
|
|
||||||
|
|
||||||
final oid = repo.createAnnotatedTag(
|
|
||||||
tagName: tagName,
|
|
||||||
target: target,
|
|
||||||
targetType: GitObject.commit,
|
|
||||||
tagger: signature,
|
|
||||||
message: message,
|
|
||||||
);
|
|
||||||
|
|
||||||
final newTag = repo.lookupTag(oid);
|
|
||||||
final tagger = newTag.tagger;
|
|
||||||
final newTagTarget = newTag.target as Commit;
|
|
||||||
|
|
||||||
expect(newTag.oid, oid);
|
|
||||||
expect(newTag.name, tagName);
|
|
||||||
expect(newTag.message, message);
|
|
||||||
expect(tagger, signature);
|
|
||||||
expect(newTagTarget.oid, target);
|
|
||||||
|
|
||||||
newTag.free();
|
|
||||||
newTagTarget.free();
|
|
||||||
signature.free();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('creates lightweight tag with provided sha', () {
|
|
||||||
const tagName = 'tag';
|
|
||||||
final target = repo['f17d0d48eae3aa08cecf29128a35e310c97b3521'];
|
|
||||||
|
|
||||||
repo.createLightweightTag(
|
|
||||||
tagName: tagName,
|
|
||||||
target: target,
|
|
||||||
targetType: GitObject.commit,
|
|
||||||
);
|
|
||||||
|
|
||||||
final newTag = repo.lookupReference('refs/tags/$tagName');
|
|
||||||
|
|
||||||
expect(newTag.shorthand, tagName);
|
|
||||||
expect(newTag.target, target);
|
|
||||||
|
|
||||||
newTag.free();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('returns status of a repository', () {
|
test('returns status of a repository', () {
|
||||||
File(p.join(tmpDir.path, 'new_file.txt')).createSync();
|
File(p.join(tmpDir.path, 'new_file.txt')).createSync();
|
||||||
final index = repo.index;
|
final index = repo.index;
|
||||||
|
@ -273,7 +188,7 @@ void main() {
|
||||||
|
|
||||||
test('cleans up state', () {
|
test('cleans up state', () {
|
||||||
expect(repo.state, GitRepositoryState.none);
|
expect(repo.state, GitRepositoryState.none);
|
||||||
final commit = repo.lookupCommit(repo['5aecfa0']);
|
final commit = Commit.lookup(repo: repo, oid: repo['5aecfa0']);
|
||||||
repo.cherryPick(commit);
|
repo.cherryPick(commit);
|
||||||
|
|
||||||
expect(repo.state, GitRepositoryState.cherrypick);
|
expect(repo.state, GitRepositoryState.cherrypick);
|
||||||
|
@ -364,8 +279,8 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('returns number of ahead behind commits', () {
|
test('returns number of ahead behind commits', () {
|
||||||
final commit1 = repo.lookupCommit(repo['821ed6e8']);
|
final commit1 = Commit.lookup(repo: repo, oid: repo['821ed6e']);
|
||||||
final commit2 = repo.lookupCommit(repo['c68ff54a']);
|
final commit2 = Commit.lookup(repo: repo, oid: repo['c68ff54']);
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
repo.aheadBehind(local: commit1.oid, upstream: commit2.oid),
|
repo.aheadBehind(local: commit1.oid, upstream: commit2.oid),
|
||||||
|
|
|
@ -56,7 +56,7 @@ void main() {
|
||||||
expect(repo.status.isEmpty, true);
|
expect(repo.status.isEmpty, true);
|
||||||
expect(swpPath.existsSync(), false);
|
expect(swpPath.existsSync(), false);
|
||||||
|
|
||||||
repo.applyStash();
|
Stash.apply(repo: repo);
|
||||||
expect(swpPath.existsSync(), true);
|
expect(swpPath.existsSync(), true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ void main() {
|
||||||
final stash = repo.stashes.first;
|
final stash = repo.stashes.first;
|
||||||
Stash.drop(repo: repo, index: stash.index);
|
Stash.drop(repo: repo, index: stash.index);
|
||||||
|
|
||||||
expect(() => repo.applyStash(), throwsA(isA<LibGit2Error>()));
|
expect(() => Stash.apply(repo: repo), throwsA(isA<LibGit2Error>()));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws when trying to drop with wrong index', () {
|
test('throws when trying to drop with wrong index', () {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue