diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7465cd19..b72595d9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,7 @@ jobs: strategy: fail-fast: false matrix: - sdk: [dev, 3.4] + sdk: [dev, 3.9] steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd - uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c @@ -47,7 +47,7 @@ jobs: matrix: # Add macos-latest and/or windows-latest if relevant for this package. os: [ubuntu-latest, macos-latest, windows-latest] - sdk: [dev, 3.4] + sdk: [dev, 3.9] steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd - uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e175b2c..4b673577 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.3.3-wip + +- Require Dart 3.9 + ## 2.3.2 - Fix `GitDir` constructor when in a submodule. diff --git a/lib/src/commit.dart b/lib/src/commit.dart index 9b5d7059..50613ccc 100644 --- a/lib/src/commit.dart +++ b/lib/src/commit.dart @@ -102,8 +102,9 @@ class Commit { final treeSha = headers['tree']!.single; final author = headers['author']!.single; final committer = headers['committer']!.single; - final commitSha = - headers.containsKey('commit') ? headers['commit']!.single : null; + final commitSha = headers.containsKey('commit') + ? headers['commit']!.single + : null; final parents = headers['parent'] ?? []; diff --git a/lib/src/git_dir.dart b/lib/src/git_dir.dart index 3e5a1f70..2145f214 100644 --- a/lib/src/git_dir.dart +++ b/lib/src/git_dir.dart @@ -23,9 +23,9 @@ class GitDir { final String? _gitWorkTree; GitDir._raw(this.path, {String? gitWorkTree}) - : assert(p.isAbsolute(path)), - assert(gitWorkTree == null || p.isAbsolute(gitWorkTree)), - _gitWorkTree = gitWorkTree; + : assert(p.isAbsolute(path)), + assert(gitWorkTree == null || p.isAbsolute(gitWorkTree)), + _gitWorkTree = gitWorkTree; Future commitCount([String branchName = 'HEAD']) async { final pr = await runCommand(['rev-list', '--count', branchName]); @@ -68,10 +68,7 @@ class GitDir { for (var ref in refs) { final pr = await runCommand(['cat-file', '-p', ref.sha]); - yield Tag.parseCatFile( - pr.stdout as String, - ref, - ); + yield Tag.parseCatFile(pr.stdout as String, ref); } } @@ -103,17 +100,22 @@ class GitDir { } Future currentBranch() async { - var pr = await runCommand( - const ['rev-parse', '--verify', '--symbolic-full-name', 'HEAD'], - ); + var pr = await runCommand(const [ + 'rev-parse', + '--verify', + '--symbolic-full-name', + 'HEAD', + ]); - pr = await runCommand( - ['show-ref', '--verify', (pr.stdout as String).trim()], - ); + pr = await runCommand([ + 'show-ref', + '--verify', + (pr.stdout as String).trim(), + ]); - return CommitReference.fromShowRefOutput(pr.stdout as String) - .single - .toBranchReference(); + return CommitReference.fromShowRefOutput( + pr.stdout as String, + ).single.toBranchReference(); } Future> lsTree( @@ -155,8 +157,11 @@ class GitDir { if (targetBranchRef == null) { newCommitSha = await commitTree(treeSha, commitMessage); } else { - newCommitSha = - await _updateBranch(targetBranchRef.sha, treeSha, commitMessage); + newCommitSha = await _updateBranch( + targetBranchRef.sha, + treeSha, + commitMessage, + ); } if (newCommitSha == null) { @@ -292,8 +297,10 @@ class GitDir { ); } - Future isWorkingTreeClean() => runCommand(['status', '--porcelain']) - .then((pr) => (pr.stdout as String).isEmpty); + Future isWorkingTreeClean() => runCommand([ + 'status', + '--porcelain', + ]).then((pr) => (pr.stdout as String).isEmpty); // TODO: TEST: someone puts a git dir when populated // TODO: TEST: someone puts in no content at all @@ -340,16 +347,21 @@ class GitDir { ) async { final tempGitRoot = await _createTempDir(); - final tempGitDir = - GitDir._raw(tempGitRoot.path, gitWorkTree: sourceDirectoryPath); + final tempGitDir = GitDir._raw( + tempGitRoot.path, + gitWorkTree: sourceDirectoryPath, + ); // time for crazy clone tricks final args = ['clone', '--shared', '--bare', path, '.']; await runGit(args, processWorkingDir: tempGitDir.path); - await tempGitDir - .runCommand(['symbolic-ref', 'HEAD', 'refs/heads/$branchName']); + await tempGitDir.runCommand([ + 'symbolic-ref', + 'HEAD', + 'refs/heads/$branchName', + ]); try { // make sure there is something in the working three @@ -371,10 +383,7 @@ class GitDir { return null; } - final args = [ - 'commit', - '--verbose', - ]; + final args = ['commit', '--verbose']; Directory? tmpDir; @@ -401,8 +410,13 @@ class GitDir { } // --verbose is not strictly needed, but nice for debugging - await tempGitDir - .runCommand(['push', '--verbose', '--progress', path, branchName]); + await tempGitDir.runCommand([ + 'push', + '--verbose', + '--progress', + path, + branchName, + ]); // pr.stderr will have all of the info @@ -461,10 +475,10 @@ class GitDir { // `--show-toplevel` returns a canonicalized absolute path // with all symlinks resolved. - final pr = await runGit( - ['rev-parse', '--show-toplevel'], - processWorkingDir: path.toString(), - ); + final pr = await runGit([ + 'rev-parse', + '--show-toplevel', + ], processWorkingDir: path.toString()); final returnedPath = (pr.stdout as String).trim(); @@ -476,15 +490,19 @@ class GitDir { return GitDir._raw(returnedPath); } - throw ArgumentError('The provided value "$gitDirRoot" is not ' - 'the root of a git directory'); + throw ArgumentError( + 'The provided value "$gitDirRoot" is not ' + 'the root of a git directory', + ); } static Future _init(Directory source, {String? branchName}) async { final isGitDir = await _isGitDir(source); if (isGitDir) { - throw ArgumentError('Cannot init a directory that is already a ' - 'git directory'); + throw ArgumentError( + 'Cannot init a directory that is already a ' + 'git directory', + ); } await runGit([ diff --git a/pubspec.yaml b/pubspec.yaml index a85489f0..2e3f1957 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,17 +1,18 @@ name: git -version: 2.3.2 +version: 2.3.3-wip description: >- Git command line wrapper. Exposes a Git directory abstraction that makes it easy to inspect and manipulate a local Git repository. repository: https://github.com/kevmoo/git environment: - sdk: ^3.4.0 + sdk: ^3.9.0 dependencies: - path: ^1.0.0 + path: ^1.8.0 dev_dependencies: + checks: ^0.3.1 dart_flutter_team_lints: ^3.0.0 - test: ^1.6.0 + test: ^1.24.0 test_descriptor: ^2.0.0 diff --git a/test/git_dir_test.dart b/test/git_dir_test.dart index 9913afde..19e7ad16 100644 --- a/test/git_dir_test.dart +++ b/test/git_dir_test.dart @@ -1,9 +1,10 @@ import 'dart:async'; import 'dart:io'; +import 'package:checks/checks.dart'; import 'package:git/git.dart'; import 'package:path/path.dart' as p; -import 'package:test/test.dart'; +import 'package:test/scaffolding.dart'; import 'package:test_descriptor/test_descriptor.dart' as d; import 'test_utils.dart'; @@ -45,10 +46,10 @@ void main() { // validate it has the right message var treeItems = await gitDir.lsTree(newSha!); - expect(treeItems, hasLength(2)); + check(treeItems).length.equals(2); final libTreeEntry = treeItems.singleWhere((tree) => tree.name == 'lib'); - expect(libTreeEntry.type, 'tree'); + check(libTreeEntry.type).equals('tree'); // do another update from the subtree sha final nextCommit = await gitDir.createOrUpdateBranch( @@ -58,22 +59,21 @@ void main() { ); final testCommitCount = await gitDir.commitCount('test'); - expect(testCommitCount, 2); + check(testCommitCount).equals(2); treeItems = await gitDir.lsTree(nextCommit!); - expect(treeItems, hasLength(2)); + check(treeItems).length.equals(2); - expect( + check( treeItems.map((tree) => tree.name), - unorderedEquals(['foo.txt', 'bar.txt']), - ); + ).unorderedEquals(['foo.txt', 'bar.txt']); }); group('init', () { test('allowContent:false with content fails', () async { File(p.join(d.sandbox, 'testfile.txt')).writeAsStringSync('test content'); - expect(GitDir.init(d.sandbox), throwsArgumentError); + await check(GitDir.init(d.sandbox)).throws(); }); group('existing git dir', () { @@ -84,23 +84,22 @@ void main() { test('isWorkingTreeClean', () async { final gitDir = await GitDir.fromExisting(tempRepoPath); final isClean = await gitDir.isWorkingTreeClean(); - expect(isClean, isTrue); + check(isClean).isTrue(); }); test('isGitDir is true', () async { final isGitDir = await GitDir.isGitDir(tempRepoPath); - expect(isGitDir, isTrue); + check(isGitDir).isTrue(); }); - test('with allowContent:false fails', () { - expect(GitDir.init(tempRepoPath), throwsArgumentError); + test('with allowContent:false fails', () async { + await check(GitDir.init(tempRepoPath)).throws(); }); - test('with allowContent:true fails', () { - expect( + test('with allowContent:true fails', () async { + await check( GitDir.init(tempRepoPath, allowContent: true), - throwsArgumentError, - ); + ).throws(); }); }); }); @@ -116,29 +115,26 @@ void main() { test('succeeds for root directory', () async { final gitDir = await GitDir.fromExisting(tempRepoPath); - expect( + check( p.canonicalize(gitDir.path), - p.canonicalize(tempRepoPath), - reason: 'The created `GitDir` will point to the root.', - ); + because: 'The created `GitDir` will point to the root.', + ).equals(p.canonicalize(tempRepoPath)); }); test('succeeds for symlink to root directory', () async { - final linkToRepoDir = - await Link(p.join(d.sandbox, 'link-to-repo')).create(tempRepoPath); + final linkToRepoDir = await Link( + p.join(d.sandbox, 'link-to-repo'), + ).create(tempRepoPath); final gitDir = await GitDir.fromExisting(linkToRepoDir.path); - expect( + check( p.canonicalize(gitDir.path), - p.canonicalize(tempRepoPath), - reason: 'The `GitDir` will point to the canonical resolved root.', - ); + because: + 'The created `GitDir` will point to the canonical resolved root.', + ).equals(p.canonicalize(tempRepoPath)); }); test('fails for sub directories', () async { - expect( - () => GitDir.fromExisting(subDirPath), - throwsArgumentError, - ); + await check(GitDir.fromExisting(subDirPath)).throws(); }); test('succeeds for sub directories with `allowSubdirectory`', () async { @@ -147,11 +143,10 @@ void main() { allowSubdirectory: true, ); - expect( + check( p.canonicalize(gitDir.path), - p.canonicalize(tempRepoPath), - reason: 'The created `GitDir` will point to the root.', - ); + because: 'The created `GitDir` will point to the root.', + ).equals(p.canonicalize(tempRepoPath)); }); group('with git submodule', () { @@ -172,11 +167,9 @@ void main() { // the child repo must have something in it in order to add it // as a submodule - await doDescriptorGitCommit( - child, - {'README.md': 'hello'}, - 'initial commit', - ); + await doDescriptorGitCommit(child, { + 'README.md': 'hello', + }, 'initial commit'); // normally git doesn't allow us to create a submodule with a // "file://" remote. Setting "protocol.file.allow=always" allows @@ -193,20 +186,19 @@ void main() { test('succeeds on valid submodule dir', () async { final submodule = await GitDir.fromExisting(submoduleMountPathAbs); - expect( + check( p.canonicalize(submodule.path), - p.canonicalize(submoduleMountPathAbs), - reason: + because: 'The created `GitDir` will point to the root of the submodule.', - ); - expect( + ).equals(p.canonicalize(submoduleMountPathAbs)); + + check( p.isWithin( p.canonicalize(tempRepoPath), p.canonicalize(submodule.path), ), - true, - reason: 'the submodule should always be inside the parent worktree', - ); + because: 'the submodule should always be inside the parent worktree', + ).isTrue(); }); }); }); @@ -215,7 +207,7 @@ void main() { final gitDir = await createTempGitDir(); final branches = await gitDir.branches(); - expect(branches, isEmpty, reason: 'Should start with zero commits'); + check(branches, because: 'Should start with zero commits').isEmpty(); final initialContentMap = { 'file1.txt': 'content1', @@ -229,20 +221,10 @@ void main() { .toList(); final hashes = await gitDir.writeObjects(paths); - expect(hashes, hasLength(initialContentMap.length)); - expect(hashes.keys, unorderedEquals(paths)); - - expect(paths[0], endsWith('file1.txt')); - expect( - hashes, - containsPair(paths[0], 'dd954e7a4e1a62ff90c5a0709dce5928716535c1'), - ); - - expect(paths[1], endsWith('file2.txt')); - expect( - hashes, - containsPair(paths[1], 'db00fd65b218578127ea51f3dffac701f12f486a'), - ); + check(hashes).deepEquals({ + paths[0]: 'dd954e7a4e1a62ff90c5a0709dce5928716535c1', + paths[1]: 'db00fd65b218578127ea51f3dffac701f12f486a', + }); }); group('BranchReference', () { @@ -262,19 +244,17 @@ void main() { ); final branch = await gitDir.currentBranch(); - expect(branch.isHead, isFalse); - expect(branch.branchName, 'master'); - expect(branch.reference, 'refs/heads/master'); + check(branch.isHead).isFalse(); + check(branch.branchName).equals('master'); + check(branch.reference).equals('refs/heads/master'); - await gitDir.runCommand( - ['checkout', '--detach'], - ); + await gitDir.runCommand(['checkout', '--detach']); final detached = await gitDir.currentBranch(); - expect(detached.isHead, isTrue); - expect(detached.branchName, 'HEAD'); - expect(detached.reference, 'HEAD'); - expect(detached.sha, branch.sha); + check(detached.isHead).isTrue(); + check(detached.branchName).equals('HEAD'); + check(detached.reference).equals('HEAD'); + check(detached.sha).equals(branch.sha); }); }); } @@ -300,7 +280,7 @@ Future _testGetCommits() async { final gitDir = await createTempGitDir(); final branches = await gitDir.branches(); - expect(branches, isEmpty); + check(branches).isEmpty(); for (var commitStr in commitText) { final fileMap = {}; @@ -310,11 +290,11 @@ Future _testGetCommits() async { } final count = await gitDir.commitCount(); - expect(count, commitText.length); + check(count).equals(commitText.length); final commits = await gitDir.commits(); - expect(commits, hasLength(commitText.length)); + check(commits).length.equals(commitText.length); final commitMessages = commitText.map(msgFromText).toList(); @@ -322,27 +302,26 @@ Future _testGetCommits() async { for (var entry in commits.entries) { // index into the text for the message of this commit - final commitMessageIndex = - commitMessages.indexWhere((element) => element == entry.value.message); + final commitMessageIndex = commitMessages.indexWhere( + (element) => element == entry.value.message, + ); - expect( + check( commitMessageIndex, - greaterThanOrEqualTo(0), - reason: 'a matching message should be found', - ); + because: 'a matching message should be found', + ).isGreaterOrEqual(0); - expect(indexMap, isNot(contains(commitMessageIndex))); + check(indexMap.keys).not((it) => it.contains(commitMessageIndex)); indexMap[commitMessageIndex] = entry; } for (var entry in indexMap.entries) { if (entry.key > 0) { - expect( + check( entry.value.value.parents, - unorderedEquals([indexMap[entry.key - 1]!.key]), - ); + ).unorderedEquals([indexMap[entry.key - 1]!.key]); } else { - expect(entry.value.value.parents, hasLength(0)); + check(entry.value.value.parents).isEmpty(); } } } @@ -368,7 +347,7 @@ Future _testPopulateBranch() async { await doDescriptorGitCommit(gd1, initialMasterBranchContent, 'master files'); - _testPopulateBranchEmpty(gd1, testBranchName); + await _testPopulateBranchEmpty(gd1, testBranchName); await _testPopulateBranchWithContent( gd1, @@ -391,27 +370,20 @@ Future _testPopulateBranch() async { 'same content', ); - await _testPopulateBranchWithContent( - gd1, - testBranchName, - testContent1, - ''' + await _testPopulateBranchWithContent(gd1, testBranchName, testContent1, ''' 3rd commit, content 1 With some new lines -and more messages''', - ); +and more messages'''); - _testPopulateBranchEmpty(gd1, testBranchName); + await _testPopulateBranchEmpty(gd1, testBranchName); } -void _testPopulateBranchEmpty(GitDir gitDir, String branchName) { - expect( +Future _testPopulateBranchEmpty(GitDir gitDir, String branchName) async { + await check( _testPopulateBranchCore(gitDir, branchName, {}, 'empty?'), - throwsA( - isA() - .having((ge) => ge.message, 'message', 'No files were added'), - ), + ).throws( + (it) => it.has((e) => e.message, 'message').equals('No files were added'), ); } @@ -433,22 +405,18 @@ Future> _testPopulateBranchCore( Directory? tempDir; try { - final commit = await gitDir.updateBranch( - branchName, - (td) { - // strictly speaking, users of this API should not hold on to TempDir - // but this is for testing - tempDir = td; - - return doDescriptorPopulate(tempDir!.path, contents); - }, - commitMessage, - ); + final commit = await gitDir.updateBranch(branchName, (td) { + // strictly speaking, users of this API should not hold on to TempDir + // but this is for testing + tempDir = td; + + return doDescriptorPopulate(tempDir!.path, contents); + }, commitMessage); return MapEntry(commit, originalCommitCount); } finally { if (tempDir != null) { - expect(tempDir!.existsSync(), false); + check(tempDir!.existsSync()).isFalse(); } } } @@ -471,35 +439,33 @@ Future _testPopulateBranchWithContent( final originalCommitCount = pair.value; if (originalCommitCount == 0) { - expect( + check( returnedCommit.parents, - isEmpty, - reason: 'This should be the first commit', - ); + because: 'This should be the first commit', + ).isEmpty(); } else { - expect(returnedCommit.parents, hasLength(1)); + check(returnedCommit.parents).length.equals(1); } - expect(returnedCommit, isNotNull, reason: 'Commit should not be null'); - expect(returnedCommit.message, commitMessage); + check(returnedCommit, because: 'Commit should not be null').isNotNull(); + check(returnedCommit.message).equals(commitMessage); // new check to see if things are updated it gd1 final branchRef = (await gitDir.branchReference(branchName))!; final commit = await gitDir.commitFromRevision(branchRef.reference); - expect( + check( commit.content, - returnedCommit.content, - reason: 'content of queried commit should what was returned', - ); + because: 'content of queried commit should what was returned', + ).equals(returnedCommit.content); final entries = await gitDir.lsTree(commit.treeSha); - expect(entries.map((te) => te.name), unorderedEquals(contents.keys)); + check(entries.map((te) => te.name)).unorderedEquals(contents.keys); final newCommitCount = await gitDir.commitCount(branchRef.reference); - expect(newCommitCount, originalCommitCount + 1); + check(newCommitCount).equals(originalCommitCount + 1); } Future _testPopulateBranchWithDupeContent( @@ -519,21 +485,19 @@ Future _testPopulateBranchWithDupeContent( final returnedCommit = pair.key; final originalCommitCount = pair.value; - expect(returnedCommit, isNull); - expect( + check(returnedCommit).isNull(); + check( originalCommitCount, - greaterThan(0), - reason: 'must have had some original content', - ); + because: 'must have had some original content', + ).isGreaterThan(0); // new check to see if things are updated it gd1 final br = (await gitDir.branchReference(branchName))!; final newCommitCount = await gitDir.commitCount(br.reference); - expect( + check( newCommitCount, - originalCommitCount, - reason: 'no change in commit count', - ); + because: 'no change in commit count', + ).equals(originalCommitCount); } diff --git a/test/git_test.dart b/test/git_test.dart index 3e06e3bb..0f09f01f 100644 --- a/test/git_test.dart +++ b/test/git_test.dart @@ -1,36 +1,28 @@ import 'dart:io'; +import 'package:checks/checks.dart'; import 'package:git/git.dart'; -import 'package:test/test.dart'; +import 'package:test/scaffolding.dart'; void main() { test('bad git command', () async { - await expectLater( - runGit(['not-a-command']), - throwsA( - isA() - .having( - (pe) => pe.message, - 'message', - contains("'not-a-command' is not a git command."), - ) - .having((pe) => pe.errorCode, 'errorCode', 1), - ), + await check(runGit(['not-a-command'])).throws( + (it) => it + ..has( + (pe) => pe.message, + 'message', + ).contains("'not-a-command' is not a git command.") + ..has((pe) => pe.errorCode, 'errorCode').equals(1), ); }); test('bad git command - echoOutput true', () async { - await expectLater( + await check( runGit(['not-a-command'], echoOutput: true), - throwsA( - isA() - .having( - (pe) => pe.message, - 'message', - 'Unknown error', - ) - .having((pe) => pe.errorCode, 'errorCode', 1), - ), + ).throws( + (it) => it + ..has((pe) => pe.message, 'message').contains('Unknown error') + ..has((pe) => pe.errorCode, 'errorCode').equals(1), ); }); } diff --git a/test/parse_test.dart b/test/parse_test.dart index 510557b3..64f17542 100644 --- a/test/parse_test.dart +++ b/test/parse_test.dart @@ -1,11 +1,12 @@ +import 'package:checks/checks.dart'; import 'package:git/git.dart'; import 'package:git/src/util.dart'; -import 'package:test/test.dart'; +import 'package:test/scaffolding.dart'; void main() { test('valid sha', () { const good = 'bcd1284d805951a16e765cea5b2273a464ee2d86'; - expect(isValidSha(good), true); + check(isValidSha(good)).isTrue(); final bad = [ '', @@ -20,35 +21,34 @@ void main() { '''bcd1284d805951a16e765cea5b2273a464ee2d86 ''', -// newline before + // newline before ''' -bcd1284d805951a16e765cea5b2273a464ee2d86''' +bcd1284d805951a16e765cea5b2273a464ee2d86''', ]; for (var v in bad) { - expect(isValidSha(v), isFalse, reason: "'$v' should be bad"); - expect(() => requireArgumentValidSha1(v, 'v'), throwsArgumentError); + check(isValidSha(v), because: "'$v' should be bad").isFalse(); + check(() => requireArgumentValidSha1(v, 'v')).throws(); } }); test('parse show-ref output', () { final parsed = CommitReference.fromShowRefOutput(_showRefOutput); - expect(parsed.length, 6); - for (var t in parsed) { - expect(t.sha, hasLength(40)); - expect(t.reference, isNot(isEmpty)); - } + check(parsed).length.equals(6); + check(parsed).every( + (e) => e + ..has((c) => c.sha, 'sha').length.equals(40) + ..has((c) => c.reference, 'reference').isNotEmpty(), + ); }); test('TreeEntry.parse', () { final result = TreeEntry.fromLsTreeOutput(_lsTreeOutput); - expect(result, hasLength(13)); - expect(result.first.name, '.gitignore'); - for (var v in result) { - expect(v, isNotNull); - } + check(result).length.equals(13); + check(result.first).has((e) => e.name, 'name').equals('.gitignore'); + check(result).every((e) => e.isNotNull()); }); } diff --git a/test/readme_test.dart b/test/readme_test.dart index 9de9ac67..4525782c 100644 --- a/test/readme_test.dart +++ b/test/readme_test.dart @@ -1,12 +1,13 @@ import 'dart:io'; -import 'package:test/test.dart'; +import 'package:checks/checks.dart'; +import 'package:test/scaffolding.dart'; void main() { test('readme example contents', () { final readmeContent = File('README.md').readAsStringSync(); final exampleContent = File('example/example.dart').readAsStringSync(); - expect(readmeContent, contains(exampleContent)); + check(readmeContent).contains(exampleContent); }); } diff --git a/test/tag_test.dart b/test/tag_test.dart index 49a1ba5c..a040744f 100644 --- a/test/tag_test.dart +++ b/test/tag_test.dart @@ -1,5 +1,6 @@ +import 'package:checks/checks.dart'; import 'package:git/git.dart'; -import 'package:test/test.dart'; +import 'package:test/scaffolding.dart'; import 'test_utils.dart'; @@ -12,13 +13,14 @@ void main() { await doDescriptorGitCommit(testDir, contents, 'Something'); final branchRef = await testDir.currentBranch(); - await runGit( - ['tag', givenTagName, branchRef.sha], - processWorkingDir: testDir.path, - ); + await runGit([ + 'tag', + givenTagName, + branchRef.sha, + ], processWorkingDir: testDir.path); final foundTag = (await testDir.tags().toList()).single; - expect(foundTag.tag, equals(givenTagName)); + check(foundTag.tag).equals(givenTagName); }); test('Parse annotated tag', () async { @@ -30,36 +32,31 @@ void main() { await doDescriptorGitCommit(testDir, contents, 'Something'); final branchRef = await testDir.currentBranch(); - await runGit( - [ - 'tag', - '--annotate', - '--message', - 'First tag', - newTagName, - branchRef.sha, - ], - processWorkingDir: testDir.path, - ); - - await runGit( - [ - 'tag', - '--annotate', - '--message', - 'Second tag', - anotherTagName, - branchRef.sha, - ], - processWorkingDir: testDir.path, - ); + await runGit([ + 'tag', + '--annotate', + '--message', + 'First tag', + newTagName, + branchRef.sha, + ], processWorkingDir: testDir.path); + + await runGit([ + 'tag', + '--annotate', + '--message', + 'Second tag', + anotherTagName, + branchRef.sha, + ], processWorkingDir: testDir.path); final tagsFound = await testDir.tags().toList(); - expect(tagsFound, hasLength(2)); + check(tagsFound).length.equals(2); final alphabeticallyFirstTag = tagsFound.first; - expect(alphabeticallyFirstTag.tag, equals(anotherTagName)); - expect(alphabeticallyFirstTag.objectSha, equals(branchRef.sha)); - expect(alphabeticallyFirstTag.type, equals('commit')); + check(alphabeticallyFirstTag) + ..has((t) => t.tag, 'tag').equals(anotherTagName) + ..has((t) => t.objectSha, 'objectSha').equals(branchRef.sha) + ..has((t) => t.type, 'type').equals('commit'); }); }