mirror of
https://forgejo.stefka.eu/jiriks74/create-pull-request.git
synced 2025-01-18 16:01:06 +01:00
feat: add-paths input (#1010)
* add add-pattern-array argument * ignore return code * doc to add-pattern-array * update README.md * cleanup after success commit * fix integration tests * add test * update naming and docs * update readme * fix missing await * update docs Co-authored-by: avdim <avdim@mail.ru> Co-authored-by: Авдеев Дима <avdeev@tutu.tech>
This commit is contained in:
parent
4b53b6fd1a
commit
dcd5fd746d
9 changed files with 229 additions and 65 deletions
|
@ -91,7 +91,8 @@ export async function createOrUpdateBranch(
|
|||
base: string,
|
||||
branch: string,
|
||||
branchRemoteName: string,
|
||||
signoff: boolean
|
||||
signoff: boolean,
|
||||
addPaths: string[]
|
||||
): Promise<CreateOrUpdateBranchResult> {
|
||||
// Get the working base.
|
||||
// When a ref, it may or may not be the actual base.
|
||||
|
@ -120,12 +121,17 @@ 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 path of addPaths) {
|
||||
await git.exec(['add', path], true)
|
||||
}
|
||||
const params = ['-m', commitMessage]
|
||||
if (signoff) {
|
||||
params.push('--signoff')
|
||||
}
|
||||
await git.commit(params)
|
||||
// Remove uncommitted tracked and untracked changes
|
||||
await git.exec(['reset', '--hard'])
|
||||
await git.exec(['clean', '-f'])
|
||||
}
|
||||
|
||||
// Perform fetch and reset the working base
|
||||
|
|
|
@ -12,6 +12,7 @@ import * as utils from './utils'
|
|||
export interface Inputs {
|
||||
token: string
|
||||
path: string
|
||||
addPaths: string[]
|
||||
commitMessage: string
|
||||
committer: string
|
||||
author: string
|
||||
|
@ -173,7 +174,8 @@ export async function createPullRequest(inputs: Inputs): Promise<void> {
|
|||
inputs.base,
|
||||
inputs.branch,
|
||||
branchRemoteName,
|
||||
inputs.signoff
|
||||
inputs.signoff,
|
||||
inputs.addPaths
|
||||
)
|
||||
core.endGroup()
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ async function run(): Promise<void> {
|
|||
const inputs: Inputs = {
|
||||
token: core.getInput('token'),
|
||||
path: core.getInput('path'),
|
||||
addPaths: utils.getInputAsArray('add-paths'),
|
||||
commitMessage: core.getInput('commit-message'),
|
||||
committer: core.getInput('committer'),
|
||||
author: core.getInput('author'),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue