Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add pull input, deprecate pull_strategy #294

Merged
merged 4 commits into from Sep 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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