fix(release): allow string array for commitArgs and tagArgs (#27797)

This commit is contained in:
Austin Fahsl 2024-09-17 04:19:33 -06:00 committed by GitHub
parent 0a8202aee1
commit 786537efa8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 21 additions and 13 deletions

View File

@ -634,7 +634,7 @@
"description": "Custom git commit message to use when committing the changes made by this command" "description": "Custom git commit message to use when committing the changes made by this command"
}, },
"commitArgs": { "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" "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": { "stageChanges": {
@ -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." "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": { "tagArgs": {
"type": "string", "type": ["string", "array"],
"description": "Additional arguments to pass to the `git tag` command invoked behind the scenes" "description": "Additional arguments to pass to the `git tag` command invoked behind the scenes"
} }
} }

View File

@ -30,10 +30,10 @@ interface GitCommitAndTagOptions {
stageChanges?: boolean; stageChanges?: boolean;
gitCommit?: boolean; gitCommit?: boolean;
gitCommitMessage?: string; gitCommitMessage?: string;
gitCommitArgs?: string; gitCommitArgs?: string | string[];
gitTag?: boolean; gitTag?: boolean;
gitTagMessage?: string; gitTagMessage?: string;
gitTagArgs?: string; gitTagArgs?: string | string[];
} }
export type VersionOptions = NxReleaseArgs & export type VersionOptions = NxReleaseArgs &

View File

@ -251,7 +251,7 @@ export async function gitCommit({
logFn, logFn,
}: { }: {
messages: string[]; messages: string[];
additionalArgs?: string; additionalArgs?: string | string[];
dryRun?: boolean; dryRun?: boolean;
verbose?: boolean; verbose?: boolean;
logFn?: (message: string) => void; logFn?: (message: string) => void;
@ -263,8 +263,12 @@ export async function gitCommit({
commandArgs.push('--message', message); commandArgs.push('--message', message);
} }
if (additionalArgs) { if (additionalArgs) {
if (Array.isArray(additionalArgs)) {
commandArgs.push(...additionalArgs);
} else {
commandArgs.push(...additionalArgs.split(' ')); commandArgs.push(...additionalArgs.split(' '));
} }
}
if (verbose) { if (verbose) {
logFn( logFn(
@ -305,7 +309,7 @@ export async function gitTag({
}: { }: {
tag: string; tag: string;
message?: string; message?: string;
additionalArgs?: string; additionalArgs?: string | string[];
dryRun?: boolean; dryRun?: boolean;
verbose?: boolean; verbose?: boolean;
logFn?: (message: string) => void; logFn?: (message: string) => void;
@ -321,8 +325,12 @@ export async function gitTag({
message || tag, message || tag,
]; ];
if (additionalArgs) { if (additionalArgs) {
if (Array.isArray(additionalArgs)) {
commandArgs.push(...additionalArgs);
} else {
commandArgs.push(...additionalArgs.split(' ')); commandArgs.push(...additionalArgs.split(' '));
} }
}
if (verbose) { if (verbose) {
logFn( logFn(

View File

@ -88,7 +88,7 @@ export async function commitChanges({
isDryRun?: boolean; isDryRun?: boolean;
isVerbose?: boolean; isVerbose?: boolean;
gitCommitMessages?: string[]; gitCommitMessages?: string[];
gitCommitArgs?: string; gitCommitArgs?: string | string[];
}) { }) {
if (!changedFiles?.length && !deletedFiles?.length) { if (!changedFiles?.length && !deletedFiles?.length) {
throw new Error('Error: No changed files to commit'); throw new Error('Error: No changed files to commit');

View File

@ -123,9 +123,9 @@ export interface NxReleaseGitConfiguration {
*/ */
commitMessage?: string; 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. * Whether or not to stage the changes made by this command. Always treated as true if commit is true.
*/ */
@ -139,9 +139,9 @@ export interface NxReleaseGitConfiguration {
*/ */
tagMessage?: string; 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 { export interface NxReleaseConventionalCommitsConfiguration {