Fix a bug with build identifiers (#29)


diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0efa0ea..78865c8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,8 @@
+# 1.4.1
+
+* Fix a bug where there upper bound of a version range with a build identifier
+  could accidentally be rewritten.
+
 # 1.4.0
 
 * Add a `Version.firstPreRelease` getter that returns the first possible
diff --git a/lib/src/version_range.dart b/lib/src/version_range.dart
index 99dc718..a566891 100644
--- a/lib/src/version_range.dart
+++ b/lib/src/version_range.dart
@@ -72,6 +72,7 @@
         !includeMax &&
         max != null &&
         !max.isPreRelease &&
+        max.build.isEmpty &&
         (min == null ||
             !min.isPreRelease ||
             !equalsWithoutPreRelease(min, max))) {
@@ -439,7 +440,9 @@
           var minIsPreReleaseOfMax = min != null &&
               min.isPreRelease &&
               equalsWithoutPreRelease(min, max);
-          if (!max.isPreRelease && !minIsPreReleaseOfMax) buffer.write("-∞");
+          if (!max.isPreRelease && max.build.isEmpty && !minIsPreReleaseOfMax) {
+            buffer.write("-∞");
+          }
         }
       }
     }
diff --git a/test/version_range_test.dart b/test/version_range_test.dart
index 4bdc21c..a24faae 100644
--- a/test/version_range_test.dart
+++ b/test/version_range_test.dart
@@ -33,6 +33,11 @@
                 .max,
             equals(v124));
       });
+
+      test("max has a build identifier", () {
+        expect(new VersionRange(max: new Version.parse("1.2.4+1")).max,
+            equals(new Version.parse("1.2.4+1")));
+      });
     });
 
     test('allows omitting max', () {