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:
Federico Grandi
2021-09-30 09:33:32 +02:00
committed by GitHub
parent 69da4fbdaf
commit 314739c46f
5 changed files with 28 additions and 18 deletions

View File

@@ -61,9 +61,9 @@ Add a step like this to your workflow:
# Default: ignore # Default: ignore
pathspec_error_handling: 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' # 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) # 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 # Default: true

View File

@@ -36,10 +36,15 @@ inputs:
description: The way the action should handle pathspec errors from the add and remove commands. description: The way the action should handle pathspec errors from the add and remove commands.
required: false required: false
default: ignore 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: pull_strategy:
description: The flag used on the pull strategy. Use NO-PULL to avoid the action pulling at all. description: The flag used on the pull strategy. Use NO-PULL to avoid the action pulling at all.
required: false required: false
default: '--no-rebase' deprecationMessage: The 'pull_strategy' input is deprecated, please use 'pull'
push: 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) 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 required: false

4
lib/index.js generated

File diff suppressed because one or more lines are too long

View File

@@ -26,6 +26,7 @@ core.info(`Running in ${baseDir}`)
core.info('> Staging files...') core.info('> Staging files...')
const peh = getInput('pathspec_error_handling') const peh = getInput('pathspec_error_handling')
if (getInput('add')) { if (getInput('add')) {
core.info('> Adding files...') core.info('> Adding files...')
await add(peh == 'ignore' ? 'pathspec' : 'none') await add(peh == 'ignore' ? 'pathspec' : 'none')
@@ -60,18 +61,16 @@ core.info(`Running in ${baseDir}`)
.checkout(getInput('branch'), undefined, log) .checkout(getInput('branch'), undefined, log)
.catch(() => git.checkoutLocalBranch(getInput('branch'), log)) .catch(() => git.checkoutLocalBranch(getInput('branch'), log))
if (getInput('pull_strategy') == 'NO-PULL') // The current default value is set here.
core.info('> Not pulling from repo.') // 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 { else {
core.info('> Pulling from remote...') core.info('> Pulling from remote...')
await git.fetch(undefined, log).pull( core.debug(`Current git pull arguments: ${pull}`)
undefined, await git
undefined, .fetch(undefined, log)
{ .pull(undefined, undefined, matchGitArgs(pull), log)
[getInput('pull_strategy')]: null
},
log
)
} }
core.info('> Re-staging files...') core.info('> Re-staging files...')
@@ -351,8 +350,13 @@ async function checkInputs() {
) )
// #endregion // #endregion
// #region pull_strategy // #region pull, pull_strategy [deprecated]
if (getInput('pull_strategy') == 'NO-PULL') 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.") core.debug("NO-PULL found: won't pull from remote.")
// #endregion // #endregion

View File

@@ -14,7 +14,8 @@ interface InputTypes {
default_author: 'github_actor' | 'user_info' | 'github_actions' default_author: 'github_actor' | 'user_info' | 'github_actions'
message: string message: string
pathspec_error_handling: 'ignore' | 'exitImmediately' | 'exitAtEnd' pathspec_error_handling: 'ignore' | 'exitImmediately' | 'exitAtEnd'
pull_strategy: string pull: string | undefined
pull_strategy: string | undefined
push: string push: string
remove: string | undefined remove: string | undefined
signoff: undefined signoff: undefined