Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(458)

Unified Diff: tools/release/version.dart

Issue 11086078: Do more robust parsing of the revision info when creating version numbers. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/release/version.dart
===================================================================
--- tools/release/version.dart (revision 13526)
+++ tools/release/version.dart (working copy)
@@ -119,6 +119,23 @@
return '';
}
+ int getRevisionFromSvnInfo(String info) {
+ if (info == null || info == '') return 0;
+ var lines = info.split("\n");
+ RegExp exp = const RegExp(r"Revision: (\d*)");
+ for (var line in lines) {
+ if (exp.hasMatch(line)) {
+ String revisionString = (exp.firstMatch(line).group(1));
+ try {
+ return int.parse(revisionString);
+ } catch(e) {
+ return 0;
+ }
+ }
+ }
+ return 0;
+ }
+
Future<int> getRevision() {
if (repositoryType == RepositoryType.UNKNOWN) {
return new Future.immediate(0);
@@ -131,15 +148,7 @@
if (result.exitCode != 0) {
return 0;
}
- // If anything goes wrong parsing the revision we simply return 0.
- try {
- // Extract the revision. It's located at the 8th line,
- // 18 characters in.
- String revisionString = result.stdout.split("\n")[8].substring(18);
- return int.parse(revisionString);
- } catch (e) {
- return 0;
- }
+ return getRevisionFromSvnInfo(result.stdout);
});
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698