Skip to content

Commit

Permalink
Merge pull request #730 from leoafarias/fix/not-git-cache
Browse files Browse the repository at this point in the history
Fix/not git cache
  • Loading branch information
leoafarias authored May 31, 2024
2 parents 96733c3 + 612db15 commit ed66017
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 13 deletions.
1 change: 0 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ jobs:

test-os:
name: Test on ${{ matrix.os }}
needs: test
timeout-minutes: 30
runs-on: ${{ matrix.os }}
strategy:
Expand Down
2 changes: 1 addition & 1 deletion lib/src/services/flutter_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ class FlutterService extends ContextService {
throw Exception('Git cache directory does not exist');
}

final gitDir = await GitDir.fromExisting(context.gitCachePath);
try {
final gitDir = await GitDir.fromExisting(context.gitCachePath);
final result = await gitDir.runCommand(
['rev-parse', '--short', '--verify', ref],
);
Expand Down
8 changes: 8 additions & 0 deletions lib/src/workflows/resolve_dependencies.workflow.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ Future<void> resolveDependenciesWorkflow(
return;
}

if (!project.hasPubspec) {
logger
..info('Skipping "pub get" because no pubspec.yaml found.')
..spacer;

return;
}

final progress = logger.progress('Resolving dependencies...');

// Try to resolve offline
Expand Down
35 changes: 24 additions & 11 deletions lib/src/workflows/use_version.workflow.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,25 @@ Future<void> useVersionWorkflow({
}) async {
// If project use check that is Flutter project
if (!project.hasPubspec && !force) {
logger
..spacer
..info('No pubspec.yaml detected in this directory');
final proceed = logger.confirm('Would you like to continue?');
if (project.hasConfig) {
if (project.path != ctx.workingDirectory) {
logger
..spacer
..info('Using $kFvmConfigFileName in ${project.path}')
..spacer
..info(
'If this is incorrect either use the --force flag or remove the $kFvmConfigFileName and the $kFvmDirName directory.',
)
..spacer;
}
} else {
logger
..spacer
..info('No pubspec.yaml detected in this directory');
final proceed = logger.confirm('Would you like to continue?');

if (!proceed) exit(ExitCode.success.code);
if (!proceed) exit(ExitCode.success.code);
}
}

logger
Expand Down Expand Up @@ -111,12 +124,6 @@ Future<void> _checkGitignore(Project project, {required bool force}) async {
final updateGitIgnore = project.config?.updateGitIgnore ?? true;

logger.detail('Update gitignore: $updateGitIgnore');
if (!await GitDir.isGitDir(project.path)) {
logger.warn(
'Project is not a git repository. \n But will set .gitignore as IDEs may use it,'
'to determine what to index and display on searches,',
);
}

if (!updateGitIgnore) {
logger.detail(
Expand All @@ -131,6 +138,12 @@ Future<void> _checkGitignore(Project project, {required bool force}) async {
final ignoreFile = project.gitIgnoreFile;

if (!ignoreFile.existsSync()) {
if (!await GitDir.isGitDir(project.path)) {
logger.warn(
'Project is not a git repository. \n But will set .gitignore as IDEs may use it,'
'to determine what to index and display on searches,',
);
}
ignoreFile.createSync(recursive: true);
}

Expand Down

0 comments on commit ed66017

Please sign in to comment.