anchor.diff:    }
   
     Future<Option<Version>> _getReleaseVersion(Version latestTaggedVersion,
  -      Version currentPubspecVersion, GitDir gitDir, ReleaseType type) async {
  +      Version currentPubspecVersion, Option<Version> latestPublishedVersionOpt,
  +      GitDir gitDir, ReleaseType type, Project project) async {
  +    final isHosted = latestPublishedVersionOpt is Some;
  +
  +    final latestReleasedVersion = latestPublishedVersionOpt
  +        .map((lpv) => lpv >= latestTaggedVersion ? lpv : latestTaggedVersion)
  +        .getOrDefault(latestTaggedVersion);
  +
       if (latestTaggedVersion > currentPubspecVersion) {
         throw new StateError('the latest tagged version $latestTaggedVersion'
             ' is greater than the current pubspec version $currentPubspecVersion');
  
positive.code:     });
    }
  
    Future<bool> _hasCommitsSince(GitDir gitDir, Version sinceVersion) async {
      return (await commitCountSince(gitDir, sinceVersion.toString())) > 0;
    }
  
    @override
    ProjectCommand release({ReleaseType type: ReleaseType.minor}) {
      return projectCommandWithDependencies('Release version type $type',
  
negative.code:         // manually bumped version
          return await new Some(currentPubspecVersion);
        } else {
          // latest released version is same as pubspec version
          final hasChangesSinceLatestTaggedVersion =
              await _hasCommitsSince(gitDir, latestTaggedVersion);
  
          if (hasChangesSinceLatestTaggedVersion) {
            if (isHosted) {
              // Hosted packages must observe semantic versioning so not sensible
              // to try to automatically bump version
              throw new ArgumentError(
                  '${project.name} is hosted and has changes. '
                  'The version must be manually changed for hosted packages');
            } else {
              return new Some(type.bump(currentPubspecVersion));
            }
          } else {
            return const None();
          }
        }
      }
    }
  
    Future<bool> _hasCommitsSince(GitDir gitDir, Version sinceVersion) async {
      return (await commitCountSince(gitDir, sinceVersion.toString())) > 0;
    }
  
    Future<Option<Version>> _latestPublishedVersion(Project project) async {
      final Option<HostedPackageVersions> publishedVersionsOpt =
          await _pub.fetchPackageVersions().process(project);
  
      return publishedVersionsOpt
          .map((HostedPackageVersions versions) => versions.latest.version);
    }
  }
  