Skip to content

Commit

Permalink
feat: add pull input, deprecate pull_strategy (#294)
Browse files Browse the repository at this point in the history
* feat: add pull input and deprecate pull_strategy

* docs(README): update pull docs

* fix: fix DeepScan issue

* fix: minor formatting change
  • Loading branch information
EndBug committed Sep 30, 2021
1 parent 69da4fb commit 314739c
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 18 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion action.yml
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/index.js

Large diffs are not rendered by default.

28 changes: 16 additions & 12 deletions src/main.ts
Expand Up @@ -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')
Expand Down Expand Up @@ -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...')
Expand Down Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion src/util.ts
Expand Up @@ -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
Expand Down

0 comments on commit 314739c

Please sign in to comment.