Skip to content

Commit

Permalink
feat: add 'DefaultIncrementType' to AutoVer config
Browse files Browse the repository at this point in the history
  • Loading branch information
philasmar committed Mar 20, 2024
1 parent 66b0c02 commit 0269e34
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
3 changes: 1 addition & 2 deletions .autover/autover.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@
"IncrementType": "Patch"
}
],
"UseCommitsForChangelog": false,
"DefaultIncrementType": "Patch"
"UseCommitsForChangelog": false
}
10 changes: 10 additions & 0 deletions .autover/changes/3c7273f6-f83e-46cd-aa45-86cef528a89f.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"Projects": [
{
"Name": "AutoVer",
"ChangelogMessages": [
"Add \u0027DefaultIncrementType\u0027 to AutoVer config"
]
}
]
}
15 changes: 10 additions & 5 deletions src/AutoVer/Commands/VersionCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,17 @@ public async Task ExecuteAsync(
throw new NoVersionTagException($"The project '{availableProject.Path}' does not have a {ProjectConstants.VersionTag} tag. Add a {ProjectConstants.VersionTag} tag and run the tool again.");
}
}


var projectsIncremented = false;
foreach (var availableProject in userConfiguration.Projects)
{
if (availableProject.ProjectDefinition is null)
throw new InvalidUserConfigurationException($"The configured project '{availableProject.Path}' is invalid.");

if (!availableProject.IncrementType.Equals(IncrementType.None))
projectsIncremented = true;
projectHandler.UpdateVersion(availableProject.ProjectDefinition, availableProject.IncrementType, availableProject.PrereleaseLabel);
gitHandler.StageChanges(userConfiguration, availableProject.Path);
}

var dateTimeNow = DateTime.UtcNow;
var nextVersionNumber = $"version_{dateTimeNow:yyyy-MM-dd.HH.mm.ss}";

// When done, reset the config file if the user had one
if (userConfiguration.PersistConfiguration)
Expand All @@ -57,6 +56,12 @@ public async Task ExecuteAsync(
});
}

if (!projectsIncremented)
return;

var dateTimeNow = DateTime.UtcNow;
var nextVersionNumber = $"version_{dateTimeNow:yyyy-MM-dd.HH.mm.ss}";

if (!optionNoCommit)
{
gitHandler.CommitChanges(userConfiguration, $"Release {dateTimeNow:yyyy-MM-dd}");
Expand Down

0 comments on commit 0269e34

Please sign in to comment.