Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/dependabot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ updates:
labels:
- autosubmit
groups:
dependencies:
github-actions:
patterns:
- "*"
25 changes: 17 additions & 8 deletions pkgs/blast_repo/bin/blast_repo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ import 'package:stack_trace/stack_trace.dart';
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',
Expand All @@ -28,6 +29,10 @@ Future<void> main(List<String> args) async {
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',
Expand All @@ -54,29 +59,33 @@ Future<void> main(List<String> args) async {
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);
Expand Down
22 changes: 16 additions & 6 deletions pkgs/blast_repo/lib/src/top_level.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ final allTweaks = Set<RepoTweak>.unmodifiable([
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,
Expand Down Expand Up @@ -83,6 +85,11 @@ ${fixes.join(', ')}
],
);

await gitDir.exec(
'Changes:',
['--no-pager', 'show'],
);

await runProc(
'Creating pull request',
'gh',
Expand All @@ -97,9 +104,11 @@ ${fixes.join(', ')}
'${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,
);
},
);
Expand All @@ -108,10 +117,11 @@ ${fixes.join(', ')}
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)
Expand Down
2 changes: 1 addition & 1 deletion pkgs/blast_repo/lib/src/tweaks/dependabot_tweak.dart
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ Map<String, Object> _githubActionValue(String frequency) {
'schedule': {'interval': frequency},
'labels': ['autosubmit'],
'groups': {
'dependencies': {
'github-actions': {
'patterns': ['*']
}
},
Expand Down
7 changes: 7 additions & 0 deletions pkgs/blast_repo/lib/src/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Future<void> runProc(
String proc,
List<String> args, {
required String workingDirectory,
bool skipExecution = false,
}) async {
printHeader(description);

Expand All @@ -55,6 +56,12 @@ Future<void> runProc(
...args,
].join(' '),
);

if (skipExecution) {
print('** skipping execution for $proc **');
return;
}

final ghProc = await Process.start(
proc,
args,
Expand Down
2 changes: 1 addition & 1 deletion pkgs/blast_repo/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ environment:
sdk: ^3.1.0

dependencies:
args: ^2.3.1
args: ^2.4.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

collection: ^1.17.0
git: ^2.2.0
github: ^9.6.0
Expand Down
6 changes: 3 additions & 3 deletions pkgs/blast_repo/test/dependabot_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ updates:
labels:
- autosubmit
groups:
dependencies:
github-actions:
patterns:
- "*"
''');
Expand All @@ -79,7 +79,7 @@ updates:
labels:
- autosubmit
groups:
dependencies:
github-actions:
patterns:
- "*"
''';
Expand Down Expand Up @@ -113,7 +113,7 @@ updates:
labels:
- autosubmit
groups:
dependencies:
github-actions:
patterns:
- "*"
''';