Skip to content

Commit

Permalink
Validate if git is installed
Browse files Browse the repository at this point in the history
  • Loading branch information
leoafarias committed Aug 25, 2024
1 parent 145a9b8 commit a739534
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/src/models/flutter_version_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,7 @@ class FlutterVersion with FlutterVersionMappable {

return compareSemver(versionWeight, otherVersion);
}

@override
String toString() => name;
}
8 changes: 8 additions & 0 deletions lib/src/workflows/ensure_cache.workflow.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Future<CacheFlutterVersion> ensureCacheWorkflow(
bool force = false,
}) async {
_validateContext();
_validateGit();
// Get valid flutter version
final validVersion = await validateFlutterVersion(version, force: force);
try {
Expand Down Expand Up @@ -238,3 +239,10 @@ void _validateContext() {
);
}
}

void _validateGit() {
final isGitInstalled = Process.runSync('git', ['--version']).exitCode == 0;
if (!isGitInstalled) {
throw AppException('Git is not installed');
}
}

0 comments on commit a739534

Please sign in to comment.