Skip to content

Commit

Permalink
fix(release): allow string array for commitArgs and tagArgs (#27797)
Browse files Browse the repository at this point in the history
  • Loading branch information
fahslaj authored Sep 17, 2024
1 parent 0a8202a commit 786537e
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 13 deletions.
4 changes: 2 additions & 2 deletions packages/nx/schemas/nx-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@
"description": "Custom git commit message to use when committing the changes made by this command"
},
"commitArgs": {
"type": "string",
"type": ["string", "array"],
"description": "Additional arguments (added after the --message argument, which may or may not be customized with --git-commit-message) to pass to the `git commit` command invoked behind the scenes"
},
"stageChanges": {
Expand All @@ -650,7 +650,7 @@
"description": "Custom git tag message to use when tagging the changes made by this command. This defaults to be the same value as the tag itself."
},
"tagArgs": {
"type": "string",
"type": ["string", "array"],
"description": "Additional arguments to pass to the `git tag` command invoked behind the scenes"
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/nx/src/command-line/release/command-object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ interface GitCommitAndTagOptions {
stageChanges?: boolean;
gitCommit?: boolean;
gitCommitMessage?: string;
gitCommitArgs?: string;
gitCommitArgs?: string | string[];
gitTag?: boolean;
gitTagMessage?: string;
gitTagArgs?: string;
gitTagArgs?: string | string[];
}

export type VersionOptions = NxReleaseArgs &
Expand Down
16 changes: 12 additions & 4 deletions packages/nx/src/command-line/release/utils/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ export async function gitCommit({
logFn,
}: {
messages: string[];
additionalArgs?: string;
additionalArgs?: string | string[];
dryRun?: boolean;
verbose?: boolean;
logFn?: (message: string) => void;
Expand All @@ -263,7 +263,11 @@ export async function gitCommit({
commandArgs.push('--message', message);
}
if (additionalArgs) {
commandArgs.push(...additionalArgs.split(' '));
if (Array.isArray(additionalArgs)) {
commandArgs.push(...additionalArgs);
} else {
commandArgs.push(...additionalArgs.split(' '));
}
}

if (verbose) {
Expand Down Expand Up @@ -305,7 +309,7 @@ export async function gitTag({
}: {
tag: string;
message?: string;
additionalArgs?: string;
additionalArgs?: string | string[];
dryRun?: boolean;
verbose?: boolean;
logFn?: (message: string) => void;
Expand All @@ -321,7 +325,11 @@ export async function gitTag({
message || tag,
];
if (additionalArgs) {
commandArgs.push(...additionalArgs.split(' '));
if (Array.isArray(additionalArgs)) {
commandArgs.push(...additionalArgs);
} else {
commandArgs.push(...additionalArgs.split(' '));
}
}

if (verbose) {
Expand Down
2 changes: 1 addition & 1 deletion packages/nx/src/command-line/release/utils/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export async function commitChanges({
isDryRun?: boolean;
isVerbose?: boolean;
gitCommitMessages?: string[];
gitCommitArgs?: string;
gitCommitArgs?: string | string[];
}) {
if (!changedFiles?.length && !deletedFiles?.length) {
throw new Error('Error: No changed files to commit');
Expand Down
8 changes: 4 additions & 4 deletions packages/nx/src/config/nx-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ export interface NxReleaseGitConfiguration {
*/
commitMessage?: string;
/**
* Additional arguments (added after the --message argument, which may or may not be customized with --git-commit-message) to pass to the `git commit` command invoked behind the scenes
* Additional arguments (added after the --message argument, which may or may not be customized with --git-commit-message) to pass to the `git commit` command invoked behind the scenes. May be a string or array of strings.
*/
commitArgs?: string;
commitArgs?: string | string[];
/**
* Whether or not to stage the changes made by this command. Always treated as true if commit is true.
*/
Expand All @@ -139,9 +139,9 @@ export interface NxReleaseGitConfiguration {
*/
tagMessage?: string;
/**
* Additional arguments to pass to the `git tag` command invoked behind the scenes
* Additional arguments to pass to the `git tag` command invoked behind the scenes. . May be a string or array of strings.
*/
tagArgs?: string;
tagArgs?: string | string[];
}

export interface NxReleaseConventionalCommitsConfiguration {
Expand Down

0 comments on commit 786537e

Please sign in to comment.