JP CLI: add support for git command passthrough #43258
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I realize this may not be the ideal approach. :)
The problem: The
jp
command uses a docker container for running development commands to avoid needing your machine to have the right versions of everything.This works fairly well for all commands in the
jetpack
CLI; however, we expect precommit and prepush hooks to run, which currently are on the local machine. So, we still need things setup right on the local machine.The solution: This adds a
jp git
command that passes through to git on the developer container, where node, etc are all set.Nuance: my gitconfig file has me sign everything by default, but for this iteration, I didn't want to handle some type of key forwarding (which doesn't natively exist like ssh -A). In this initial iteration, just ensure we don't try to sign things.
Proposed changes:
jp git
commands togit
on the dev container.Other information:
Jetpack product discussion
n/a
Does this pull request change what data or activity we track or use?
no
Testing instructions:
./projects/js-packages/jetpack-cli/bin/jp.js --help
[ensure the default behavior works, passing tojetpack
./projects/js-packages/jetpack-cli/bin/jp.js git status
[ensures git works]./projects/js-packages/jetpack-cli/bin/jp.js install -r
[install monorepo root, just in case it hasn't been done]./projects/js-packages/jetpack-cli/bin/jp.js git commit -a -m "test test test"
[after making some local changes, namely to php and js files to let phpcbf, prettier, etc run on precommit]The following will not yet work and will need a follow-up PR.
./projects/js-packages/jetpack-cli/bin/jp.js git push
[need to get key support working]./projects/js-packages/jetpack-cli/bin/jp.js git commit -a
[where it needs to prompt you for the commit messages. to get a quoted string to work, I disabled shell, but that breaks the editor prompt. Will aim to figure this out in a follow-up.