diff --git a/.gitignore b/.gitignore index d352240..93a4a64 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ lib/ node_modules/ .DS_Store +.idea diff --git a/action.yml b/action.yml index 96fb5d1..ac92da0 100644 --- a/action.yml +++ b/action.yml @@ -64,6 +64,10 @@ inputs: draft: description: 'Create a draft pull request' default: false + add-pattern-array: + description: 'git add [pattern]' + default: | + -A outputs: pull-request-number: description: 'The pull request number' diff --git a/dist/index.js b/dist/index.js index be6695e..b4895ee 100644 --- a/dist/index.js +++ b/dist/index.js @@ -98,7 +98,7 @@ function splitLines(multilineString) { .map(s => s.trim()) .filter(x => x !== ''); } -function createOrUpdateBranch(git, commitMessage, base, branch, branchRemoteName, signoff) { +function createOrUpdateBranch(git, commitMessage, base, branch, branchRemoteName, signoff, filePatterns) { return __awaiter(this, void 0, void 0, function* () { // Get the working base. // When a ref, it may or may not be the actual base. @@ -124,7 +124,9 @@ function createOrUpdateBranch(git, commitMessage, base, branch, branchRemoteName // Commit any uncommitted changes if (yield git.isDirty(true)) { core.info('Uncommitted changes found. Adding a commit.'); - yield git.exec(['add', '-A']); + for (const filePattern of filePatterns) { + yield git.exec(['add', filePattern]); + } const params = ['-m', commitMessage]; if (signoff) { params.push('--signoff'); @@ -377,7 +379,7 @@ function createPullRequest(inputs) { core.endGroup(); // Create or update the pull request branch core.startGroup('Create or update the pull request branch'); - const result = yield (0, create_or_update_branch_1.createOrUpdateBranch)(git, inputs.commitMessage, inputs.base, inputs.branch, branchRemoteName, inputs.signoff); + const result = yield (0, create_or_update_branch_1.createOrUpdateBranch)(git, inputs.commitMessage, inputs.base, inputs.branch, branchRemoteName, inputs.signoff, inputs.addPatternArray); core.endGroup(); if (['created', 'updated'].includes(result.action)) { // The branch was created or updated @@ -1090,7 +1092,8 @@ function run() { reviewers: utils.getInputAsArray('reviewers'), teamReviewers: utils.getInputAsArray('team-reviewers'), milestone: Number(core.getInput('milestone')), - draft: core.getInput('draft') === 'true' + draft: core.getInput('draft') === 'true', + addPatternArray: utils.getInputAsArray('add-pattern-array') }; core.debug(`Inputs: ${(0, util_1.inspect)(inputs)}`); yield (0, create_pull_request_1.createPullRequest)(inputs); diff --git a/src/create-or-update-branch.ts b/src/create-or-update-branch.ts index f33051d..1934287 100644 --- a/src/create-or-update-branch.ts +++ b/src/create-or-update-branch.ts @@ -91,7 +91,8 @@ export async function createOrUpdateBranch( base: string, branch: string, branchRemoteName: string, - signoff: boolean + signoff: boolean, + filePatterns: string[] ): Promise { // Get the working base. // When a ref, it may or may not be the actual base. @@ -120,7 +121,9 @@ export async function createOrUpdateBranch( // Commit any uncommitted changes if (await git.isDirty(true)) { core.info('Uncommitted changes found. Adding a commit.') - await git.exec(['add', '-A']) + for (const filePattern of filePatterns) { + await git.exec(['add', filePattern]) + } const params = ['-m', commitMessage] if (signoff) { params.push('--signoff') diff --git a/src/create-pull-request.ts b/src/create-pull-request.ts index 8b2c11e..73c874c 100644 --- a/src/create-pull-request.ts +++ b/src/create-pull-request.ts @@ -29,6 +29,7 @@ export interface Inputs { teamReviewers: string[] milestone: number draft: boolean + addPatternArray: string[] } export async function createPullRequest(inputs: Inputs): Promise { @@ -173,7 +174,8 @@ export async function createPullRequest(inputs: Inputs): Promise { inputs.base, inputs.branch, branchRemoteName, - inputs.signoff + inputs.signoff, + inputs.addPatternArray ) core.endGroup() diff --git a/src/main.ts b/src/main.ts index bb7b7e2..baa9a32 100644 --- a/src/main.ts +++ b/src/main.ts @@ -24,7 +24,8 @@ async function run(): Promise { reviewers: utils.getInputAsArray('reviewers'), teamReviewers: utils.getInputAsArray('team-reviewers'), milestone: Number(core.getInput('milestone')), - draft: core.getInput('draft') === 'true' + draft: core.getInput('draft') === 'true', + addPatternArray: utils.getInputAsArray('add-pattern-array') } core.debug(`Inputs: ${inspect(inputs)}`)