Skip to content

Commit 314739c

Browse files
authored
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
1 parent 69da4fb commit 314739c

File tree

5 files changed

+28
-18
lines changed

5 files changed

+28
-18
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ Add a step like this to your workflow:
6161
# Default: ignore
6262
pathspec_error_handling: ignore
6363

64-
# The flag used on the pull strategy. Use NO-PULL to avoid the action pulling at all.
64+
# Arguments for the git pull command. Use NO-PULL to avoid the action pulling at all.
6565
# Default: '--no-rebase'
66-
pull_strategy: 'NO-PULL or --no-rebase or --no-ff or --rebase'
66+
pull: 'NO-PULL or --rebase --autostash ...'
6767

6868
# 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)
6969
# Default: true

action.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,15 @@ inputs:
3636
description: The way the action should handle pathspec errors from the add and remove commands.
3737
required: false
3838
default: ignore
39+
pull:
40+
description: Arguments for the git pull command. Use NO-PULL to avoid the action pulling at all.
41+
required: false
42+
# Default value currently set in runtime
43+
# default: '--no-rebase'
3944
pull_strategy:
4045
description: The flag used on the pull strategy. Use NO-PULL to avoid the action pulling at all.
4146
required: false
42-
default: '--no-rebase'
47+
deprecationMessage: The 'pull_strategy' input is deprecated, please use 'pull'
4348
push:
4449
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)
4550
required: false

lib/index.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ core.info(`Running in ${baseDir}`)
2626
core.info('> Staging files...')
2727

2828
const peh = getInput('pathspec_error_handling')
29+
2930
if (getInput('add')) {
3031
core.info('> Adding files...')
3132
await add(peh == 'ignore' ? 'pathspec' : 'none')
@@ -60,18 +61,16 @@ core.info(`Running in ${baseDir}`)
6061
.checkout(getInput('branch'), undefined, log)
6162
.catch(() => git.checkoutLocalBranch(getInput('branch'), log))
6263

63-
if (getInput('pull_strategy') == 'NO-PULL')
64-
core.info('> Not pulling from repo.')
64+
// The current default value is set here.
65+
// When the depreacted pull_strategy input is removed, the default should be set via the action manifest.
66+
const pull = getInput('pull') || getInput('pull_strategy') || '--no-rebase'
67+
if (pull == 'NO-PULL') core.info('> Not pulling from repo.')
6568
else {
6669
core.info('> Pulling from remote...')
67-
await git.fetch(undefined, log).pull(
68-
undefined,
69-
undefined,
70-
{
71-
[getInput('pull_strategy')]: null
72-
},
73-
log
74-
)
70+
core.debug(`Current git pull arguments: ${pull}`)
71+
await git
72+
.fetch(undefined, log)
73+
.pull(undefined, undefined, matchGitArgs(pull), log)
7574
}
7675

7776
core.info('> Re-staging files...')
@@ -351,8 +350,13 @@ async function checkInputs() {
351350
)
352351
// #endregion
353352

354-
// #region pull_strategy
355-
if (getInput('pull_strategy') == 'NO-PULL')
353+
// #region pull, pull_strategy [deprecated]
354+
if (getInput('pull') && getInput('pull_strategy'))
355+
throw new Error(
356+
"You can't use both pull and pull_strategy as action inputs. Please remove pull_strategy, which is deprecated."
357+
)
358+
359+
if ([getInput('pull'), getInput('pull_strategy')].includes('NO-PULL'))
356360
core.debug("NO-PULL found: won't pull from remote.")
357361
// #endregion
358362

src/util.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ interface InputTypes {
1414
default_author: 'github_actor' | 'user_info' | 'github_actions'
1515
message: string
1616
pathspec_error_handling: 'ignore' | 'exitImmediately' | 'exitAtEnd'
17-
pull_strategy: string
17+
pull: string | undefined
18+
pull_strategy: string | undefined
1819
push: string
1920
remove: string | undefined
2021
signoff: undefined

0 commit comments

Comments
 (0)