-
-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add --only
option to sharezone cli.
#1292
Conversation
The option allows to run a `ConcurrentCommand` only for the specified package names. E.g.: `sz analyze --only sz_repo_cli`, `sz test sharezone,abgabe_client_lib`.
WalkthroughThe recent update introduces a new feature within the CLI tool, allowing users to target specific packages for task execution through the introduction of an Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
..addOption( | ||
'only', | ||
help: | ||
'Only run the task for the given package(s). Package names can be separated by comma. E.g. `--only package1` or `--only=package1,package2`.', | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure the description for the --only
option is clear and concise. Consider mentioning the expected behavior when no package names are provided.
Stream<Package> get packagesToProcess { | ||
var stream = repo.streamPackages(); | ||
|
||
final onlyPackageNames = _parseOnlyArg(); | ||
if (onlyPackageNames.isNotEmpty) { | ||
stream = | ||
stream.where((package) => onlyPackageNames.contains(package.name)); | ||
} | ||
|
||
return stream; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation of filtering packages based on the --only
option in packagesToProcess
is correct. However, consider the performance impact of calling stream.where
inside an if statement. For large repositories, this could introduce a delay. Evaluate if there's a more efficient way to filter the packages, possibly by pre-processing the list before converting it to a stream.
List<String> _parseOnlyArg() { | ||
final onlyArg = argResults!['only'] as String?; | ||
if (onlyArg == null) { | ||
return []; | ||
} | ||
return onlyArg.split(','); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The _parseOnlyArg
method correctly parses the --only
argument. However, it does not trim whitespace from the package names after splitting. This could lead to unexpected behavior if users include spaces after commas. Add trimming to ensure robustness.
- return onlyArg.split(',');
+ return onlyArg.split(',').map((name) => name.trim()).toList();
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
List<String> _parseOnlyArg() { | |
final onlyArg = argResults!['only'] as String?; | |
if (onlyArg == null) { | |
return []; | |
} | |
return onlyArg.split(','); | |
} | |
List<String> _parseOnlyArg() { | |
final onlyArg = argResults!['only'] as String?; | |
if (onlyArg == null) { | |
return []; | |
} | |
return onlyArg.split(',').map((name) => name.trim()).toList(); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Nice! We can also update the CI pipelines |
Which jobs do you mean exactly where this would be useful? |
The option allows to run a
ConcurrentCommand
only for the specified package names.E.g.:
sz analyze --only sz_repo_cli
,sz test sharezone,abgabe_client_lib
.Summary by CodeRabbit