-
Notifications
You must be signed in to change notification settings - Fork 230
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
Validate git is clean when publishing #4373
Conversation
lib/src/validator/git_status.dart
Outdated
import '../utils.dart'; | ||
import '../validator.dart'; | ||
|
||
/// A validator that validates that no checked in files are modiofied in git. |
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.
/// A validator that validates that no checked in files are modiofied in git. | |
/// A validator that validates that no checked in files are modified in git. |
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.
Done
lib/src/validator/git_status.dart
Outdated
class GitStatusValidator extends Validator { | ||
@override | ||
Future<void> validate() async { | ||
if (package.inGitRepo) { |
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.
nit: please return early instead of nesting a bit more 🤣
if (package.inGitRepo) { | |
if (package.inGitRepo) { | |
return; | |
} |
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.
Done
lib/src/validator/git_status.dart
Outdated
for (var i = 0; i < output.length; i++) { | ||
if (output[i] != 0) { | ||
continue; | ||
} |
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.
Perhaps consider splitting this out into a helper library.. git.parseMachineStatus
or something.
This might be worth having unit tests cover.
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.
I split something out - but it is hard to make something really general I think...
lib/src/validator/git_status.dart
Outdated
if (output[i] != 0) { | ||
continue; | ||
} | ||
final filename = utf8.decode( |
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.
you might want to handle FormatException
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.
Good point! Done!
/// The first [skipPrefix] bytes of each substring will be ignored (useful for | ||
/// `git status -z`). If there are not enough bytes to skip, throws a | ||
/// [FormatException]. | ||
List<Uint8List> splitZeroTerminated(Uint8List output, {int skipPrefix = 0}) { |
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.
splitZeroTerminated
without the skipPrefix
might have been more sane.
But this is also fine :D
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.
Yeah - more sane - just I wanted to avoid creating too much garbage, and (as far as I can tell) utf8.decode
cannot work on a partial buffer...
These files can have minor differences in them (depending on the version of Dart?), so that it is difficult for them to always be identical to the ones checked in, during CI. Then there is a new warning that `pub publish --dry-run` produces, if the current git checkout is not clean: dart-lang/pub#4373. We need to reset these files to avoid that warning.
…sh (#3896) These files can have minor differences in them (depending on the version of Dart?), so that it is difficult for them to always be identical to the ones checked in, during CI. Then there is a new warning that `pub publish --dry-run` produces, if the current git checkout is not clean: dart-lang/pub#4373. We need to reset these files to avoid that warning.
Hi @sigurdm, couple questions for docs:
|
Yes, all the
Also yes. No |
Fixes #2040
Does not warn about newly added files, because they might get generated by a build step.