Skip to content
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

Support Xcode betas with xcode-locator #7371

Closed
wants to merge 2 commits into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* {@code 5.0.1beta2}. Components must start with a non-negative integer and at least one component
* must be present.
*
* <p>Specifically, the format of a component is {@code \d+([a-z]+\d*)?}.
* <p>Specifically, the format of a component is {@code \d+([a-z0-9]*?)?(\d+)?}.
*
* <p>Dotted versions are ordered using natural integer sorting on components in order from first to
* last where any missing element is considered to have the value 0 if they don't contain any
Expand Down Expand Up @@ -122,9 +122,10 @@ public static Option option(DottedVersion version) {
return version == null ? null : new Option(version);
}
private static final Splitter DOT_SPLITTER = Splitter.on('.');
private static final Pattern COMPONENT_PATTERN = Pattern.compile("(\\d+)(?:([a-z]+)(\\d*))?");
private static final Pattern COMPONENT_PATTERN =
Pattern.compile("(\\d+)([a-z0-9]*?)?(\\d+)?", Pattern.CASE_INSENSITIVE);
private static final String ILLEGAL_VERSION =
"Dotted version components must all be of the form \\d+([a-z]+\\d*)? but got %s";
"Dotted version components must all be of the form \\d+([a-z0-9]*?)?(\\d+)? but got %s";
private static final String NO_ALPHA_SEQUENCE = null;
private static final Component ZERO_COMPONENT = new Component(0, NO_ALPHA_SEQUENCE, 0, "0");

Expand Down Expand Up @@ -165,7 +166,7 @@ private static Component toComponent(String component, String version) {
int secondNumber = 0;
firstNumber = parseNumber(parsedComponent, 1, version);

if (parsedComponent.group(2) != null) {
if (!Strings.isNullOrEmpty(parsedComponent.group(2))) {
alphaSequence = parsedComponent.group(2);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public void testCompareTo() throws Exception {
.addEqualityGroup(DottedVersion.fromString("1.2beta12.1"))
.addEqualityGroup(DottedVersion.fromString("1.2.0"), DottedVersion.fromString("1.2"))
.addEqualityGroup(DottedVersion.fromString("1.20"))
.addEqualityGroup(DottedVersion.fromString("10.2.0.10P99q"))
.testCompare();
}

Expand All @@ -52,6 +53,7 @@ public void testEquals() throws Exception {
.addEqualityGroup(DottedVersion.fromString("0.1"), DottedVersion.fromString("0.01"))
.addEqualityGroup(DottedVersion.fromString("0.2"), DottedVersion.fromString("0.2.0"))
.addEqualityGroup(DottedVersion.fromString("1.2xy2"), DottedVersion.fromString("1.2xy2"))
.addEqualityGroup(DottedVersion.fromString("10.2.0.10P99q"), DottedVersion.fromString("10.2.0.10P99q0"))
.addEqualityGroup(
DottedVersion.fromString("1.2x"),
DottedVersion.fromString("1.2x0"),
Expand Down
17 changes: 11 additions & 6 deletions tools/osx/xcode_locator.m
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,17 @@ static void AddEntryToDictionary(
NSLog(@"Version strings for %@: short=%@, expanded=%@",
url, version, expandedVersion);

NSURL *versionPlistUrl = [url
URLByAppendingPathComponent:@"Contents/version.plist"];
NSDictionary *versionPlistContents = [[NSDictionary alloc]
initWithContentsOfURL:versionPlistUrl error:nil];
NSString *productVersion = [versionPlistContents
objectForKey:@"ProductBuildVersion"];
if (productVersion) {
expandedVersion = [expandedVersion
stringByAppendingFormat:@".%@", productVersion];
}

NSURL *developerDir =
[url URLByAppendingPathComponent:@"Contents/Developer"];
XcodeVersionEntry *entry =
Expand Down Expand Up @@ -259,12 +270,6 @@ int main(int argc, const char * argv[]) {
versionArg = @"";
} else {
versionArg = firstArg;
NSCharacterSet *versSet =
[NSCharacterSet characterSetWithCharactersInString:@"0123456789."];
if ([versionArg rangeOfCharacterFromSet:versSet.invertedSet].length
!= 0) {
versionArg = nil;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

In theory we could add all uppercase and lowercase letters here, but I don't think this validation added a lot of value anyways, so it's probably fine to remove it entirely

}
}
if (versionArg == nil) {
Expand Down