updates for the blast_repo tool (#267)
diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml
index 492a82f..bf6b38a 100644
--- a/.github/dependabot.yaml
+++ b/.github/dependabot.yaml
@@ -9,6 +9,6 @@
labels:
- autosubmit
groups:
- dependencies:
+ github-actions:
patterns:
- "*"
diff --git a/pkgs/blast_repo/bin/blast_repo.dart b/pkgs/blast_repo/bin/blast_repo.dart
index 1208ce6..621495c 100644
--- a/pkgs/blast_repo/bin/blast_repo.dart
+++ b/pkgs/blast_repo/bin/blast_repo.dart
@@ -13,8 +13,9 @@
Future<void> main(List<String> args) async {
final parser = ArgParser()
..addFlag(
- 'keep-temp',
- help: "Don't delete the temporary repo clone.",
+ 'dry-run',
+ aliases: ['keep-temp'],
+ help: "Don't create a PR or delete the temporary repo clone.",
negatable: false,
)
..addMultiOption('tweaks',
@@ -28,6 +29,10 @@
valueHelp: 'github-id',
help: 'Specify the GitHub handle for the desired reviewer.',
)
+ ..addMultiOption(
+ 'labels',
+ help: 'Specify labels to apply to the PR.',
+ )
..addFlag(
'help',
abbr: 'h',
@@ -54,29 +59,33 @@
return;
}
- if (argResults['help'] as bool || argResults.rest.isEmpty) {
+ if (argResults.flag('help') || argResults.rest.isEmpty) {
printUsage();
return;
}
final slug = argResults.rest.single;
- final keepTemp = argResults['keep-temp'] as bool;
+ final dryRun = argResults.flag('dry-run');
- final prReviewer = argResults['reviewer'] as String?;
- final explicitTweakIds = argResults['tweaks'] as List<String>;
+ final reviewer = argResults.option('reviewer');
+ final explicitTweakIds = argResults.multiOption('tweaks');
final explicitTweaks = explicitTweakIds.isEmpty
? null
: explicitTweakIds
.map((id) => allTweaks.firstWhere((t) => t.id == id))
.toList();
+ final labels = argResults.multiOption('labels');
+
try {
await runFix(
slug: slug,
- deleteTemp: !keepTemp,
+ deleteTemp: !dryRun,
tweaks: explicitTweaks,
- prReviewer: prReviewer,
+ reviewer: reviewer,
+ labels: labels,
+ dryRun: dryRun,
);
} catch (error, stack) {
final chain = Chain.forTrace(stack);
diff --git a/pkgs/blast_repo/lib/src/top_level.dart b/pkgs/blast_repo/lib/src/top_level.dart
index 40ac0af..dd8514c 100644
--- a/pkgs/blast_repo/lib/src/top_level.dart
+++ b/pkgs/blast_repo/lib/src/top_level.dart
@@ -27,8 +27,10 @@
Future<void> runFix({
required String slug,
required bool deleteTemp,
- required String? prReviewer,
- Iterable<RepoTweak>? tweaks,
+ required String? reviewer,
+ List<RepoTweak>? tweaks,
+ List<String> labels = const [],
+ bool dryRun = false,
}) async {
await withSystemTemp(
deleteTemp: deleteTemp,
@@ -83,6 +85,11 @@
],
);
+ await gitDir.exec(
+ 'Changes:',
+ ['--no-pager', 'show'],
+ );
+
await runProc(
'Creating pull request',
'gh',
@@ -97,9 +104,11 @@
'${fixes.map((fix) => '- `$fix`').join('\n')}',
'--repo',
slug,
- if (prReviewer != null) ...['--reviewer', prReviewer]
+ if (reviewer != null) ...['--reviewer', reviewer],
+ for (final label in labels) ...['--label', label],
],
workingDirectory: tempDir.path,
+ skipExecution: dryRun,
);
},
);
@@ -108,10 +117,11 @@
Future<Map<RepoTweak, FixResult>> fixAll(
String repoSlug,
Directory checkout, {
- Iterable<RepoTweak>? tweaks,
+ List<RepoTweak>? tweaks,
}) async {
- tweaks ??=
- allTweaks.where((tweak) => tweak.shouldRunByDefault(checkout, repoSlug));
+ tweaks ??= allTweaks
+ .where((tweak) => tweak.shouldRunByDefault(checkout, repoSlug))
+ .toList();
return {
for (var tweak in tweaks)
diff --git a/pkgs/blast_repo/lib/src/tweaks/dependabot_tweak.dart b/pkgs/blast_repo/lib/src/tweaks/dependabot_tweak.dart
index f5de299..19fd8e4 100644
--- a/pkgs/blast_repo/lib/src/tweaks/dependabot_tweak.dart
+++ b/pkgs/blast_repo/lib/src/tweaks/dependabot_tweak.dart
@@ -163,7 +163,7 @@
'schedule': {'interval': frequency},
'labels': ['autosubmit'],
'groups': {
- 'dependencies': {
+ 'github-actions': {
'patterns': ['*']
}
},
diff --git a/pkgs/blast_repo/lib/src/utils.dart b/pkgs/blast_repo/lib/src/utils.dart
index cfa9662..5d58a87 100644
--- a/pkgs/blast_repo/lib/src/utils.dart
+++ b/pkgs/blast_repo/lib/src/utils.dart
@@ -46,6 +46,7 @@
String proc,
List<String> args, {
required String workingDirectory,
+ bool skipExecution = false,
}) async {
printHeader(description);
@@ -55,6 +56,12 @@
...args,
].join(' '),
);
+
+ if (skipExecution) {
+ print('** skipping execution for $proc **');
+ return;
+ }
+
final ghProc = await Process.start(
proc,
args,
diff --git a/pkgs/blast_repo/pubspec.yaml b/pkgs/blast_repo/pubspec.yaml
index 0b8eae9..b9e99ae 100644
--- a/pkgs/blast_repo/pubspec.yaml
+++ b/pkgs/blast_repo/pubspec.yaml
@@ -7,7 +7,7 @@
sdk: ^3.1.0
dependencies:
- args: ^2.3.1
+ args: ^2.4.0
collection: ^1.17.0
git: ^2.2.0
github: ^9.6.0
diff --git a/pkgs/blast_repo/test/dependabot_test.dart b/pkgs/blast_repo/test/dependabot_test.dart
index 8819543..20a6f1d 100644
--- a/pkgs/blast_repo/test/dependabot_test.dart
+++ b/pkgs/blast_repo/test/dependabot_test.dart
@@ -56,7 +56,7 @@
labels:
- autosubmit
groups:
- dependencies:
+ github-actions:
patterns:
- "*"
''');
@@ -79,7 +79,7 @@
labels:
- autosubmit
groups:
- dependencies:
+ github-actions:
patterns:
- "*"
''';
@@ -113,7 +113,7 @@
labels:
- autosubmit
groups:
- dependencies:
+ github-actions:
patterns:
- "*"
''';