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

Initial support of --allow-different-versions #108

Closed
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions Versionize/ConfigurationContract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ public class ConfigurationContract
public String CommitSuffix { get; set; }
public ChangelogOptions Changelog { get; set; }
public string Prerelease { get; set; }
public bool? AllowDifferentVersions { get; set; }
}
7 changes: 5 additions & 2 deletions Versionize/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Text.Json;
using McMaster.Extensions.CommandLineUtils;
using McMaster.Extensions.CommandLineUtils;
using System.Text.Json;
using Versionize.CommandLine;
using Versionize.Versioning;

Expand Down Expand Up @@ -36,6 +36,7 @@ public static int Main(string[] args)
var optionPrerelease = app.Option("-p|--pre-release", "Release as pre-release version with given pre release label.", CommandOptionType.SingleValue);
var optionAggregatePrereleases = app.Option("-a|--aggregate-pre-releases", "Include all pre-release commits in the changelog since the last full version.", CommandOptionType.NoValue);
var optionUseProjVersionForBumpLogic = app.Option("--proj-version-bump-logic", "Use project version for bump logic, as opposed to git tag version.", CommandOptionType.NoValue);
var optionAllowDifferentVersions = app.Option("--allow-different-versions", "Allow different version of projects in folder", CommandOptionType.NoValue);

var inspectCmd = app.Command("inspect", inspectCmd => inspectCmd.OnExecute(() =>
{
Expand Down Expand Up @@ -68,6 +69,7 @@ public static int Main(string[] args)
Changelog = ChangelogOptions.Default,
AggregatePrereleases = optionAggregatePrereleases.HasValue(),
UseProjVersionForBumpLogic = optionUseProjVersionForBumpLogic.HasValue(),
AllowDifferentVersions = optionAllowDifferentVersions.HasValue()
},
optionIncludeAllCommitsInChangelog.HasValue());

Expand Down Expand Up @@ -151,6 +153,7 @@ private static ConfigurationContract FromJsonFile(string filePath)
AggregatePrereleases = configuration.AggregatePrereleases,
// TODO: Consider supporting optionalConfiguration
UseProjVersionForBumpLogic = configuration.UseProjVersionForBumpLogic,
AllowDifferentVersions = MergeBool(configuration.AllowDifferentVersions, optionalConfiguration?.AllowDifferentVersions),
};
}

Expand Down
3 changes: 2 additions & 1 deletion Versionize/VersionizeOptions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Versionize;
namespace Versionize;

public class VersionizeOptions
{
Expand All @@ -14,4 +14,5 @@ public class VersionizeOptions
public ChangelogOptions Changelog { get; set; } = ChangelogOptions.Default;
public bool AggregatePrereleases { get; set; }
public bool UseProjVersionForBumpLogic { get; set; }
public bool AllowDifferentVersions { get; set; }
}
4 changes: 2 additions & 2 deletions Versionize/WorkingCopy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public SemanticVersion Versionize(VersionizeOptions options)
Exit($"Could not find any projects files in {workingDirectory} that have a <Version> defined in their csproj file.", 1);
}

if (projects.HasInconsistentVersioning())
if (projects.HasInconsistentVersioning() && !options.AllowDifferentVersions)
{
Exit($"Some projects in {workingDirectory} have an inconsistent <Version> defined in their csproj file. Please update all versions to be consistent or remove the <Version> elements from projects that should not be versioned", 1);
}
Expand Down Expand Up @@ -150,7 +150,7 @@ public SemanticVersion Versionize(VersionizeOptions options)


Step($"bumping version from {projects.Version} to {nextVersion} in projects");

// Commit changelog and version source
if (!options.DryRun && (nextVersion != projects.Version))
{
Expand Down