Skip to content

Commit

Permalink
feat: Add git-commit-version flag to control commit creation
Browse files Browse the repository at this point in the history
  • Loading branch information
spydon committed Jan 11, 2024
1 parent 123f34b commit 9479e40
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 15 deletions.
16 changes: 12 additions & 4 deletions packages/melos/lib/src/command_runner/version.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,15 @@ class VersionCommand extends MelosCommand {
'git-tag-version',
abbr: 't',
defaultsTo: true,
help:
'By default, melos version will commit changes to pubspec.yaml files '
'and tag the release. Pass --no-git-tag-version to disable the '
'behaviour.',
help: 'By default, melos version will tag the release. Pass '
'--no-git-tag-version to disable the behaviour.',
);
argParser.addFlag(
'git-commit-version',
abbr: 'C',
defaultsTo: true,
help: 'By default, melos version will commit changes to pubspec.yaml '
'files. Pass --no-git-commit-version to disable the behaviour.',
);
argParser.addFlag(
'release-url',
Expand Down Expand Up @@ -167,6 +172,7 @@ class VersionCommand extends MelosCommand {
final updateDependentsConstraints =
argResults!['dependent-constraints'] as bool;
final tag = argResults!['git-tag-version'] as bool;
final commit = argResults!['git-commit-version'] as bool;
final releaseUrl = argResults!.optional('release-url') as bool?;
final changelog = argResults!['changelog'] as bool;
final commitMessage =
Expand Down Expand Up @@ -196,6 +202,7 @@ class VersionCommand extends MelosCommand {
manualVersions: {packageName: versionChange},
force: force,
gitTag: tag,
gitCommit: commit,
releaseUrl: releaseUrl,
updateChangelog: changelog,
updateDependentsConstraints: updateDependentsConstraints,
Expand Down Expand Up @@ -238,6 +245,7 @@ class VersionCommand extends MelosCommand {
packageFilters: parsePackageFilters(config.path),
force: force,
gitTag: tag,
gitCommit: commit,
releaseUrl: releaseUrl,
updateChangelog: changelog,
updateDependentsConstraints: updateDependentsConstraints,
Expand Down
27 changes: 16 additions & 11 deletions packages/melos/lib/src/commands/version.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ mixin _VersionMixin on _RunMixin {
bool updateDependentsConstraints = true,
bool updateDependentsVersions = true,
bool gitTag = true,
bool gitCommit = true,
bool? releaseUrl,
String? message,
bool force = false,
Expand Down Expand Up @@ -59,6 +60,7 @@ mixin _VersionMixin on _RunMixin {
updateDependentsConstraints: updateDependentsConstraints,
updateDependentsVersions: updateDependentsVersions,
gitTag: gitTag,
gitCommit: gitCommit,
releaseUrl: releaseUrl,
message: message,
force: force,
Expand All @@ -81,6 +83,7 @@ mixin _VersionMixin on _RunMixin {
bool updateDependentsConstraints = true,
bool updateDependentsVersions = true,
bool gitTag = true,
bool gitCommit = true,
bool? releaseUrl,
String? message,
bool force = false,
Expand Down Expand Up @@ -354,17 +357,19 @@ mixin _VersionMixin on _RunMixin {
logger.newLine();
}

await _gitStageChanges(
workspace,
pendingPackageUpdates,
updateDependentsVersions: updateDependentsVersions,
);
await _gitCommitChanges(
workspace,
pendingPackageUpdates,
commitMessageTemplate,
updateDependentsVersions: updateDependentsVersions,
);
if (gitCommit) {
await _gitStageChanges(
workspace,
pendingPackageUpdates,
updateDependentsVersions: updateDependentsVersions,
);
await _gitCommitChanges(
workspace,
pendingPackageUpdates,
commitMessageTemplate,
updateDependentsVersions: updateDependentsVersions,
);
}

if (gitTag) {
await _gitTagChanges(
Expand Down

0 comments on commit 9479e40

Please sign in to comment.