feat: add pull input, deprecate pull_strategy (#294)
* feat: add pull input and deprecate pull_strategy * docs(README): update pull docs * fix: fix DeepScan issue * fix: minor formatting change
This commit is contained in:
@@ -61,9 +61,9 @@ Add a step like this to your workflow:
|
||||
# Default: ignore
|
||||
pathspec_error_handling: ignore
|
||||
|
||||
# The flag used on the pull strategy. Use NO-PULL to avoid the action pulling at all.
|
||||
# Arguments for the git pull command. Use NO-PULL to avoid the action pulling at all.
|
||||
# Default: '--no-rebase'
|
||||
pull_strategy: 'NO-PULL or --no-rebase or --no-ff or --rebase'
|
||||
pull: 'NO-PULL or --rebase --autostash ...'
|
||||
|
||||
# Whether to push the commit and, if any, its tags to the repo. It can also be used to set the git push arguments (see the paragraph below for more info)
|
||||
# Default: true
|
||||
|
||||
@@ -36,10 +36,15 @@ inputs:
|
||||
description: The way the action should handle pathspec errors from the add and remove commands.
|
||||
required: false
|
||||
default: ignore
|
||||
pull:
|
||||
description: Arguments for the git pull command. Use NO-PULL to avoid the action pulling at all.
|
||||
required: false
|
||||
# Default value currently set in runtime
|
||||
# default: '--no-rebase'
|
||||
pull_strategy:
|
||||
description: The flag used on the pull strategy. Use NO-PULL to avoid the action pulling at all.
|
||||
required: false
|
||||
default: '--no-rebase'
|
||||
deprecationMessage: The 'pull_strategy' input is deprecated, please use 'pull'
|
||||
push:
|
||||
description: Whether to push the commit and, if any, its tags to the repo. It can also be used to set the git push arguments (more info in the README)
|
||||
required: false
|
||||
|
||||
4
lib/index.js
generated
4
lib/index.js
generated
File diff suppressed because one or more lines are too long
28
src/main.ts
28
src/main.ts
@@ -26,6 +26,7 @@ core.info(`Running in ${baseDir}`)
|
||||
core.info('> Staging files...')
|
||||
|
||||
const peh = getInput('pathspec_error_handling')
|
||||
|
||||
if (getInput('add')) {
|
||||
core.info('> Adding files...')
|
||||
await add(peh == 'ignore' ? 'pathspec' : 'none')
|
||||
@@ -60,18 +61,16 @@ core.info(`Running in ${baseDir}`)
|
||||
.checkout(getInput('branch'), undefined, log)
|
||||
.catch(() => git.checkoutLocalBranch(getInput('branch'), log))
|
||||
|
||||
if (getInput('pull_strategy') == 'NO-PULL')
|
||||
core.info('> Not pulling from repo.')
|
||||
// The current default value is set here.
|
||||
// When the depreacted pull_strategy input is removed, the default should be set via the action manifest.
|
||||
const pull = getInput('pull') || getInput('pull_strategy') || '--no-rebase'
|
||||
if (pull == 'NO-PULL') core.info('> Not pulling from repo.')
|
||||
else {
|
||||
core.info('> Pulling from remote...')
|
||||
await git.fetch(undefined, log).pull(
|
||||
undefined,
|
||||
undefined,
|
||||
{
|
||||
[getInput('pull_strategy')]: null
|
||||
},
|
||||
log
|
||||
)
|
||||
core.debug(`Current git pull arguments: ${pull}`)
|
||||
await git
|
||||
.fetch(undefined, log)
|
||||
.pull(undefined, undefined, matchGitArgs(pull), log)
|
||||
}
|
||||
|
||||
core.info('> Re-staging files...')
|
||||
@@ -351,8 +350,13 @@ async function checkInputs() {
|
||||
)
|
||||
// #endregion
|
||||
|
||||
// #region pull_strategy
|
||||
if (getInput('pull_strategy') == 'NO-PULL')
|
||||
// #region pull, pull_strategy [deprecated]
|
||||
if (getInput('pull') && getInput('pull_strategy'))
|
||||
throw new Error(
|
||||
"You can't use both pull and pull_strategy as action inputs. Please remove pull_strategy, which is deprecated."
|
||||
)
|
||||
|
||||
if ([getInput('pull'), getInput('pull_strategy')].includes('NO-PULL'))
|
||||
core.debug("NO-PULL found: won't pull from remote.")
|
||||
// #endregion
|
||||
|
||||
|
||||
@@ -14,7 +14,8 @@ interface InputTypes {
|
||||
default_author: 'github_actor' | 'user_info' | 'github_actions'
|
||||
message: string
|
||||
pathspec_error_handling: 'ignore' | 'exitImmediately' | 'exitAtEnd'
|
||||
pull_strategy: string
|
||||
pull: string | undefined
|
||||
pull_strategy: string | undefined
|
||||
push: string
|
||||
remove: string | undefined
|
||||
signoff: undefined
|
||||
|
||||
Reference in New Issue
Block a user