legacy-cli
legacy-cli copied to clipboard
Feature Request: Pull when checking out branch
I'd like the command:
platform checkout [branch]
to pull the latest repo from platform as an option or by default.
platform checkout [branch] --pull
and/or
platform checkout [branch] --pull-rebase
Right now I currently checkout, cd into repository and do a git pull --rebase. Often I find I miss the git pull and am working on an outdated branch.
Would be extra nice if I don't use the --pull
command to be notified that the branch I just pulled down is
Warning: the [branch] branch is X number of commits behind platform
If you have the 'shell aliases' installed (see the README) this could be as easy as:
platform checkout [branch] && plgit pull
... which is only 7 characters longer than your suggestion of:
platform checkout [branch] --pull
The problem would remain that the "platform checkout [branch]" doesn't automatically pull in the latest code into the repository. Would be nice to have a more prominent warning telling users to pull in the latest branch that is X number of commits ahead.
To be clear (if this feature never makes it in and you've found this thread because you want something similar), this is what Patrick is recommending (from README):
Enable auto-completion and shell aliases (optional, but recommended).
In Linux or OS X, add this line to your shell configuration file:
. "$HOME/.composer/vendor/platformsh/cli/platform.rc" 2>/dev/null
In Windows, it would be:
. "$APPDATA/Composer/vendor/platformsh/cli/platform.rc" 2> nul
Also note, this is what the current (2.3.x) CLI does when you are behind... nice warning, but needs a warning color and maybe more whitespace. We really want people to catch on that we are 14 commits behind.
This kind of seems like it should be a feature request for Git. The CLI is just reprinting Git's output there.
Also note that Git is not actually showing you how far you are behind the remote. It's showing you how far you are behind your own local copy of the remote.
I'd like to breathe new life into this issue.
I'm trying to fully containerize our deploy process and rely on an API token (env PLATFORM_CLI_TOKEN
) exclusively. Therefore, the build script cannot run any native git
commands that need to use SSH (such as fetch, pull, push
). (The CLI uses a custom GIT_SSH_COMMAND
to use the SSH key it creates on the fly. I don't want our script to emulate this.)
It's a bit strange that platform checkout
fetches from the remote only if the local branch doesn't exist. (see https://github.com/platformsh/platformsh-cli/blob/3.x/src/Command/Environment/EnvironmentCheckoutCommand.php#L64)
So one workaround is to remove the local branch before platform checkout
, but that's ugly. (Another would be to remove the repo entirely, but come on.)
Therefore, I vote in favor of adding --pull
(or --reset
to git reset --hard $remote/$branch
) to platform checkout
.
I'd be happy to create a PR for this.