-
Notifications
You must be signed in to change notification settings - Fork 29.1k
Add --force to roll_dev.dart
#56501
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 --force to roll_dev.dart
#56501
Conversation
runGit('push $origin HEAD:dev', 'land the new version on the "dev" branch'); | ||
git.run('push $origin $version', 'publish the version'); | ||
git.run( | ||
'push ${force ? "--force " : ""}$origin HEAD:dev', |
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.
This is change 1
// describe the latest dev release | ||
const String ref = 'refs/heads/dev'; | ||
return git.getOutput( | ||
'describe --match $glob --exact-match --tags $ref', |
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.
This is change 2
'obtain last released version number', | ||
); | ||
} | ||
|
||
Match parseFullTag(String version) { | ||
// of the form: x.y.z-m.n.pre-c-g<revision> | ||
final RegExp versionPattern = RegExp( | ||
r'^(\d+)\.(\d+)\.(\d+)-(\d+)\.(\d+)\.pre-(\d+)-g([a-f0-9]+)$'); | ||
r'^(\d+)\.(\d+)\.(\d+)-(\d+)\.(\d+)\.pre$'); |
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.
This is part of change 2. Instead of describing HEAD, we grab the exact tag at the tip of refs/heads/dev
.
_reportGitFailureAndExit(result, explanation); | ||
return null; // for the analyzer's sake | ||
} | ||
class 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.
Created this wrapper so we can inject mocks for tests.
'obtain last released version number', | ||
); | ||
} | ||
|
||
Match parseFullTag(String version) { | ||
// of the form: x.y.z-m.n.pre-c-g<revision> | ||
final RegExp versionPattern = RegExp( | ||
r'^(\d+)\.(\d+)\.(\d+)-(\d+)\.(\d+)\.pre-(\d+)-g([a-f0-9]+)$'); | ||
r'^(\d+)\.(\d+)\.(\d+)-(\d+)\.(\d+)\.pre$'); |
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.
Does the comment need to updated too?
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 catch
} | ||
class Git { | ||
const Git(); | ||
String getOutput(String command, String explanation) { |
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.
String getOutput(String command, String explanation) { | |
String getOutput(String command, String explanation) { |
dev/tools/test/roll_dev_test.dart
Outdated
} | ||
const String pattern = r'The current directory is not a Flutter ' | ||
'repository checkout with a correctly configured upstream remote.'; | ||
expect(exception.toString(), contains(pattern)); |
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.
If this fails to catch something, this will throw an NPE here instead of failing to match.
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.
Apparently null
implements .toString()
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.
Oh right, its null
!
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 guess it's still safer to use exception?.toString()
though, so it doesn't match 'null'
...
dev/tools/test/roll_dev_test.dart
Outdated
const String pattern = r'Your git repository is not clean. Try running ' | ||
'"git clean -fd". Warning, this will delete files! Run with -n to find ' | ||
'out which ones.'; | ||
expect(exception.toString(), contains(pattern)); |
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.
same here
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 with nits. I would make sure the comments describing the tag format are all up to date too
Description
This PR does the following:
--force
flag, since dev releases can have cherry picks.Related Issues
FIxes #56340
Tests
Added extensive unit tests, exercising existing changed logic and the pre-existing logic.