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: allow disabling pushd with --no-cd #52

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

pdecat
Copy link

@pdecat pdecat commented Dec 13, 2024

🗣 Description

This PR allows to alter packer_validate behavior to not change working directory when --no-cd is passed as an argument, like it was before #47.

💭 Motivation and context

Closes #51

🧪 Testing

Tested locally with and without passing --no-cd as args, e.g.:

repos:
  - repo: https://github.com/pdecat/pre-commit-packer
    rev: feat/optional-cd
    hooks:
      - id: packer_validate
        args: [--no-cd] # disable changing working directory
      - id: packer_fmt

✅ Pre-approval checklist

  • This PR has an informative and human-readable title.
  • Changes are limited to a single goal - eschew scope creep!
  • All future TODOs are captured in issues, which are referenced
    in code comments.
  • All relevant type-of-change labels have been added.
  • I have read the CONTRIBUTING document.
  • These code changes follow cisagov code standards.
  • All relevant repo and/or project documentation has been updated
    to reflect the changes in this PR.
  • Tests have been added and/or modified to cover the changes in this PR.
  • All new and existing tests pass.

✅ Pre-merge checklist

  • Revert dependencies to default branches.
  • Finalize version.

✅ Post-merge checklist

  • Create a release.

#######################################
function util::parse_cmdline() {
# Global variable arrays
ARGS=()
FILES=()
export NO_CD=0
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

export is needed to silence shellcheck SC2034.
It works without it, but shellcheck complains:

shellcheck...............................................................Failed
- hook id: shellcheck
- exit code: 1

In lib/util.sh line 23:
        NO_CD=1
        ^---^ SC2034 (warning): NO_CD appears unused. Verify use (or export if used externally).

@pdecat
Copy link
Author

pdecat commented Dec 21, 2024

Rebased on develop to resolve conflicts

@pdecat
Copy link
Author

pdecat commented Dec 22, 2024

Resolved linting issues, not sure how they passed local pre-hooks in the first place 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make pushd in packer_validate hook optional
2 participants